Browse Source

完善应用消息推送功能/优化巡检模块代码/BUG修复

fanghuisheng 11 months ago
parent
commit
49c351995d

+ 2 - 44
src/App.vue

@@ -15,13 +15,9 @@ function initApp() {
 
   //#ifdef APP-PLUS
   plus.screen.lockOrientation("portrait-primary"); //设置不可横屏
-  pushListener(); //开启消息推送监听
+  proxy.$settingStore.pushListener(); //开启消息推送监听
   proxy.$setting.clearBadge(0); // 清除数字
-
-  proxy.$settingStore.baseAppInfo(); //动态获取用户设备信息
-  setInterval(() => {
-    proxy.$settingStore.baseAppInfo(); //定时获取用户设备信息
-  }, 1000 * 60 * 5);
+  setInterval(proxy.$settingStore.baseAppInfo(), 1000 * 60 * 5);//动态获取用户设备信息
   //#endif
 }
 
@@ -45,44 +41,6 @@ function pushMessage() {
   });
 }
 
-/**
- * @消息推送监听
- */
-function pushListener() {
-  //获取应用的CID
-  uni.getPushClientId({
-    success: (res) => {
-      // console.log(res.cid);
-    },
-    fail(err) {
-      console.log(err);
-    },
-  });
-
-  const platform = uni.getSystemInfoSync().platform;
-  // 点击推送信息
-  plus.push.addEventListener("click", (res) => {
-    console.log(res);
-    if (res.aps) {
-      if ("url" in res.payload) {
-      } else {
-      }
-      console.log(res.payload);
-    }
-  });
-  // 接收推送信息  在线
-  plus.push.addEventListener("receive", (res) => {
-    console.log(res);
-    if (platform == "android") {
-    } else {
-      uni.createPushMessage({
-        title: res.title,
-        content: res.content,
-      });
-    }
-  });
-}
-
 watchEffect(() => {
   //#ifdef APP-PLUS || MP-WEIXIN
   if (uni.getStorageSync("serveUrl")) {

+ 13 - 8
src/components/oa-upload/index.vue

@@ -17,16 +17,16 @@
 
   <!-- 图片上传数量大于1显示 -->
   <view class="oa-upload" v-if="uploadCount > 1">
-    <view class="uploadView" :style="uploadStyle" v-for="up in uploadList" :key="up">
+    <view class="uploadView" :style="uploadStyle" v-for="(up, index) in uploadList" :key="index">
       <view class="uploadUimage">
         <u-image width="100%" height="100%" :src="up[uploadListSrc]" @click="handlePreviewImage(up[uploadListSrc])"></u-image>
       </view>
 
-      <view v-if="!uploadCloseStatus" class="uploadViewClose" @click="uploadViewClose(up)">
+      <view v-if="!uploadCloseStatus" class="uploadViewClose" @click="uploadViewClose(index)">
         <u-icon name="close" color="#ffffff" size="12"></u-icon>
       </view>
     </view>
-    <view :class="uploadCloseStatus ? 'uploadView upload-buttom uploadDisabled' : 'uploadView upload-buttom'" :style="uploadStyle" @click="uploadClick()">
+    <view v-if="uploadCount > uploadList.length" :class="uploadCloseStatus ? 'uploadView upload-buttom uploadDisabled' : 'uploadView upload-buttom'" :style="uploadStyle" @click="uploadClick()">
       <u-icon style="margin: auto" name="plus" color="#909399" :size="uploadIconSize"></u-icon>
     </view>
   </view>
@@ -103,7 +103,11 @@ function uploadClick() {
     sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
     sourceType: ["album", "camera"], //从相册选择、摄像头
     success: function (res) {
-      uploadApi(res);
+      res.tempFilePaths.forEach((url) => {
+        if (uploadList.value.length >= uploadCount.value) {
+          uploadApi(url);
+        }
+      });
     },
   });
 }
@@ -112,8 +116,8 @@ function uploadClick() {
  * @upload图片上传
  * @api接口请求
  */
-function uploadApi(res) {
-  let data = { name: "file", filePath: res.tempFilePaths[0] };
+function uploadApi(url) {
+  let data = { name: "file", filePath: url };
 
   uploadAvatar(data).then((response) => {
     emit("uploadSuccessChange", response.data);
@@ -125,9 +129,10 @@ function uploadApi(res) {
  * @点击事件
  * @删除事件
  */
-function uploadViewClose(el) {
+function uploadViewClose(index) {
   if (uploadCount.value > 1) {
-    emit("uploadDeleteChange", uploadList.value.splice(uploadList.value.indexOf(el), 1));
+    uploadList.value.splice(index, 1);
+    emit("uploadDeleteChange", uploadList.value);
   } else {
     emit("uploadDeleteChange", "");
   }

+ 4 - 2
src/manifest.json

@@ -2,8 +2,8 @@
     "name" : "综合智慧云",
     "appid" : "__UNI__36DE3A0",
     "description" : "综合智慧云app,助力企业数字化转型升级",
-    "versionName" : "2.1.2",
-    "versionCode" : 12,
+    "versionName" : "2.1.3",
+    "versionCode" : 13,
     "transformPx" : false,
     /* 5+App特有相关 */
     "app-plus" : {
@@ -249,3 +249,5 @@
     "vueVersion" : "3",
     "locale" : "zh-Hans"
 }
+/* ios打包配置 *//* SDK配置 */
+

+ 1 - 4
src/pages/business/mhxf/informationSelect/index.vue

@@ -527,11 +527,8 @@ function addZero(s) {
 // end
 
 onLoad((options) => {
-  getNowTime(); //进入页面调用该方法获取当前时间
   clearInterval(myTimeDisplay); //销毁之前定时器
-  var myTimeDisplay = setInterval(() => {
-    getNowTime(); //每秒更新一次时间
-  }, 1000);
+  var myTimeDisplay = setInterval(getNowTime(), 1000); //每秒更新一次时间
 });
 
 onShow(() => {

+ 1 - 4
src/pages/business/zhaf/signIn/index.vue

@@ -104,10 +104,7 @@ onLoad(() => {
   getStatusApi(); //调用人员状态查询接口
 
   //#ifdef APP-PLUS
-  getLocation();
-  inter.interLocation = setInterval(() => {
-    getLocation();
-  }, 1000 * 10);
+  inter.interLocation = setInterval(getLocation(), 1000 * 10);
   //#endif
   inter.interOperateDate = setInterval(() => {
     state.operateDate = proxy.$common.formatterDateTime(new Date());

+ 11 - 7
src/pages/business/zhaf/xunJian/collect/components/collectRecord.vue

@@ -82,13 +82,17 @@ async function handleSelectApi() {
   siteList({
     startTime: state.startTime, //开始时间
     endTime: state.endTime, //结束时间
-  }).then((res) => {
-    if (res.status == "SUCCESS") {
-      state.siteList = res.data;
-      state.total = res.data.length;
-    } else {
-    }
-  });
+  })
+    .then((res) => {
+      if (res.status == "SUCCESS") {
+        state.siteList = res.data;
+        state.total = res.data.length;
+      } else {
+      }
+    })
+    .catch((err) => {
+      proxy.$modal.msg("网络异常,请稍后重试!");
+    });
 }
 
 /**

+ 1 - 1
src/pages/business/zhaf/xunJian/collect/index.vue

@@ -179,7 +179,7 @@ function handleInsert(e) {
         }
       })
       .catch((err) => {
-        proxy.$modal.msgError("当前网络环境异常,请检查网络状态!");
+        proxy.$modal.msg("网络异常,请稍后重试!");
       });
   }
 }

+ 16 - 12
src/pages/business/zhaf/xunJian/plan/components/content.vue

@@ -177,18 +177,22 @@ async function buttonClick(type) {
       recordOptionList: recordOptionList,
     };
 
-    updatePlan(array).then((res) => {
-      if (res.status == "SUCCESS") {
-        title.value = "消息";
-        content.value = "提交成功,确定后返回!";
-        show.value = true;
-      } else {
-        xunJianStore.planDataList.push(array);
-        title.value = "消息";
-        content.value = "提交成功,确定后返回!";
-        show.value = true;
-      }
-    });
+    updatePlan(array)
+      .then((res) => {
+        if (res.status == "SUCCESS") {
+          title.value = "消息";
+          content.value = "提交成功,确定后返回!";
+          show.value = true;
+        } else {
+          xunJianStore.planDataList.push(array);
+          title.value = "消息";
+          content.value = "提交成功,确定后返回!";
+          show.value = true;
+        }
+      })
+      .catch((err) => {
+        proxy.$modal.msg("网络异常,请稍后重试!");
+      });
   }
 }
 

+ 27 - 19
src/pages/business/zhaf/xunJian/plan/components/report.vue

@@ -25,7 +25,7 @@
         <view style="font-size: 13px; color: #a1a1a1; margin-bottom: 5px"> 描述:{{ cu.siteDescribe == "" || cu.siteDescribe == null ? "无" : cu.siteDescribe }} </view>
         <view style="font-size: 13px; color: #a1a1a1">
           完成时间:
-          {{ cu.inspectionTime ? e.inspectionTime.replace("T", " ") : "无" }}
+          {{ cu.inspectionTime ? cu.inspectionTime.replace("T", " ") : "无" }}
         </view>
       </view>
       <view class="reportRight">
@@ -141,18 +141,22 @@ function siteDetailsApi(value) {
     siteId: xunJianStore.siteId,
     siteNubmber: xunJianStore.siteNubmber,
     planSonId: xunJianStore.planSonId,
-  }).then((res) => {
-    if (res.status == "SUCCESS") {
-      currentDateList.value.forEach((res1) => {
-        if (res1.id == res.data.siteList[0].id) {
-          uni.navigateTo({
-            url: "/pages/business/zhaf/xunJian/plan/components/siteDetails",
-          });
-        }
-      });
-    } else {
-    }
-  });
+  })
+    .then((res) => {
+      if (res.status == "SUCCESS") {
+        currentDateList.value.forEach((res1) => {
+          if (res1.id == res.data.siteList[0].id) {
+            uni.navigateTo({
+              url: "/pages/business/zhaf/xunJian/plan/components/siteDetails",
+            });
+          }
+        });
+      } else {
+      }
+    })
+    .catch((err) => {
+      proxy.$modal.msg("网络异常,请稍后重试!");
+    });
 }
 
 /**
@@ -163,12 +167,16 @@ const currentDateList = ref([]); //地点列表list数据存储
 function currentApi() {
   planSonSiteDetails({
     planSonId: xunJianStore.planSonId,
-  }).then((res) => {
-    if (res.status == "SUCCESS") {
-      currentDateList.value = res.data;
-    } else {
-    }
-  });
+  })
+    .then((res) => {
+      if (res.status == "SUCCESS") {
+        currentDateList.value = res.data;
+      } else {
+      }
+    })
+    .catch((err) => {
+      proxy.$modal.msg("网络异常,请稍后重试!");
+    });
 }
 
 onLoad((options) => {

+ 36 - 28
src/pages/business/zhaf/xunJian/plan/components/siteDetails.vue

@@ -21,7 +21,7 @@
         <uni-section class="block mb10" title="上报现场" type="line"></uni-section>
 
         <oa-upload
-          :uploadCount="9"
+          :uploadCount="5"
           :uploadList="siteList.recordPictureList"
           :uploadListSrc="'pictureUrl'"
           :uploadStyle="{
@@ -83,20 +83,24 @@ function selectAPI() {
     siteId: xunJianStore.siteId,
     siteNubmber: xunJianStore.siteNubmber,
     planSonId: xunJianStore.planSonId,
-  }).then((res) => {
-    if (res.status == "SUCCESS") {
-      contentList.value = res.data.contentList;
-      siteList.value = res.data.siteList[0];
-      siteList.value.recordPictureList = [];
-
-      contentList.value.forEach((el) => {
-        el.remarksBool = false;
-        el.contentOptionListValue = "";
-        el.contentOptionListValue1 = [];
-      });
-    } else {
-    }
-  });
+  })
+    .then((res) => {
+      if (res.status == "SUCCESS") {
+        contentList.value = res.data.contentList;
+        siteList.value = res.data.siteList[0];
+        siteList.value.recordPictureList = [];
+
+        contentList.value.forEach((el) => {
+          el.remarksBool = false;
+          el.contentOptionListValue = "";
+          el.contentOptionListValue1 = [];
+        });
+      } else {
+      }
+    })
+    .catch((err) => {
+      proxy.$modal.msg("网络异常,请稍后重试!");
+    });
 }
 
 /**
@@ -139,20 +143,24 @@ onLoad((options) => {
     recordList({
       siteId: xunJianStore.siteId,
       planSonId: xunJianStore.planSonId,
-    }).then((res) => {
-      if (res.status == "SUCCESS") {
-        if (res.data.length > 0) {
-          recordOption({
-            siteId: res.data[0].siteId,
-            recordId: res.data[0].id,
-          }).then((res1) => {
-            contentList.value = res1.data.contentList;
-            siteList.value = res.data[0];
-          });
+    })
+      .then((res) => {
+        if (res.status == "SUCCESS") {
+          if (res.data.length > 0) {
+            recordOption({
+              siteId: res.data[0].siteId,
+              recordId: res.data[0].id,
+            }).then((res1) => {
+              contentList.value = res1.data.contentList;
+              siteList.value = res.data[0];
+            });
+          }
+        } else {
         }
-      } else {
-      }
-    });
+      })
+      .catch((err) => {
+        proxy.$modal.msg("网络异常,请稍后重试!");
+      });
   }
 });
 

+ 65 - 52
src/pages/business/zhaf/xunJian/plan/index.vue

@@ -69,7 +69,7 @@
         <oa-timeLine-item
           v-for="(ac, index) in activities"
           :key="index"
-          :titleValue="ac.planName"
+          :titleValue="ac.siteName"
           :timeValue="ac.createTime"
           :iconColor="proxy.$settingStore.themeColor.color"
           v-show="tabPosition == 1"
@@ -207,20 +207,24 @@ function planListApi(value) {
 
   planList({
     siteNubmber: value,
-  }).then((res) => {
-    if (res.status == "SUCCESS") {
-      if (res.data.length > 0) {
-        scanArray.value = res.data;
-        scanBool.value = true;
+  })
+    .then((res) => {
+      if (res.status == "SUCCESS") {
+        if (res.data.length > 0) {
+          scanArray.value = res.data;
+          scanBool.value = true;
+        } else {
+          uni.showToast({
+            title: "此点位下暂无数据,请切换点位重试!",
+            icon: "none",
+          });
+        }
       } else {
-        uni.showToast({
-          title: "此点位下暂无数据,请切换点位重试!",
-          icon: "none",
-        });
       }
-    } else {
-    }
-  });
+    })
+    .catch((err) => {
+      proxy.$modal.msg("网络异常,请稍后重试!");
+    });
 }
 
 /**
@@ -244,45 +248,50 @@ function activitiesApi() {
     patrolInspectionPlan({
       currentDate: currentDate.value,
       sort: activitiesSort.value,
-    }).then((res) => {
-      if (res.status == "SUCCESS") {
-        res.data.forEach((el) => {
-          activities.value.push({
-            id: el.id,
-            planName: el.planName,
-            timestamp:
-              (el.startTime == null || el.startTime == "" ? "" : el.startTime.split(":")[0] + ":" + el.startTime.split(":")[1] + "~") +
-              (el.endTime == null || el.endTime == "" ? "" : el.endTime.split(":")[0] + ":" + el.endTime.split(":")[1]),
-
-            planStatus: el.planStatus,
-            completion: el.completion,
-            patrolledSiteCount: el.patrolledSiteCount,
-            undetectedSiteCount: el.undetectedSiteCount,
+    })
+      .then((res) => {
+        if (res.status == "SUCCESS") {
+          res.data.forEach((el) => {
+            activities.value.push({
+              id: el.id,
+              planName: el.planName,
+              timestamp: (el.startTime ? el.startTime.split(":")[0] + ":" + el.startTime.split(":")[1] + "~" : "") + (el.endTime ? el.endTime.split(":")[0] + ":" + el.endTime.split(":")[1] : ""),
+              planStatus: el.planStatus,
+              completion: el.completion,
+              patrolledSiteCount: el.patrolledSiteCount,
+              undetectedSiteCount: el.undetectedSiteCount,
+            });
           });
-        });
-      } else {
-      }
-    });
+        } else {
+        }
+      })
+      .catch((err) => {
+        proxy.$modal.msg("网络异常,请稍后重试!");
+      });
   } else if (tabPosition.value == 1) {
     recordList({
       currentDate: currentDate.value,
       sort: activitiesSort.value,
-    }).then((res) => {
-      if (res.status == "SUCCESS") {
-        res.data.forEach((el) => {
-          activities.value.push({
-            siteId: el.siteId,
-            planSonId: el.planSonId,
-            areaName: el.areaName,
-            siteName: el.siteName,
-            contentCount: el.contentCount,
-            createTime: el.createTime ? el.createTime.replace("T", " ") : el.createTime,
-            siteStatus: el.siteStatus,
+    })
+      .then((res) => {
+        if (res.status == "SUCCESS") {
+          res.data.forEach((el) => {
+            activities.value.push({
+              siteId: el.siteId,
+              planSonId: el.planSonId,
+              areaName: el.areaName,
+              siteName: el.siteName,
+              contentCount: el.contentCount,
+              createTime: el.createTime ? el.createTime.replace("T", " ") : el.createTime,
+              siteStatus: el.siteStatus,
+            });
           });
-        });
-      } else {
-      }
-    });
+        } else {
+        }
+      })
+      .catch((err) => {
+        proxy.$modal.msg("网络异常,请稍后重试!");
+      });
   }
 }
 
@@ -296,12 +305,16 @@ const currentDateList = ref({}); //统计list数据存储
 function currentApi() {
   appPlanStatistics({
     currentDate: currentDate.value,
-  }).then((res) => {
-    if (res.status == "SUCCESS") {
-      currentDateList.value = res.data;
-    } else {
-    }
-  });
+  })
+    .then((res) => {
+      if (res.status == "SUCCESS") {
+        currentDateList.value = res.data;
+      } else {
+      }
+    })
+    .catch((err) => {
+      proxy.$modal.msg("网络异常,请稍后重试!");
+    });
 }
 
 /**

+ 4 - 4
src/pages/index.vue

@@ -89,7 +89,7 @@ import { scan_push, getHomePageData, getFunctionalModuleStatistics, getAppRouter
 import { useStores, stystemStores } from "@/store/modules/index";
 /*----------------------------------公共方法引入-----------------------------------*/
 import * as jwx from "@/utils/jssdk.js"; //引入js sdk的封装
-import { storage_stystem } from "@/utils/storage"; // 公共方法引用
+import { storageStystem } from "@/utils/storage"; // 公共方法引用
 /*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
 const useStore = useStores();
@@ -164,7 +164,7 @@ function navItemClick(item) {
     });
     state.recentlyUsed = proxy.$common.sortEvent(state.recentlyUsed, 1);
 
-    storage_stystem.set("homeList", state);
+    storageStystem.set("homeList", state);
 
     if (item.path.indexOf("http") != -1) {
       uni.navigateTo({
@@ -334,7 +334,7 @@ function getMobileBannerApi() {
 function getAppRoutersData() {
   getAppRouters().then((res) => {
     state.cuIconList = res.data;
-    storage_stystem.set("homeList", state);
+    storageStystem.set("homeList", state);
 
     // plus.downloader
     //   .createDownload("http://172.16.120.165:9300/statics/202312/20231201113810A027.jpg", {}, (d, status) => {
@@ -351,7 +351,7 @@ onLoad((option) => {
 });
 
 onShow(() => {
-  var storages = storage_stystem.get("homeList");
+  var storages = storageStystem.get("homeList");
   Object.keys(storages).forEach((key) => {
     state[key] = storages[key];
   });

+ 10 - 3
src/plugins/nfc.plugins.js

@@ -25,6 +25,14 @@ export default {
         if (uni.getSystemInfoSync().platform == "android") {
             listenNFCStatus();
         }
+
+        if (uni.getSystemInfoSync().platform == "ios") {
+            uni.showToast({
+                title: "设备不支持NFC!",
+                icon: "none",
+            });
+            return;
+        }
     },
     readNFC(callback) {
         if (uni.getSystemInfoSync().platform == "android") {
@@ -78,8 +86,8 @@ function listenNFCStatus() {
         plus.globalEvent.addEventListener(
             "newintent",
             function () {
-                // 轮询调用 NFC
-                setTimeout(handleNFCData, 1000);
+                plus.device.vibrate(500);//调用手机震动
+                setTimeout(handleNFCData, 1000);// 轮询调用 NFC
             },
             false
         );
@@ -116,7 +124,6 @@ function handleNFCData() {
     NdefMessage = plus.android.importClass("android.nfc.NdefMessage");
     var main = plus.android.runtimeMainActivity();
     var intent = main.getIntent();
-    //console.log("action type:" + intent.getAction());
     if ("android.nfc.action.TECH_DISCOVERED" == intent.getAction()) {
         if (readyWriteData) {
             //__write(intent);

+ 39 - 1
src/store/modules/setting.js

@@ -13,6 +13,7 @@ import { checkUpdates } from "@/api/system/setting";
 
 const settingStore = defineStore("storage-setting", {
     state: () => ({
+        pushClientId: "",//应用消息推送cid
         currentSize: "",//APP缓存
         barHeight: 0,//微信小程序顶部安全距离
         webViewHeight: "",//webView整体高度-铺满
@@ -73,7 +74,6 @@ const settingStore = defineStore("storage-setting", {
             this.barHeight = CustomBar || 0
             //#endif
         },
-
         /**
          * @动态获取用户设备信息
          */
@@ -115,6 +115,44 @@ const settingStore = defineStore("storage-setting", {
             });
         },
 
+        /**
+         * @消息推送监听
+         */
+        pushListener() {
+            //获取应用的CID
+            uni.getPushClientId({
+                success: (res) => {
+                    this.pushClientId = res.cid
+                },
+                fail(err) {
+                    console.log(err);
+                },
+            });
+
+            const platform = uni.getSystemInfoSync().platform;
+            // 点击推送信息
+            plus.push.addEventListener("click", (res) => {
+                console.log(res);
+                if (res.aps) {
+                    if ("url" in res.payload) {
+                    } else {
+                    }
+                    console.log(res.payload);
+                }
+            });
+            // 接收推送信息  在线
+            plus.push.addEventListener("receive", (res) => {
+                console.log(res);
+                if (platform == "android") {
+                } else {
+                    uni.createPushMessage({
+                        title: res.title,
+                        content: res.content,
+                    });
+                }
+            });
+        },
+
         /**
          * @点击登录
          */

+ 8 - 21
src/store/modules/stystem.js

@@ -2,33 +2,20 @@
 import { defineStore } from "pinia";
 // 接口引用
 // 公共方法引用
-import { storage } from "@/utils/storage";
-import common from "@/plugins/common.plugins.js";
+import { storage, storageStystem } from "@/utils/storage";
 
-const stystemStores = defineStore(`${storage.get("userId")}_storage-stystem`, {
+const stystemStores = defineStore(`storage-stystem`, {
     state: () => ({
-        homeList: {
-            swiperBool: false,
-            swiperIndex: 0,
-            swiperTime: 5000,
-            swiperList: [],
-
-            cuIconList: [],
-            recentlyUsed: [],
-
-            userId: storage.get("userId"),//用户ID
-        },
+        homeList: storageStystem.get("homeList"),
         infoList: {
-            static:{
-                infoTypeStatic:[],
-                total:undefined
+            static: {
+                infoTypeStatic: [],
+                total: undefined
             }
         },
     }),
-    // unistorage: true,
-    actions: {
-
-    },
+    unistorage: true,
+    actions: {},
 });
 
 export default stystemStores;

+ 4 - 2
src/utils/storage.js

@@ -21,7 +21,7 @@ const storage = {
   }
 }
 
-const storage_stystem = {
+const storageStystem = {
   set: function (key, value) {
     let tmp = uni.getStorageSync(useStores().userId + "_storage_common")
     tmp = tmp ? tmp : {}
@@ -39,6 +39,7 @@ const storage_stystem = {
     uni.removeStorageSync(useStores().userId + "_storage_common")
   }
 }
+
 const storage_msgType = {
   set: function (key, value) {
     let tmp = uni.getStorageSync(useStores().userId + "_storage_msgType")
@@ -57,4 +58,5 @@ const storage_msgType = {
     uni.removeStorageSync(useStores().userId + "_storage_msgType")
   }
 }
-export { storage, storage_stystem,storage_msgType }
+
+export { storage, storageStystem, storage_msgType }