Kaynağa Gözat

预警消息离线推送更新

lxh 1 gün önce
ebeveyn
işleme
ba4513d68c

+ 40 - 36
App.vue

@@ -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)
+    //   }
+    // },
 
   }
 };

+ 2 - 8
manifest.json

@@ -82,14 +82,8 @@
                 "push" : {
                     "unipush" : {
                         "version" : "2",
-                        "offline" : false,
-                        "hms" : {},
-                        "oppo" : {},
-                        "vivo" : {},
-                        "mi" : {},
-                        "meizu" : {},
-                        "honor" : {},
-                        "fcm" : {}
+                        "offline" : true,
+                        "hms" : {}
                     }
                 }
             },

+ 1 - 1
pages/gasreport/components/gasFill.vue

@@ -206,7 +206,7 @@ export default {
             nfcShow: true,//是否使用NFC
             isDisabled: false,
             isStatus: '',
-            deviceId: '1',
+            deviceId: '',
             rangeBc: [
                 { value: '夜班', text: "夜班" },
                 { value: '早班', text: "早班" },

+ 1 - 0
pages/login/login.vue

@@ -176,6 +176,7 @@ export default {
       let loginParams = {
         username: this.userName,
         password: this.password,
+        clientId:uni.getStorageSync('push_cid')
       };
       // 加密
       const loginCipher = getLoginCipher();

+ 5 - 0
uniCloud-aliyun/cloudfunctions/testPush/index.js

@@ -12,6 +12,11 @@ exports.main = async (event, context) => {
 		"content": event.queryStringParameters.content,
 		"payload": {
 			"text":"体验一下uni-push2.0" 
+		},
+		"options":{
+			"HW":{
+				"/message/android/category":"DEVICE_REMINDER"
+			}
 		}
 	})
 };