Bläddra i källkod

预警信息离线推送-修改提交

lxh 1 dag sedan
förälder
incheckning
42d650da0b

+ 1 - 1
.hbuilderx/launch.json

@@ -2,7 +2,7 @@
     "version" : "1.0",
     "configurations" : [
         {
-            "playground" : "standard",
+            "playground" : "custom",
             "type" : "uni-app:app-android"
         },
         {

+ 10 - 53
App.vue

@@ -6,7 +6,6 @@
 import Vue from "vue";
 import appUpdate from "common/util/appUpdate.js";
 import configService from "@/common/service/config.service.js";
-import { connectWebSocket, sendWebSocketMessage, closeWebSocket } from '@/common/util/websocket'
 export default {
   data() {
     return {
@@ -25,17 +24,14 @@ export default {
         console.log(err)
       }
     });
-    // plus.push.addEventListener('click', (msg) => {
-    //   console.log('点击消息内容:', msg);
-
-    // });
-    uni.onPushMessage((res) => {
-      //客户端监听推送消息
-      console.log("收到推送消息:", res) //监听推送消息
-      if (res.data) {
-        uni.createPushMessage(res.data)  //收到消息推送,创建系统状态栏及锁屏通 知
-      }
-    })
+  
+    // uni.onPushMessage((res) => {
+    //   //客户端监听推送消息
+    //   console.log("收到推送消息:", res) //监听推送消息
+    //   if (res.data) {
+    //     uni.createPushMessage(res.data)  //收到消息推送,创建系统状态栏及锁屏通 知
+    //   }
+    // })
 
     const savedIP = uni.getStorageSync("selectedIP");
     if (configService.apiUrl !== "") {
@@ -307,52 +303,13 @@ export default {
   },
   onShow: function () {
     console.log("App Show");
-    // 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)
-    //     }
-    //   })
-    // },
-
-    //连接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)
-    //       // }
-    //       that.getInfoInit('111', '2222')
-    //     });
-    //   } catch (err) {
-    //     console.log('连接失败: ' + err)
-    //   }
-    // },
-
-  }
+  methods: {}
 };
 </script>
 

+ 2 - 2
manifest.json

@@ -25,9 +25,9 @@
         ],
         /* 5+App特有相关 */
         "modules" : {
-            "Push" : {},
             "VideoPlayer" : {},
-            "Camera" : {}
+            "Camera" : {},
+            "Push" : {}
         },
         /* 模块配置 */
         "distribute" : {

+ 6 - 4
pages/gasreport/components/gasFill.vue

@@ -266,9 +266,10 @@ export default {
     },
     watch: {
         cardIds: {
-            handler(newV, oldV) {
+           async handler(newV, oldV) {
                 if (newV) {
-                    this.getCardLists(newV)
+                  await  this.getCardLists(newV)
+                  this.change()
                 }
             },
             immediate: true
@@ -1107,8 +1108,8 @@ export default {
         //检测时间下拉选项切换
         change(e) {
             let that = this
-            that.formState.time = moment(e.value).format('YYYY-MM-DD HH:mm:ss')
-            that.formState.tbrq = moment(e.value).format('YYYY-MM-DD')
+            // that.formState.time = moment(e.value).format('YYYY-MM-DD HH:mm:ss')
+            // that.formState.tbrq = moment(e.value).format('YYYY-MM-DD')
             new Promise((resolve, reject) => {
                 api
                     .getGas({ reportTime: that.formState.tbrq, deviceId: that.deviceId })
@@ -1553,6 +1554,7 @@ export default {
             if (that.nfcShow) {
                 testNfc.listenNFCStatus()
                 testNfc.readData();
+                // that.change()
             }
 
         },

+ 3 - 7
uniCloud-aliyun/cloudfunctions/testPush/index.js

@@ -6,16 +6,12 @@ const uniPush = uniCloud.getPushManager({appId:"__UNI__2000523"}) //注意这里
 exports.main = async (event, context) => {
 	console.log('event',event);
 	console.log('context',context); 
+	const pushParam=JSON.parse(event.body)
 	return await uniPush.sendMessage({
-		"push_clientid": event.queryStringParameters.cid, 	//填写上一步在uni-app客户端获取到的客户端推送标识push_clientid
-		"title":event.queryStringParameters.title,	
-		"content": event.queryStringParameters.content,
-		"payload": {
-			"text":"体验一下uni-push2.0" 
-		},
+		...pushParam,
 		"options":{
 			"HW":{
-				"/message/android/category":"DEVICE_REMINDER"
+				"/message/android/category":"WORK"
 			}
 		}
 	})