Selaa lähdekoodia

提交新版本

lxh 2 päivää sitten
vanhempi
commit
39d2221d49

+ 43 - 1
App.vue

@@ -8,8 +8,27 @@ import appUpdate from "common/util/appUpdate.js";
 import configService from "@/common/service/config.service.js";
 export default {
   onLaunch: function () {
-    const savedIP = uni.getStorageSync("selectedIP");
+    //消息推送
+    	uni.getPushClientId({
+        //获取客户端推送标识
+				success: (res) => {
+					console.log(res.cid,'cid---');
+          uni.setStorageSync('push_cid', res.cid); // 存储CID供后续使用
+				},
+				fail(err) {
+					console.log(err)
+				}
+			});
+			uni.onPushMessage((res) => {
+        //客户端监听推送消息
+				console.log("收到推送消息:",res) //监听推送消息
+				if(res.data){
+				    console.log(res.data)
+				    uni.createPushMessage(res.data)  //收到消息推送,创建系统状态栏及锁屏通 知
+				}
+		    })
 
+    const savedIP = uni.getStorageSync("selectedIP");
     if (configService.apiUrl !== "") {
       uni.getSystemInfo({
         success: function (e) {
@@ -279,11 +298,34 @@ export default {
   },
   onShow: function () {
     console.log("App Show");
+   this.times= setInterval(()=>this.getInfoInit(),10000)  
   },
   onHide: function () {
     console.log("App Hide");
     clearInterval(this.$store.state.timer); // 假设定时器存储在 Vuex 的状态管理中
   },
+  methods:{
+    //获取推送消息,标题
+    getInfoInit(){
+      console.log('获取推送消息,标题---')
+      console.log(uni.getStorageSync('push_cid'), '111')
+       uni.request({
+        url: 'https://fc-mp-2578c13f-eaaa-45e9-a01e-6a48b45fb7a0.next.bspapp.com/testPush', //云函数url
+        data: {
+          cid: uni.getStorageSync('push_cid'),
+          title: '报警信息通知', //可按需传入动态参数,在云函数index.js接收参数
+          content: '测试通知信息',
+        },
+        method: 'get',
+        success(result) {
+          console.log('发送通知', result);
+        },
+        fail({ errMsg }) {
+          console.log('request fail', errMsg)
+        }
+      })
+    }
+  }
 };
 </script>
 

+ 1 - 1
manifest.json

@@ -82,7 +82,7 @@
                 "push" : {
                     "unipush" : {
                         "version" : "2",
-                        "offline" : true,
+                        "offline" : false,
                         "hms" : {},
                         "oppo" : {},
                         "vivo" : {},

+ 11 - 4
pages/gasreport/components/Recognition.vue

@@ -2,12 +2,12 @@
     <view class="Recognition">
         <u-list :height="666">
             <u-list-item v-for="(item, index) in listData" :key="index">
-                <u-cell :title="`${item.deviceName} (${item.checkNum == '1' ? '第一次' :
+                <u-cell  :title="`${item.deviceName} (${item.checkNum == '1' ? '第一次' :
                     item.checkNum == '2' ? '第二次' : ''})`" @click="getSbClick(item)">
                     <u-avatar slot="icon" shape="square" size="35" :src="item.img"
                         customStyle="margin: -3px 5px -3px 0"></u-avatar>
-                    <view slot="value" style="display: flex;align-items: center;">
-                        <text>{{ item.status=='0' ? '处理中...' : item.status=='1' ? '识别成功' : item.status=='2' ? '识别失败' : '' }}</text>
+                    <view slot="value" style="display: flex;align-items: center;margin-left: 20px;">
+                        <text :class="item.status=='2' ? 'fail-text' : 'suc-text'">{{ item.status=='0' ? '处理中' : item.status=='1' ? '识别成功' : item.status=='2' ? '识别失败' : '' }}</text>
                     </view>
                 </u-cell>
             </u-list-item>
@@ -137,9 +137,16 @@ export default {
 .Recognition {
     position: relative;
     width: 100%;
-    height: 100%;
     background-color: #fff;
 
+    .suc-text{
+        font-size: 12px;
+        color: rgb(118, 236, 88);
+    }
+    .fail-text{
+         font-size: 12px;
+        color: rgb(240, 20, 4);
+    }
 }
 
 ::v-deep .u-slot-title {

+ 5 - 5
pages/gasreport/components/gasImgIdentify.vue

@@ -199,11 +199,11 @@ export default {
         return []
       }
     },
-    urlData:{
-      type:String,
-      default:''
+    urlData: {
+      type: String,
+      default: ''
     }
-    
+
   },
 
   data() {
@@ -375,7 +375,7 @@ export default {
     getSbFill() {
       let that = this
       that.deviceId = that.deviceID;
-      that.imageSrc=that.urlData
+      that.imageSrc = that.urlData
       let status = that.sbData[0].status
       if (status != '2') {
         if (that.sbData.length != 0) {

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

@@ -53,7 +53,7 @@ export default {
             showCalendar: false,//控制日期选型下拉开启
             // timeRan: Number(new Date()),
             // minDate: moment().subtract(30, 'days').format('YYYY-MM-DD'),
-            minDate: moment().subtract(115, 'days').format('YYYY-MM-DD'),
+            minDate: moment().subtract(120, 'days').format('YYYY-MM-DD'),
             maxDate:moment().add(30, 'days').format('YYYY-MM-DD'),
             isShow: true,
             loadComponent: '',

+ 10 - 5
pages/gasreport/components/taskBoardAddress.vue

@@ -122,11 +122,13 @@ export default {
             let that = this
             that.isShow = false
             that.sbShow = true
-            that.showBtn=false
-            uni.showLoading({
-    title: '批量识别中...',
-    mask: true
-});
+            that.showBtn = false
+            if (that.recognitionData.length != 0) {
+                uni.showLoading({
+                    title: '批量识别中...',
+                    mask: true
+                });
+            }
         },
         //批量识别后跳转到填报页面
         getRepport(param) {
@@ -210,9 +212,12 @@ export default {
     width: 100%;
     height: 100%;
     background-color: #fff;
+    padding: 0px 10px;
+    box-sizing: border-box;
 
 }
 
+
 ::v-deep .u-slot-title {
     display: flex;
 }

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

@@ -0,0 +1,17 @@
+'use strict';
+ 
+const { log } = require("console");
+ 
+const uniPush = uniCloud.getPushManager({appId:"__UNI__2000523"}) //注意这里需要传入你的应用appId,用于指定接收消息的客户端
+exports.main = async (event, context) => {
+	console.log('event',event);
+	console.log('context',context); 
+	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" 
+		}
+	})
+};

+ 8 - 0
uniCloud-aliyun/cloudfunctions/testPush/package.json

@@ -0,0 +1,8 @@
+{
+  "name": "testPush",
+  "dependencies": {},
+  "extensions": {
+    "uni-cloud-jql": {},
+    "uni-cloud-push": {}
+  }
+}