|
@@ -25,6 +25,10 @@ export default {
|
|
|
console.log(err)
|
|
|
}
|
|
|
});
|
|
|
+ // plus.push.addEventListener('click', (msg) => {
|
|
|
+ // console.log('点击消息内容:', msg);
|
|
|
+
|
|
|
+ // });
|
|
|
uni.onPushMessage((res) => {
|
|
|
//客户端监听推送消息
|
|
|
console.log("收到推送消息:", res) //监听推送消息
|
|
@@ -303,50 +307,50 @@ export default {
|
|
|
},
|
|
|
onShow: function () {
|
|
|
console.log("App Show");
|
|
|
- this.getConnect()
|
|
|
+ // this.getConnect()
|
|
|
},
|
|
|
onHide: function () {
|
|
|
console.log("App Hide");
|
|
|
clearInterval(this.$store.state.timer); // 假设定时器存储在 Vuex 的状态管理中
|
|
|
},
|
|
|
methods: {
|
|
|
-
|
|
|
- //获取推送消息,标题
|
|
|
- getInfoInit(title, message) {
|
|
|
- uni.request({
|
|
|
- url: 'https://fc-mp-2578c13f-eaaa-45e9-a01e-6a48b45fb7a0.next.bspapp.com/testPush', //云函数url
|
|
|
- data: {
|
|
|
- cid: uni.getStorageSync('push_cid'),
|
|
|
- title: title, //可按需传入动态参数,在云函数index.js接收参数
|
|
|
- content: message,
|
|
|
- },
|
|
|
- method: 'get',
|
|
|
- success(result) {
|
|
|
- console.log('发送通知', result);
|
|
|
- },
|
|
|
- fail({ errMsg }) {
|
|
|
- console.log('request fail', errMsg)
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
+ // //获取推送消息,标题
|
|
|
+ // getInfoInit(title, message) {
|
|
|
+ // uni.request({
|
|
|
+ // url: 'https://fc-mp-2578c13f-eaaa-45e9-a01e-6a48b45fb7a0.next.bspapp.com/testPush', //云函数url
|
|
|
+ // data: {
|
|
|
+ // cid: uni.getStorageSync('push_cid'),
|
|
|
+ // title: title, //可按需传入动态参数,在云函数index.js接收参数
|
|
|
+ // content: message,
|
|
|
+ // },
|
|
|
+ // method: 'get',
|
|
|
+ // success(result) {
|
|
|
+ // console.log('发送通知', result);
|
|
|
+ // },
|
|
|
+ // fail({ errMsg }) {
|
|
|
+ // console.log('request fail', errMsg)
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // },
|
|
|
|
|
|
//连接websocket
|
|
|
- async getConnect() {
|
|
|
- let that = this
|
|
|
- try {
|
|
|
- that.socketTask = await connectWebSocket();
|
|
|
- that.socketTask.onMessage((res) => {
|
|
|
- console.log('收到消息:websocket已连接 ', res)
|
|
|
- let message = JSON.parse(res.data)
|
|
|
- //报警信息推送
|
|
|
- if (message.warndata) {
|
|
|
- that.getInfoInit(message.msgTitle, message.warndata)
|
|
|
- }
|
|
|
- });
|
|
|
- } catch (err) {
|
|
|
- console.log('连接失败: ' + err)
|
|
|
- }
|
|
|
- },
|
|
|
+ // async getConnect() {
|
|
|
+ // let that = this
|
|
|
+ // try {
|
|
|
+ // that.socketTask = await connectWebSocket();
|
|
|
+ // that.socketTask.onMessage((res) => {
|
|
|
+ // console.log('收到消息:websocket已连接 ', res)
|
|
|
+ // // let message = JSON.parse(res.data)
|
|
|
+ // // //报警信息推送
|
|
|
+ // // if (message.warndata) {
|
|
|
+ // // that.getInfoInit(message.msgTitle, message.warndata)
|
|
|
+ // // }
|
|
|
+ // that.getInfoInit('111', '2222')
|
|
|
+ // });
|
|
|
+ // } catch (err) {
|
|
|
+ // console.log('连接失败: ' + err)
|
|
|
+ // }
|
|
|
+ // },
|
|
|
|
|
|
}
|
|
|
};
|