浏览代码

巡更系统优化/代码优化/新增物理监听功能、websocket

fanghuisheng 9 月之前
父节点
当前提交
8ed864b669

+ 6 - 6
src/App.vue

@@ -8,24 +8,24 @@ import { defineComponent, getCurrentInstance, inject, nextTick, onMounted, watch
 /*----------------------------------公共方法引入-----------------------------------*/
 import config from "./config";
 import { storageSystem } from "@/utils/storage";
+import JKeyListen from "@/utils/keyListen.js";
 /*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
 /*----------------------------------变量声明-----------------------------------*/
 
 function initApp() {
-  //初始化默认主题
-  proxy.$settingStore.initThemeColor();
-  //初始化获取安全区高度
-  proxy.$settingStore.systemHeightTop();
-  //隐藏自带tabbar
-  uni.hideTabBar();
+  proxy.$settingStore.initThemeColor(); //初始化默认主题
+  proxy.$settingStore.systemHeightTop(); //初始化获取安全区高度
+  uni.hideTabBar(); //隐藏自带tabbar
 
   //#ifdef APP-PLUS
   plus.screen.lockOrientation("portrait-primary"); //设置不可横屏
   proxy.$settingStore.pushListener(); //开启消息推送监听
+  // JKeyListen.startListen(true); //开启物理按钮监听
   //#endif
 }
 
+
 // 设置手机通知权限
 function setPermissions() {
   // #ifdef APP-PLUS

+ 1 - 1
src/config.js

@@ -40,7 +40,7 @@ export default {
       {
         title: "隐私政策",
         content: "暂无数据",
-        url: "http://file.usky.cn/statics/protocol.html",
+        url: "http://file.usky.cn/uskycloud/privacy_protocol.html",
       },
     ],
   },

+ 22 - 10
src/pages/business/fireIot/deviceManage/components/deviceDetails.vue

@@ -1,6 +1,15 @@
 <template>
-  <scroll-view class="scroll-height" :scroll-y="true" :data-theme="'theme-' + proxy.$settingStore.themeColor.name">
-    <view class="deviceDetails-container">
+  <oa-scroll
+    customClass="deviceDetails-container scroll-height"
+    :refresherLoad="false"
+    :refresherEnabled="false"
+    :refresherEnabledTitle="false"
+    :refresherDefaultStyle="'none'"
+    :refresherThreshold="44"
+    :refresherBackground="'#f5f6f7'"
+    :data-theme="'theme-' + proxy.$settingStore.themeColor.name"
+  >
+    <template #default>
       <view class="flex bg-white p15 mb15">
         <image style="width: 40px; height: 40px; margin: auto 15px auto 0" :src="'/static/images/404.png'" mode="aspectFill"></image>
 
@@ -87,22 +96,25 @@
       </u-modal>
 
       <uni-calendar ref="calendar" class="uni-calendar--hook" :clearDate="false" :insert="false" :lunar="false" :range="true" @confirm="calendarConfirm" />
-    </view>
-  </scroll-view>
+    </template>
+  </oa-scroll>
 </template>
 
 <script setup>
+/*----------------------------------依赖引入-----------------------------------*/
 import { onLoad, onShow, onReady, onHide, onLaunch, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
 import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
-import { useStores, commonStores } from "@/store/modules/index";
-
-import chart from "./chart.vue";
-
+/*----------------------------------接口引入-----------------------------------*/
 import { dmpProductAttribute, historyMetrics, last } from "@/api/business/fireIot/deviceManage.js";
-
+/*----------------------------------组件引入-----------------------------------*/
+import chart from "./chart.vue";
+/*----------------------------------store引入-----------------------------------*/
+import { useStores, commonStores } from "@/store/modules/index";
+/*----------------------------------公共方法引入-----------------------------------*/
+/*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
 const commonStore = commonStores();
-
+/*----------------------------------变量声明-----------------------------------*/
 const dataList = ref([
   {
     title: "设备类型",

+ 32 - 16
src/pages/business/fireIot/facilitiesManage/facilitiesDetails.vue

@@ -1,6 +1,15 @@
 <template>
-  <scroll-view class="scroll-height" :scroll-y="true" :data-theme="'theme-' + proxy.$settingStore.themeColor.name">
-    <view class="facilitiesDetails-container">
+  <oa-scroll
+    customClass="facilitiesDetails-container scroll-height"
+    :refresherLoad="false"
+    :refresherEnabled="false"
+    :refresherEnabledTitle="false"
+    :refresherDefaultStyle="'none'"
+    :refresherThreshold="44"
+    :refresherBackground="'#f5f6f7'"
+    :data-theme="'theme-' + proxy.$settingStore.themeColor.name"
+  >
+    <template #default>
       <view class="flex bg-white p15 mb15">
         <image style="width: 40px; height: 40px; margin: auto 15px auto 0" :src="dataArray.imagesUrl ? dataArray.imagesUrl : '/static/images/404.png'" mode="aspectFill"></image>
 
@@ -37,7 +46,7 @@
         <uni-section class="block mb10" title="关联设备" type="line"></uni-section>
 
         <view class="flex mb10" style="height: 35px; line-height: 35px">
-          <u-input v-model="deviceId" placeholder="设备编号" @change="deviceInfoApi()" disabledColor="transparent" prefixIcon="search" prefixIconStyle="font-size: 22px;color: #909399" clearable />
+          <u-input v-model="state.deviceId" placeholder="设备编号" @change="deviceInfoApi()" disabledColor="transparent" prefixIcon="search" prefixIconStyle="font-size: 22px;color: #909399" clearable />
         </view>
 
         <view class="tableType1">
@@ -76,7 +85,7 @@
         <uni-section class="block mb10" title="关联建筑" type="line"></uni-section>
 
         <view class="flex mb10" style="height: 35px; line-height: 35px">
-          <u-input v-model="buildNum" placeholder="建筑编号" @change="buildInfoApi()" disabledColor="transparent" prefixIcon="search" prefixIconStyle="font-size: 22px;color: #909399" clearable />
+          <u-input v-model="state.buildNum" placeholder="建筑编号" @change="buildInfoApi()" disabledColor="transparent" prefixIcon="search" prefixIconStyle="font-size: 22px;color: #909399" clearable />
         </view>
 
         <view class="tableType1">
@@ -110,22 +119,29 @@
           </u-row>
         </view>
       </view>
-    </view>
-  </scroll-view>
+    </template>
+  </oa-scroll>
 </template>
 
 <script setup>
+/*----------------------------------依赖引入-----------------------------------*/
 import { onLoad, onShow, onReady, onHide, onLaunch, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
 import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
-import { useStores, commonStores } from "@/store/modules/index";
-
+/*----------------------------------接口引入-----------------------------------*/
 import { facilityInfo, deviceInfo, buildInfo } from "@/api/business/fireIot/facilitiesManage.js";
-
+/*----------------------------------组件引入-----------------------------------*/
+/*----------------------------------store引入-----------------------------------*/
+import { useStores, commonStores } from "@/store/modules/index";
+/*----------------------------------公共方法引入-----------------------------------*/
+/*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
+/*----------------------------------变量声明-----------------------------------*/
+const state = reactive({
+  id: undefined,
+  deviceId: undefined,
+  buildNum: undefined,
+});
 
-const id = ref(undefined);
-const deviceId = ref(undefined);
-const buildNum = ref(undefined);
 const dataArray = ref({});
 const dataList = ref([
   { title: "设施类型", value: "" },
@@ -141,7 +157,7 @@ const dataList2 = ref([]);
  * @页面初始化
  */
 function init() {
-  facilityInfo({ id: id.value }).then((requset) => {
+  facilityInfo({ id: state.id }).then((requset) => {
     if (requset.status === "SUCCESS") {
       dataArray.value = requset.data[0];
       dataList.value[1].value = requset.data[0].facilityNum ? requset.data[0].facilityNum : "无";
@@ -159,7 +175,7 @@ function init() {
  * @api接口请求
  */
 function deviceInfoApi() {
-  deviceInfo({ id: id.value, deviceId: deviceId.value, current: 1, size: 1000 }).then((requset) => {
+  deviceInfo({ id: state.id, deviceId: state.deviceId, current: 1, size: 1000 }).then((requset) => {
     if (requset.status === "SUCCESS") {
       dataList1.value = requset.data.records;
     }
@@ -171,7 +187,7 @@ function deviceInfoApi() {
  * @api接口请求
  */
 function buildInfoApi() {
-  buildInfo({ id: id.value, buildNum: buildNum.value, current: 1, size: 1000 }).then((requset) => {
+  buildInfo({ id: state.id, buildNum: state.buildNum, current: 1, size: 1000 }).then((requset) => {
     if (requset.status === "SUCCESS") {
       dataList2.value = requset.data.records;
     }
@@ -190,7 +206,7 @@ onLoad((options) => {
     dataList.value[0].value = options.typeName;
   }
   if ("id" in options) {
-    id.value = parseInt(options.id);
+    state.id = parseInt(options.id);
     init();
   }
 });

+ 57 - 50
src/pages/business/fireIot/repairManage/repairDetails.vue

@@ -1,6 +1,15 @@
 <template>
-  <scroll-view class="scroll-height" :scroll-y="true" :data-theme="'theme-' + proxy.$settingStore.themeColor.name">
-    <view class="alarmDetails-container">
+  <oa-scroll
+    customClass="repairDetails-container scroll-height"
+    :refresherLoad="false"
+    :refresherEnabled="false"
+    :refresherEnabledTitle="false"
+    :refresherDefaultStyle="'none'"
+    :refresherThreshold="44"
+    :refresherBackground="'#f5f6f7'"
+    :data-theme="'theme-' + proxy.$settingStore.themeColor.name"
+  >
+    <template #default>
       <view class="flex bg-white p15 mb15">
         <image style="width: 40px; height: 40px; margin: auto 15px auto 0" :src="dataArray.typeImg ? dataArray.typeImg : '/static/images/404.png'" mode="aspectFill"></image>
 
@@ -73,34 +82,41 @@
           ></u-button>
         </view>
       </view>
-    </view>
-  </scroll-view>
+    </template>
+  </oa-scroll>
 </template>
 
 <script setup>
+/*----------------------------------依赖引入-----------------------------------*/
 import { onLoad, onShow, onReady, onHide, onLaunch, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
 import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
-import { useStores, commonStores } from "@/store/modules/index";
-
+/*----------------------------------接口引入-----------------------------------*/
 import { page, fill } from "@/api/business/fireIot/repairManage.js";
-
+/*----------------------------------组件引入-----------------------------------*/
+/*----------------------------------store引入-----------------------------------*/
+import { useStores, commonStores } from "@/store/modules/index";
+/*----------------------------------公共方法引入-----------------------------------*/
+/*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
 const useStore = useStores();
+/*----------------------------------变量声明-----------------------------------*/
+const state = reactive({
+  dataArray: {},
+  dataList: [
+    { title: "报修日期", value: "" },
+    { title: "项目名称", value: "" },
+    { title: "报修人", value: "" },
+    { title: "报修电话", value: "" },
+    { title: "问题描述", value: "" },
+    { title: "报修地址", value: "" },
+  ],
+  repairCode: "",
+  pageSize: 20,
+  current: 1,
+  total: 0,
+});
 
-const dataArray = ref({});
-const dataList = ref([
-  { title: "报修日期", value: "" },
-  { title: "项目名称", value: "" },
-  { title: "报修人", value: "" },
-  { title: "报修电话", value: "" },
-  { title: "问题描述", value: "" },
-  { title: "报修地址", value: "" },
-]);
-
-const repairCode = ref("");
-const pageSize = ref(20);
-const current = ref(1);
-const total = ref(0);
+const { dataArray, dataList, repairCode, pageSize, current, total } = toRefs(state);
 
 /**
  * @页面初始化
@@ -115,35 +131,26 @@ function init() {
  */
 function selectListApi() {
   page({
-    repairCode: repairCode.value,
-    current: current.value,
-    size: pageSize.value,
+    repairCode: state.repairCode,
+    current: state.current,
+    size: state.pageSize,
   }).then((requset) => {
     if (requset.status === "SUCCESS") {
-      dataArray.value = requset.data.records[0];
-      dataArray.value.handleName = requset.data.records[0].handleName ? requset.data.records[0].handleName : useStore.nickName ? useStore.nickName : "";
-      dataArray.value.handleContent = requset.data.records[0].handleContent ? requset.data.records[0].handleContent : "";
+      state.dataArray = requset.data.records[0];
+      state.dataArray.handleName = requset.data.records[0].handleName ? requset.data.records[0].handleName : useStore.nickName ? useStore.nickName : "";
+      state.dataArray.handleContent = requset.data.records[0].handleContent ? requset.data.records[0].handleContent : "";
 
-      dataList.value[0].value = requset.data.records[0].createTime ? requset.data.records[0].createTime.replace("T", " ") : requset.data[0].createTime;
-      dataList.value[1].value = requset.data.records[0].projectName;
-      dataList.value[2].value = requset.data.records[0].reflectName;
-      dataList.value[3].value = requset.data.records[0].reflectPhone;
-      dataList.value[4].value = requset.data.records[0].repairContent;
-      dataList.value[5].value = requset.data.records[0].projectAddress;
+      state.dataList[0].value = requset.data.records[0].createTime ? requset.data.records[0].createTime.replace("T", " ") : requset.data[0].createTime;
+      state.dataList[1].value = requset.data.records[0].projectName;
+      state.dataList[2].value = requset.data.records[0].reflectName;
+      state.dataList[3].value = requset.data.records[0].reflectPhone;
+      state.dataList[4].value = requset.data.records[0].repairContent;
+      state.dataList[5].value = requset.data.records[0].projectAddress;
 
       if (requset.data.records[0].repairStatus === 2) {
-        dataList.value.push(
-          {
-            title: "评分",
-            value: 0,
-          },
-          {
-            title: "评分内容",
-            value: "",
-          }
-        );
-        dataList.value[6].value = requset.data.records[0].score ? requset.data.records[0].score : 0;
-        dataList.value[7].value = requset.data.records[0].appraiseContent;
+        state.dataList.push({ title: "评分", value: 0 }, { title: "评分内容", value: "" });
+        state.dataList[6].value = requset.data.records[0].score ? requset.data.records[0].score : 0;
+        state.dataList[7].value = requset.data.records[0].appraiseContent;
       }
 
       total.value = requset.data.total;
@@ -158,15 +165,15 @@ function handleSubmit(type) {
   if (type == 1) {
     proxy.$tab.navigateBack(1);
   } else {
-    if (!dataArray.value.handleName) {
+    if (!state.dataArray.handleName) {
       proxy.$modal.msg("请输入报修人");
       return;
     }
 
     fill({
-      id: dataArray.value.id,
-      handleName: dataArray.value.handleName,
-      handleContent: dataArray.value.handleContent,
+      id: state.dataArray.id,
+      handleName: state.dataArray.handleName,
+      handleContent: state.dataArray.handleContent,
     }).then((res) => {
       if (requset.status === "SUCCESS") {
         proxy.$tab.navigateTo(`/pages/common/success/index?codeName=提交成功`);
@@ -184,7 +191,7 @@ onShow(() => {
 
 onLoad((options) => {
   if ("repairCode" in options) {
-    repairCode.value = options.repairCode;
+    state.repairCode = options.repairCode;
   }
 
   init();

+ 32 - 23
src/pages/business/fireIot/repairManage/repairDetailsList.vue

@@ -7,6 +7,7 @@
     customClass="repairManage-container scroll-height"
     :pageSize="pageSize"
     :total="total"
+    :isSticky="true"
     :refresherLoad="true"
     :refresherEnabled="true"
     :refresherDefaultStyle="'none'"
@@ -41,26 +42,34 @@
 </template>
 
 <script setup>
+/*----------------------------------依赖引入-----------------------------------*/
 import { onLoad, onShow, onReady, onHide, onLaunch, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
 import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
-import { useStores, commonStores } from "@/store/modules/index";
-
+/*----------------------------------接口引入-----------------------------------*/
 import { page } from "@/api/business/fireIot/repairManage.js";
-
+/*----------------------------------组件引入-----------------------------------*/
+/*----------------------------------store引入-----------------------------------*/
+import { useStores, commonStores } from "@/store/modules/index";
+/*----------------------------------公共方法引入-----------------------------------*/
+/*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
-const commonStore = commonStores();
-
-const tabsList = ref([
-  { name: "全部", value: "" },
-  { name: "受理中", value: 1 },
-  { name: "处理完成", value: 2 },
-]);
-const tabsCurrent = ref(1);
+const commonStore = commonStores(); //全局公共Store
+/*----------------------------------变量声明-----------------------------------*/
+const state = reactive({
+  tabsList: [
+    { name: "全部", value: "" },
+    { name: "受理中", value: 1 },
+    { name: "处理完成", value: 2 },
+  ],
+  tabsCurrent: 1,
+
+  dataList: [],
+  pageSize: 20,
+  current: 1,
+  total: 0,
+});
 
-const dataList = ref([]);
-const pageSize = ref(20);
-const current = ref(1);
-const total = ref(0);
+const { tabsList, tabsCurrent, dataList, pageSize, current, total } = toRefs(state);
 
 /**
  * @页面初始化
@@ -75,13 +84,13 @@ function init() {
  */
 function selectListApi() {
   page({
-    repairStatus: tabsList.value[tabsCurrent.value].value,
-    current: current.value,
-    size: pageSize.value,
+    repairStatus: state.tabsList[state.tabsCurrent].value,
+    current: state.current,
+    size: state.pageSize,
   }).then((requset) => {
     if (requset.status === "SUCCESS") {
-      dataList.value = requset.data.records;
-      total.value = requset.data.total;
+      state.dataList = requset.data.records;
+      state.total = requset.data.total;
     }
   });
 }
@@ -97,7 +106,7 @@ function handleToDetails(e) {
  * @scrollView加载数据
  */
 function load() {
-  pageSize.value += 10;
+  state.pageSize += 10;
   init();
 }
 
@@ -105,7 +114,7 @@ function load() {
  * @scrollView刷新数据
  */
 function refresh() {
-  pageSize.value = 20;
+  state.pageSize = 20;
   init();
 }
 
@@ -113,7 +122,7 @@ function refresh() {
  * @tabs点击事件
  */
 function tabsClick(e) {
-  tabsCurrent.value = e.index;
+  state.tabsCurrent = e.index;
   init();
 }
 

+ 104 - 97
src/pages/business/mhxf/deviceManage/index.vue

@@ -1,109 +1,126 @@
 <template>
   <u-sticky class="shadow-default" bgColor="#fff" style="top: 0">
     <u-tabs
-      :list="list"
-      :current="current"
+      :list="tabsList"
+      :current="tabsCurrent"
       @click="tabsClick"
-      :scrollable="list.length >= 5 ? true : false"
+      :scrollable="tabsList.length >= 5 ? true : false"
       lineColor="#333"
       :activeStyle="{ color: '#333' }"
       :inactiveStyle="{ color: '#909399' }"
     ></u-tabs>
   </u-sticky>
 
-  <scroll-view class="scroll-height" :scroll-y="true" :data-theme="'theme-' + proxy.$settingStore.themeColor.name" style="padding-bottom: 44px">
-    <oa-touch class="deviceManage" @change="touchChange">
-      <template #content>
-        <uni-swipe-action>
-          <uni-swipe-action-item class="bg-white">
-            <view class="content">
-              <view class="block p10">
-                <u-input v-model="dataInput" placeholder="请输入设备编号" @blur="blur" shape="circle" prefixIcon="search" prefixIconStyle="color: #0c7bf9"> </u-input>
-              </view>
-
-              <u-empty v-if="dataList.length <= 0" text="暂无数据" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png"> </u-empty>
-
-              <u-collapse @change="change" @close="close" @open="open" accordion v-else>
-                <u-collapse-item class="uCollapseItem" v-for="da in dataList" :key="da">
-                  <template #title>
-                    <view class="flex">
-                      <view class="cu-avatar lg" style="margin: 0 10px auto 0; background-color: rgba(0, 0, 0, 0)">
-                        <image class="image-bg" style="width: 80rpx; height: 80rpx" src="@/static/images/deviceManage/1.png"></image>
-                      </view>
-                      <view style="width: 100%">
-                        <view class="flex" style="color: #000000">
-                          <view>设备编号:{{ da.deviceCode }}</view>
-                          <view class="deviceStatus" v-if="da.deviceStatus == 0" style="background-color: #aeaeae"> 离线 </view>
-                          <view class="deviceStatus" v-else-if="da.deviceStatus == 1" style="background-color: #12c100"> 正常 </view>
-                          <view class="deviceStatus" v-else-if="da.deviceStatus == 2" style="background-color: #ff1313"> 故障 </view>
-                          <view class="deviceStatus" v-else style="background-color: #0d88f0"> 告警 </view>
-                        </view>
-                        <view style="display: flex; font-size: 14px; color: #666666; margin: 10px 0">
-                          <view style="width: 50%; word-break: break-all">监测对象:{{ da.installAddress }}</view>
-                          <view style="width: 50%; word-break: break-all; padding-left: 10px">所属单位:{{ da.companyName }}</view>
+  <oa-scroll
+    customClass="bg-white scroll-height"
+    :isSticky="true"
+    :refresherLoad="false"
+    :refresherLoadTitle="false"
+    :refresherEnabled="false"
+    :refresherEnabledTitle="false"
+    :refresherDefaultStyle="'none'"
+    :refresherThreshold="44"
+    :refresherBackground="'#f5f6f7'"
+    :data-theme="'theme-' + proxy.$settingStore.themeColor.name"
+  >
+    <template #default>
+      <oa-touch class="deviceManage" @change="touchChange">
+        <template #content>
+          <uni-swipe-action>
+            <uni-swipe-action-item class="bg-white">
+              <view class="content">
+                <view class="block p10">
+                  <u-input v-model="deviceCode" placeholder="请输入设备编号" @blur="blur" shape="circle" prefixIcon="search" prefixIconStyle="color: #0c7bf9"> </u-input>
+                </view>
+
+                <u-empty v-if="dataList.length <= 0" text="暂无数据" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png"> </u-empty>
+
+                <u-collapse @change="change" @close="close" @open="open" accordion v-else>
+                  <u-collapse-item class="uCollapseItem" v-for="da in dataList" :key="da">
+                    <template #title>
+                      <view class="flex">
+                        <view class="cu-avatar lg" style="margin: 0 10px auto 0; background-color: rgba(0, 0, 0, 0)">
+                          <image class="image-bg" style="width: 80rpx; height: 80rpx" src="@/static/images/deviceManage/1.png"></image>
                         </view>
-                        <view style="display: flex; font-size: 14px; color: #666666">
-                          <view style="width: 50%; word-break: break-all">负责人:{{ da.linkPerson }}</view>
-                          <view style="width: 50%; word-break: break-all; padding-left: 10px">联系电话:{{ da.linkPhone }}</view>
+                        <view style="width: 100%">
+                          <view class="flex" style="color: #000000">
+                            <view>设备编号:{{ da.deviceCode }}</view>
+                            <view class="deviceStatus" v-if="da.deviceStatus == 0" style="background-color: #aeaeae"> 离线 </view>
+                            <view class="deviceStatus" v-else-if="da.deviceStatus == 1" style="background-color: #12c100"> 正常 </view>
+                            <view class="deviceStatus" v-else-if="da.deviceStatus == 2" style="background-color: #ff1313"> 故障 </view>
+                            <view class="deviceStatus" v-else style="background-color: #0d88f0"> 告警 </view>
+                          </view>
+                          <view style="display: flex; font-size: 14px; color: #666666; margin: 10px 0">
+                            <view style="width: 50%; word-break: break-all">监测对象:{{ da.installAddress }}</view>
+                            <view style="width: 50%; word-break: break-all; padding-left: 10px">所属单位:{{ da.companyName }}</view>
+                          </view>
+                          <view style="display: flex; font-size: 14px; color: #666666">
+                            <view style="width: 50%; word-break: break-all">负责人:{{ da.linkPerson }}</view>
+                            <view style="width: 50%; word-break: break-all; padding-left: 10px">联系电话:{{ da.linkPhone }}</view>
+                          </view>
                         </view>
                       </view>
-                    </view>
-                  </template>
+                    </template>
 
-                  <view class="u-collapse-content">
-                    <!-- <view style="display: flex; flex-wrap: wrap; margin-left: 5%">
+                    <view class="u-collapse-content">
+                      <!-- <view style="display: flex; flex-wrap: wrap; margin-left: 5%">
                     <view style="width: 50%; height: 30px; line-height: 30px" v-for="ch in da.dataList" :key="ch">
                       <span>{{ ch.label }}:</span>
                       <span :style="ch.value === '正常' ? 'color:#12C100' : 'color:#FF0101'">{{ ch.value }}</span>
                     </view>
                   </view> -->
-                    <view style="display: flex; flex-wrap: wrap; margin-left: 5%">
-                      <view style="width: 50%; height: 30px; line-height: 30px" v-for="ch in da.dataList" :key="ch">
-                        <span>{{ ch.portName }}:</span>
-                        <span>{{ ch.portData }}</span>
+                      <view style="display: flex; flex-wrap: wrap; margin-left: 5%">
+                        <view style="width: 50%; height: 30px; line-height: 30px" v-for="ch in da.dataList" :key="ch">
+                          <span>{{ ch.portName }}:</span>
+                          <span>{{ ch.portData }}</span>
+                        </view>
                       </view>
                     </view>
-                  </view>
-                </u-collapse-item>
-              </u-collapse>
-            </view>
-          </uni-swipe-action-item>
-        </uni-swipe-action>
-      </template>
-    </oa-touch>
-  </scroll-view>
+                  </u-collapse-item>
+                </u-collapse>
+              </view>
+            </uni-swipe-action-item>
+          </uni-swipe-action>
+        </template>
+      </oa-touch>
+    </template>
+  </oa-scroll>
 </template>
 
 <script setup>
+/*----------------------------------依赖引入-----------------------------------*/
 import { onReady, onLoad, onShow, onNavigationBarButtonTap } from "@dcloudio/uni-app";
 import { ref, onMounted, inject, shallowRef, reactive, watchEffect, getCurrentInstance, toRefs } from "vue";
-import { useStores, commonStores } from "@/store/modules/index";
-
+/*----------------------------------接口引入-----------------------------------*/
 import { dataRtList } from "@/api/business/mhxf/deviceManage";
-
-const commonStore = commonStores(); //全局公共Store
-
+/*----------------------------------组件引入-----------------------------------*/
+/*----------------------------------store引入-----------------------------------*/
+import { useStores, commonStores } from "@/store/modules/index";
+/*----------------------------------公共方法引入-----------------------------------*/
+/*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
+const commonStore = commonStores(); //全局公共Store
+/*----------------------------------变量声明-----------------------------------*/
+const state = reactive({
+  deviceCode: "",
+  systemTypeNo: 5,
+  dataList: [],
+  tabsCurrent: 0,
+  tabsList: [
+    { id: 5, name: "电气火灾" },
+    { id: 4, name: "烟感" },
+    { id: 3, name: "水系统" },
+  ], //设备管理数据存储
+});
 
-const dataInput = ref("");
-
-const dataRes = ref(0);
-const systemTypeNo = ref(5);
-const dataList = ref([]); //设备管理数据存储
-
-const current = ref(0);
-const list = ref([
-  { id: 5, name: "电气火灾" },
-  { id: 4, name: "烟感" },
-  { id: 3, name: "水系统" },
-]);
+const { deviceCode, systemTypeNo, dataList, tabsCurrent, tabsList } = toRefs(state);
 
 /**
  * @tabs点击事件
  */
 function tabsClick(e) {
-  current.value = e.index;
-  dataInput.value = "";
+  state.tabsCurrent = e.index;
+  state.deviceCode = "";
 }
 
 /**
@@ -111,50 +128,42 @@ function tabsClick(e) {
  */
 function touchChange(e) {
   if (e == "右滑") {
-    if (current.value >= 1) {
-      current.value--;
+    if (state.tabsCurrent >= 1) {
+      state.tabsCurrent--;
     } else {
-      current.value = list.value.length - 1;
+      state.tabsCurrent = state.tabsList.length - 1;
     }
   } else if (e == "左滑") {
-    if (current.value < list.value.length - 1) {
-      current.value++;
+    if (state.tabsCurrent < state.tabsList.length - 1) {
+      state.tabsCurrent++;
     } else {
-      current.value = 0;
+      state.tabsCurrent = 0;
     }
   }
 }
 
 function blur(e) {
-  if (dataInput.value) {
-    classifySearch({ systemType: 5, deviceCode: dataInput.value });
+  if (state.deviceCode) {
+    classifySearch({ systemType: 5, deviceCode: state.deviceCode });
   }
 }
 
 //分类信息查询 start
 function classifySearch(params) {
-  // classifyData.value = []
-
   dataRtList(params).then((res) => {
-    console.log("------");
-    console.log(res.data.records);
-
-    dataList.value = res.data.records;
+    state.dataList = res.data.records;
   });
 }
 // end
 function goSearch() {
-  if (current.value == 0) {
-    console.log(current.value);
+  if (state.tabsCurrent == 0) {
     systemTypeNo.value = 5;
-  } else if (current.value == 1) {
+  } else if (state.tabsCurrent == 1) {
     systemTypeNo.value = 1;
-    console.log(current.value);
-  } else if (current.value == 2) {
+  } else if (state.tabsCurrent == 2) {
     systemTypeNo.value = 2;
-    console.log(current.value);
   }
-  classifySearch({ systemType: systemTypeNo.value, deviceCode: dataInput.value, pageNum: "", pageSize: "" });
+  classifySearch({ systemType: systemTypeNo.value, deviceCode: state.deviceCode, pageNum: "", pageSize: "" });
 }
 
 watchEffect(() => {
@@ -174,15 +183,13 @@ function change(e) {
 // 自定义导航事件
 onNavigationBarButtonTap((e) => {
   if (e.float == "right") {
-    uni.navigateTo({
-      url: "/pages/business/zhaf/xunJian/collect/components/collectRecord",
-    });
+    proxy.$tab.navigateTo("/pages/business/zhaf/xunJian/collect/components/collectRecord");
   } else {
   }
 });
 
 onLoad((options) => {
-  // classifySearch({systemType:5,deviceCode:dataInput.value})
+  // classifySearch({systemType:5,deviceCode:state.deviceCode})
 });
 
 onShow(() => {

+ 29 - 26
src/pages/business/mhxf/unitInfoCollection/index.vue

@@ -1,6 +1,15 @@
 <template>
-  <scroll-view class="scroll-height" :scroll-y="true" :data-theme="'theme-' + proxy.$settingStore.themeColor.name">
-    <view id="unitInfoCollection">
+  <oa-scroll
+    customClass="unitInfoCollection-container scroll-height"
+    :refresherLoad="false"
+    :refresherEnabled="false"
+    :refresherEnabledTitle="false"
+    :refresherDefaultStyle="'none'"
+    :refresherThreshold="44"
+    :refresherBackground="'#f5f6f7'"
+    :data-theme="'theme-' + proxy.$settingStore.themeColor.name"
+  >
+    <template #default>
       <view>
         <u-notice-bar text="注:信息提交后不可修改,提交前请核对填写是否有误" :duration="7000" color="#FF0000" bgColor="#FFFFFF"></u-notice-bar>
       </view>
@@ -300,23 +309,25 @@
           <view style="text-align: center; font-size: 13px; color: #ff0000">注:“修改”则点击修改,“新增”将提交一条新的记录,如需“取消”操作可点击空白区域</view>
         </view>
       </u-modal>
-    </view>
-  </scroll-view>
+    </template>
+  </oa-scroll>
 </template>
 
 <script setup>
+/*----------------------------------依赖引入-----------------------------------*/
 import { onLoad, onShow, onHide, onLaunch, onReady } from "@dcloudio/uni-app";
 import { ref, onMounted, inject, shallowRef, reactive, toRefs, getCurrentInstance } from "vue";
+/*----------------------------------接口引入-----------------------------------*/
+import { companyByNameSelect, addBaseCompany, delBaseBuild, delBaseBuildExtinguish } from "@/api/business/mhxf/unitInfoCollection";
+/*----------------------------------组件引入-----------------------------------*/
+/*----------------------------------store引入-----------------------------------*/
 import { useStores, commonStores } from "@/store/modules/index";
+/*----------------------------------公共方法引入-----------------------------------*/
 import { getToken } from "@/utils/auth";
-
-import { companyByNameSelect, addBaseCompany, delBaseBuild, delBaseBuildExtinguish } from "@/api/business/mhxf/unitInfoCollection";
-
+/*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
-
 const commonStore = commonStores();
-
-const checkboxValue = ref([]);
+/*----------------------------------变量声明-----------------------------------*/
 
 //基本信息-单位使用性质下拉数据存储
 const companyNatureList = ref([
@@ -551,8 +562,6 @@ const {
   modalShow,
 } = toRefs(dataList);
 
-const uForm = ref(null);
-const uForm1 = ref(null);
 const newCompanyName = ref("");
 const scanBool = ref(false);
 
@@ -591,14 +600,14 @@ function handleSubmit(value) {
   if (value === "上一步") {
     pagingBool.value = true;
   } else if (value === "下一步") {
-    uForm.value
+    proxy.$refs["uForm"]
       .validate()
       .then((res) => {
-        uni.$u.toast("校验通过");
+        proxy.$modal.msg("校验通过");
         pagingBool.value = false;
       })
       .catch((errors) => {
-        uni.$u.toast("校验失败");
+        proxy.$modal.msg("校验失败");
       });
   } else if (value === "提交") {
     if (newCompanyName.value == "") {
@@ -615,10 +624,10 @@ function handleSubmit(value) {
 function handleSubmitApi(value) {
   let param = {};
 
-  uForm1.value
+  proxy.$refs["uForm1"]
     .validate()
     .then((res) => {
-      uni.$u.toast("校验通过");
+      proxy.$modal.msg("校验通过");
 
       param = {
         baseCompany: {
@@ -713,9 +722,7 @@ function handleSubmitApi(value) {
           if (scanBool.value) {
             proxy.$tab.reLaunch(`/pages/common/success/index?codeName=提交成功&showNow=${false}`);
           } else {
-            uni.showToast({
-              title: "提交成功",
-            });
+            proxy.$modal.msg("提交成功");
             setTimeout(() => {
               proxy.$tab.reLaunch("/pages/index");
             }, 2000);
@@ -724,7 +731,7 @@ function handleSubmitApi(value) {
       });
     })
     .catch((errors) => {
-      uni.$u.toast("校验失败");
+      proxy.$modal.msg("校验失败");
     });
 }
 
@@ -774,15 +781,12 @@ function handleAction(value, index, ind) {
 
   if (value == "单位使用性质") {
     actionTitle.value = "单位使用性质";
-
     actionsList.value = companyNatureList.value;
-
     actionDefaultIndex.value = 0;
   }
 
   if (value == "产证") {
     actionTitle.value = "产证";
-
     actionsList.value = [
       [
         { value: 1, name: "商业服务业设施用地(商业设施、商务设施、娱乐康体设施、公用设施营业网点、其它服务设施等)" },
@@ -795,7 +799,6 @@ function handleAction(value, index, ind) {
         { value: 8, name: "绿地与广场用地" },
       ],
     ];
-
     actionDefaultIndex.value = 0;
   }
 
@@ -1038,7 +1041,7 @@ onShow(() => {
 </script>
 
 <style lang="scss">
-#unitInfoCollection {
+.unitInfoCollection-container {
   .centerOne,
   .centerTwo {
     .title {

+ 3 - 6
src/pages/business/zhaf/xunJian/collect/components/collectDetail.vue

@@ -11,7 +11,7 @@
   >
     <template #default>
       <view class="bg-white p15">
-        <u-form ref="form" labelPosition="left" :model="model" :rules="rules" labelWidth="82">
+        <u-form ref="uForm" labelPosition="left" :model="model" :rules="rules" labelWidth="82">
           <u-form-item label="地点号码:" prop="siteNubmber">
             <u-input v-model="model.siteNubmber" disabled></u-input>
           </u-form-item>
@@ -42,7 +42,6 @@ import { useStores, commonStores, xunJianStores } from "@/store/modules/index";
 const { proxy } = getCurrentInstance();
 const xunJianStore = xunJianStores(); //全局变量值Store
 /*----------------------------------变量声明-----------------------------------*/
-const form = ref(null); //表单refs获取
 const model = reactive({
   siteType: 1,
   siteTime: "",
@@ -66,16 +65,14 @@ const rules = ref({
  * @保存按钮点击事件
  */
 function handleInsert() {
-  form.value
+  proxy.$refs["uForm"]
     .validate()
     .then((res) => {
       let endTime = new Date();
       model.siteTime = proxy.$common.formatterDate(endTime, "yyyy-MM-dd hh:mm:ss");
 
       xunJianStore.collectDataList.push(model);
-      uni.navigateBack({
-        delta: 1, //返回到需要执行方法的页面
-      });
+      proxy.$tab.navigateBack(1); //返回到需要执行方法的页面
     })
     .catch((errors) => {
       uni.$u.toast("校验失败");

+ 8 - 5
src/pages/business/zhaf/xunJian/collect/components/collectRecord.vue

@@ -50,12 +50,17 @@
 </template>
 
 <script setup>
+/*----------------------------------依赖引入-----------------------------------*/
 import { onReady, onLoad, onShow, onNavigationBarButtonTap } from "@dcloudio/uni-app";
 import { ref, onMounted, inject, shallowRef, reactive, getCurrentInstance, toRefs } from "vue";
+/*----------------------------------接口引入-----------------------------------*/
 import { siteList } from "@/api/business/zhaf/xunJian/collect.js";
-
+/*----------------------------------组件引入-----------------------------------*/
+/*----------------------------------store引入-----------------------------------*/
+/*----------------------------------公共方法引入-----------------------------------*/
+/*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
-
+/*----------------------------------变量声明-----------------------------------*/
 const show = ref(false);
 const dateTimeRange = ref("");
 const state = reactive({
@@ -117,9 +122,7 @@ function handleIconClick(type) {
 
 //返回
 function handleToBack() {
-  uni.navigateBack({
-    delta: 1, //返回到需要执行方法的页面
-  });
+  proxy.$tab.navigateBack(1); //返回到需要执行方法的页面
 }
 
 onLoad((options) => {

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

@@ -43,7 +43,7 @@
               </view>
 
               <view class="collect-area_center_time">
-                {{ cu.siteTime == "" || cu.siteTime == null ? "无" : cu.siteTime }}
+                {{ cu.siteTime }}
               </view>
             </view>
             <view style="margin: auto"></view>
@@ -77,14 +77,20 @@
 </template>
 
 <script setup>
+/*----------------------------------依赖引入-----------------------------------*/
 import { onReady, onLoad, onShow, onUnload, onNavigationBarButtonTap } from "@dcloudio/uni-app";
 import { ref, onMounted, reactive, computed, getCurrentInstance, toRefs, inject, shallowRef, watch } from "vue";
-import { xunJianStores } from "@/store/modules/index";
+/*----------------------------------接口引入-----------------------------------*/
 import { addSite } from "@/api/business/zhaf/xunJian/collect.js";
+/*----------------------------------组件引入-----------------------------------*/
 import oaMovable from "@/components/oa-movable/index.vue"; // 引入组件
-
+/*----------------------------------store引入-----------------------------------*/
+import { xunJianStores } from "@/store/modules/index";
+/*----------------------------------公共方法引入-----------------------------------*/
+/*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
 const xunJianStore = xunJianStores(); //全局变量值Store
+/*----------------------------------变量声明-----------------------------------*/
 
 /**
  * @NFC
@@ -103,20 +109,11 @@ function scanClick() {
   uni.scanCode({
     autoZoom: false,
     success: (e) => {
-      uni.showToast({
-        title: "扫码成功",
-        icon: "none",
-      });
-      uni.navigateTo({
-        url: `/pages/business/zhaf/xunJian/collect/components/collectDetail?siteNubmber=${e.result}&siteType=${1}`,
-      });
+      proxy.$modal.msg("扫码成功");
+      proxy.$tab.navigateTo(`/pages/business/zhaf/xunJian/collect/components/collectDetail?siteNubmber=${e.result}&siteType=${1}`);
     },
     fail: (err) => {
-      uni.showToast({
-        title: "扫码失败",
-        icon: "none",
-      });
-      console.log("扫码失败", err);
+      proxy.$modal.msg("扫码失败");
     },
     complete: () => {
       console.log("扫码结束");
@@ -148,10 +145,7 @@ function handleInsert(e) {
       api(res.longitude, res.latitude);
     },
     fail: function (res) {
-      uni.showToast({
-        title: "请打开手机定位或相关应用权限定位!",
-        icon: "none",
-      });
+      proxy.$modal.msg("请打开手机定位或相关应用权限定位!");
     },
   });
 
@@ -167,6 +161,7 @@ function handleInsert(e) {
       distanceRange: 10, //误差范围
       // areaId: 0, //区域id
       // companyId: 0, //单位ID
+      collectTime: e.siteTime ? e.siteTime.replace(" ", "T") : e.siteTime,
     })
       .then((res) => {
         if (res.status == "SUCCESS") {
@@ -216,17 +211,13 @@ function swipeChange(e, index) {
 //右侧按钮点击事件
 function handleIconClick(type) {
   if (type === "采集记录") {
-    uni.navigateTo({
-      url: "/pages/business/zhaf/xunJian/collect/components/collectRecord",
-    });
+    proxy.$tab.navigateTo("/pages/business/zhaf/xunJian/collect/components/collectRecord");
   }
 }
 
 //返回
 function handleToBack() {
-  uni.navigateBack({
-    delta: 1, //返回到需要执行方法的页面
-  });
+  proxy.$tab.navigateBack(1); //返回到需要执行方法的页面
 }
 
 onLoad((options) => {});
@@ -237,9 +228,7 @@ onShow(() => {
 
   uni.$on("tagid", function (value) {
     setTimeout(() => {
-      uni.navigateTo({
-        url: `/pages/business/zhaf/xunJian/collect/components/collectDetail?siteNubmber=${value}&siteType=${2}`,
-      });
+      proxy.$tab.navigateTo(`/pages/business/zhaf/xunJian/collect/components/collectDetail?siteNubmber=${value}&siteType=${2}`);
       uni.$off("tagid"); //将值删除监听器
     }, 0);
   });

+ 4 - 8
src/pages/business/zhaf/xunJian/error/errorDisposition.vue

@@ -12,7 +12,7 @@
     <template #default>
       <u--form ref="uForm" :model="form" :rules="rules" labelWidth="90">
         <view style="padding: 10px 10px 20px 20px; background: #ffffff">
-          <u-form-item label="事件名称" prop="eventName" required :borderBottom="true">
+          <u-form-item label="事件名称" prop="eventName" :borderBottom="true" required>
             <view style="color: #666666">{{ form.eventName }}</view>
           </u-form-item>
           <u-form-item label="处置图片" :borderBottom="true">
@@ -66,7 +66,7 @@ function handleSubmit() {
   }
 
   var param = {
-    eventName: state.form.id, //事件名称
+    eventName: state.form.eventName, //事件名称
     handleImage: JSON.stringify(state.form.imageList),
     handleContent: state.form.handleContent,
     id: state.form.id,
@@ -74,12 +74,8 @@ function handleSubmit() {
   errorApi()
     .Update(param)
     .then(() => {
-      uni.showToast({
-        title: "提交成功",
-      });
-      uni.navigateBack({
-        delta: 1, //返回到需要执行方法的页面
-      });
+      proxy.$modal.msg("提交成功");
+      proxy.$tab.navigateBack(2);
     })
     .catch((err) => {
       proxy.$modal.msg(err);

+ 2 - 3
src/pages/business/zhaf/xunJian/error/errorList.vue

@@ -79,9 +79,7 @@ function pageQueryApi() {
  * @复制粘贴板
  */
 function toDetail(row) {
-  uni.navigateTo({
-    url: "/pages/business/zhaf/xunJian/error/errorListDetail?id=" + row.id,
-  });
+  proxy.$tab.navigateTo(`/pages/business/zhaf/xunJian/error/errorListDetail?id=${row.id}`)
 }
 
 /**
@@ -117,6 +115,7 @@ onReady(() => {});
 onShow(() => {
   //调用系统主题颜色
   proxy.$settingStore.systemThemeColor([1]);
+  init();
 });
 
 // 自定义导航事件

+ 43 - 26
src/pages/business/zhaf/xunJian/error/errorListDetail.vue

@@ -21,10 +21,14 @@
         <view class="list-cell">
           <view class="menu-item">
             <view style="width: 90px">事件上传图片</view>
-            <view v-if="dataList.eventImage && dataList.eventImage !='[]'" @click="proxy.$common.imgEnlarge(2,JSON.parse(dataList.eventImage))">
-              <image style="width: 20px; height: 20px; margin: auto 15px auto 0"  v-for="(item,index) in JSON.parse(dataList.eventImage)" :key="index"
-                :src="item.url ? item.url : '/static/images/404.png'" mode="aspectFill"
-                ></image>
+            <view v-if="dataList.eventImage && dataList.eventImage != '[]'" @click="proxy.$common.imgEnlarge(2, JSON.parse(dataList.eventImage))">
+              <image
+                style="width: 20px; height: 20px; margin: auto 15px auto 0"
+                v-for="(item, index) in JSON.parse(dataList.eventImage)"
+                :key="index"
+                :src="item.url ? item.url : '/static/images/404.png'"
+                mode="aspectFill"
+              ></image>
             </view>
           </view>
         </view>
@@ -79,17 +83,21 @@
         <view class="list-cell">
           <view class="menu-item">
             <view style="width: 90px">处置状态</view>
-            <view :style="{color: dataList.handleStatus == 0 ? 'red' : '#666666'}">{{ dataList.handleStatus == 0 ? '未处置' : dataList.handleStatus == 1 ? '已处置' :  '' }}</view>
+            <view :style="{ color: dataList.handleStatus == 0 ? 'red' : '#666666' }">{{ dataList.handleStatus == 0 ? "未处置" : dataList.handleStatus == 1 ? "已处置" : "" }}</view>
           </view>
         </view>
         <view class="list-cell">
           <view class="menu-item">
             <view style="width: 90px">处置图片</view>
-              <view v-if="dataList.handleImage && dataList.handleImage !='[]'" @click="proxy.$common.imgEnlarge(2,JSON.parse(dataList.handleImage))">
-                <image style="width: 20px; height: 20px; margin: auto 15px auto 0"  v-for="(item,index) in JSON.parse(dataList.handleImage)" :key="index"
-                  :src="item.url ? item.url : '/static/images/404.png'" mode="aspectFill"
-                  ></image>
-              </view>
+            <view v-if="dataList.handleImage && dataList.handleImage != '[]'" @click="proxy.$common.imgEnlarge(2, JSON.parse(dataList.handleImage))">
+              <image
+                style="width: 20px; height: 20px; margin: auto 15px auto 0"
+                v-for="(item, index) in JSON.parse(dataList.handleImage)"
+                :key="index"
+                :src="item.url ? item.url : '/static/images/404.png'"
+                mode="aspectFill"
+              ></image>
+            </view>
           </view>
         </view>
         <view class="list-cell">
@@ -104,7 +112,7 @@
             <view style="color: #666666">{{ dataList.handleName }}</view>
           </view>
         </view>
-        <view class="list-cell" >
+        <view class="list-cell">
           <view class="menu-item">
             <view style="width: 90px">处置时间</view>
             <view style="color: #666666"> {{ dataList.handleTime ? dataList.handleTime.replace("T", " ") : "" }}</view>
@@ -121,34 +129,44 @@
   </oa-scroll>
 </template>
 <script setup>
+/*----------------------------------依赖引入-----------------------------------*/
 import { onLoad, onShow, onReady, onHide, onLaunch, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
 import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
+/*----------------------------------接口引入-----------------------------------*/
 import { errorApi } from "@/api/business/zhaf/xunJian";
+/*----------------------------------组件引入-----------------------------------*/
+/*----------------------------------store引入-----------------------------------*/
+/*----------------------------------公共方法引入-----------------------------------*/
+/*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
 const { patrol_event_classify, patrol_event_grade, patrol_event_type } = proxy.useDict("patrol_event_classify", "patrol_event_grade", "patrol_event_type");
-const data = reactive({
+/*----------------------------------变量声明-----------------------------------*/
+const state = reactive({
   dataList: {},
-  id:undefined,
+  id: undefined,
   scrollIntoView: "",
 });
 
-const { dataList, id, scrollIntoView } = toRefs(data);
+const { dataList, id, scrollIntoView } = toRefs(state);
+
 function pageQueryApi() {
-  errorApi().Select({
-    pageNum: 1,
-    pageSize: 1,
-    id:id.value,
-  }).then((res) => {
+  errorApi()
+    .Select({
+      pageNum: 1,
+      pageSize: 1,
+      id: id.value,
+    })
+    .then((res) => {
       dataList.value = res.data.records[0];
-  });
+    });
 }
-function handleSubmit(row){ 
-  uni.navigateTo({
-    url: "/pages/business/zhaf/xunJian/error/errorDisposition?id=" + row.id + "&eventName=" + row.eventName,
-  });
+
+function handleSubmit(row) {
+  proxy.$tab.navigateTo(`/pages/business/zhaf/xunJian/error/errorDisposition?id=${row.id}&eventName=${row.eventName}`);
 }
+
 onLoad((options) => {
-  id.value = options.id
+  id.value = options.id;
   pageQueryApi();
 });
 
@@ -171,4 +189,3 @@ onNavigationBarButtonTap((e) => {
   opacity: 1 !important;
 }
 </style>
-  

+ 2 - 8
src/pages/business/zhaf/xunJian/error/index.vue

@@ -121,8 +121,6 @@ function handleSubmit(value) {
   proxy.$refs["uForm"]
     .validate()
     .then((res) => {
-      proxy.$modal.msg("校验通过");
-
       var param = {
         eventName: state.form.eventName, //事件名称
         eventType: state.form.eventType, //事件类型
@@ -137,12 +135,8 @@ function handleSubmit(value) {
       errorApi()
         .Insert(param)
         .then(() => {
-          uni.showToast({
-            title: "提交成功",
-          });
-          uni.navigateBack({
-            delta: 1, //返回到需要执行方法的页面
-          });
+          proxy.$modal.msg("提交成功");
+          proxy.$tab.navigateBack(1);
         })
         .catch((err) => {
           proxy.$modal.msg(err);

+ 2 - 6
src/pages/business/zhaf/xunJian/plan/components/content.vue

@@ -126,9 +126,7 @@ function confirm() {
   audioUrl.value = "/static/mp3/XJWC.mp3";
   show.value = false;
   uni.$emit("planSelect"); //执行页面中的自定义方法
-  uni.navigateBack({
-    delta: 3, //返回到需要执行方法的页面
-  });
+  proxy.$tab.navigateBack(3); //返回到需要执行方法的页面
 }
 
 /**
@@ -139,9 +137,7 @@ function confirm() {
 async function buttonClick(type) {
   if (type == 1) {
     //上一步
-    uni.navigateBack({
-      delta: 1,
-    });
+    proxy.$tab.navigateBack(1); //返回到需要执行方法的页面
   } else if (type == 2) {
     //提交
 

+ 1 - 4
src/pages/common/searchSelect/index.vue

@@ -44,10 +44,7 @@ function handleToSearch() {
 
 //取消
 function handleToCancel() {
-  console.log(1);
-  uni.navigateBack({
-    delta: 1, //返回到需要执行方法的页面
-  });
+  proxy.$tab.navigateBack(1); //返回到需要执行方法的页面
 }
 
 onShow(() => {});

+ 1 - 0
src/pages/index.vue

@@ -124,6 +124,7 @@ function init() {
 
   //#ifdef APP-PLUS
   proxy.$settingStore.baseAppInfo(), setInterval(proxy.$settingStore.baseAppInfo, 1000 * 60 * 5); //动态获取用户设备信息
+  proxy.$settingStore.openWebSocket(); //开启WebSocket
   //#endif
 }
 

+ 140 - 128
src/pages/mine.vue

@@ -1,166 +1,178 @@
 <template>
-  <view class="mine-container" :data-theme="'theme-' + proxy.$settingStore.themeColor.name">
-    <!--顶部个人信息栏-->
-    <view class="top-area" :class="'bg-' + themeColor.name" :style="{ paddingTop: proxy.$settingStore.StatusBar ? proxy.$settingStore.StatusBar + 20 + 'px' : '55px' }">
-      <view class="flex justify-between p15">
-        <view class="flex align-center">
-          <view class="cu-avatar xl round border bg-white" v-if="!avatar" @click="!state.nickName ? proxy.$settingStore.handleToLogin() : proxy.$settingStore.handleToAvatar(1)">
-            <view class="iconfont oaIcon-people text-gray"></view>
-          </view>
-          <image class="cu-avatar xl round border bg-white" v-if="avatar" :src="avatar" @click="proxy.$settingStore.handleToAvatar(2)"> </image>
-          <view class="login-tip" v-if="!state.nickName" @click="proxy.$settingStore.handleToLogin()"> 点击登录 </view>
-          <view class="user-info" v-if="state.nickName">
-            <view class="u_title"> {{ state.nickName }} </view>
-            <view class="u_title"> {{ state.phone ? state.phone.substr(0, 3) + "******" + state.phone.substr(9) : "" }} </view>
+  <oa-scroll
+    customClass="mine-container scroll-height"
+    :customStyle="{ height: `calc(100vh - (50px + ${proxy.$settingStore.tabBarHeight}))`, position: 'relative' }"
+    :isSticky="false"
+    :refresherLoad="false"
+    :refresherEnabled="false"
+    :refresherEnabledTitle="false"
+    :refresherDefaultStyle="'none'"
+    :refresherThreshold="44"
+    :refresherBackground="'#f5f6f7'"
+  >
+    <template #default>
+      <!--顶部个人信息栏-->
+      <view class="top-area" :class="'bg-' + themeColor.name" :style="{ paddingTop: proxy.$settingStore.StatusBar ? proxy.$settingStore.StatusBar + 20 + 'px' : '55px' }">
+        <view class="flex justify-between p15">
+          <view class="flex align-center">
+            <view class="cu-avatar xl round border bg-white" v-if="!avatar" @click="!state.nickName ? proxy.$settingStore.handleToLogin() : proxy.$settingStore.handleToAvatar(1)">
+              <view class="iconfont oaIcon-people text-gray"></view>
+            </view>
+            <image class="cu-avatar xl round border bg-white" v-if="avatar" :src="avatar" @click="proxy.$settingStore.handleToAvatar(2)"> </image>
+            <view class="login-tip" v-if="!state.nickName" @click="proxy.$settingStore.handleToLogin()"> 点击登录 </view>
+            <view class="user-info" v-if="state.nickName">
+              <view class="u_title"> {{ state.nickName }} </view>
+              <view class="u_title"> {{ state.phone ? state.phone.substr(0, 3) + "******" + state.phone.substr(9) : "" }} </view>
+            </view>
           </view>
+          <view class="flex align-center"> </view>
         </view>
-        <view class="flex align-center"> </view>
-      </view>
 
-      <view class="vip-card-box"> </view>
-    </view>
+        <view class="vip-card-box"> </view>
+      </view>
 
-    <oa-transForm>
-      <template #content>
-        <view class="menu-list">
-          <view class="list-cell list-cell-arrow" @click="proxy.$settingStore.handleToEditInfo()">
-            <view class="menu-item">
-              <view class="iconfont oaIcon-user menu-item-icon"></view>
-              <view>我的信息</view>
+      <oa-transForm>
+        <template #content>
+          <view class="menu-list">
+            <view class="list-cell list-cell-arrow" @click="proxy.$settingStore.handleToEditInfo()">
+              <view class="menu-item">
+                <view class="iconfont oaIcon-user menu-item-icon"></view>
+                <view>我的信息</view>
+              </view>
             </view>
-          </view>
-          <view class="list-cell list-cell-arrow" @click="proxy.$settingStore.handleToSecure()" v-if="proxy.$common.isVisible()">
-            <view class="menu-item">
-              <view class="iconfont oaIcon-yanzheng menu-item-icon"></view>
-              <view>账号与安全</view>
+            <view class="list-cell list-cell-arrow" @click="proxy.$settingStore.handleToSecure()" v-if="proxy.$common.isVisible()">
+              <view class="menu-item">
+                <view class="iconfont oaIcon-yanzheng menu-item-icon"></view>
+                <view>账号与安全</view>
+              </view>
             </view>
-          </view>
-          <view class="list-cell list-cell-arrow" @click="proxy.$settingStore.handleToMessage()">
-            <view class="menu-item">
-              <view class="iconfont oaIcon-tongzhi menu-item-icon"></view>
-              <view>新消息通知</view>
+            <view class="list-cell list-cell-arrow" @click="proxy.$settingStore.handleToMessage()">
+              <view class="menu-item">
+                <view class="iconfont oaIcon-tongzhi menu-item-icon"></view>
+                <view>新消息通知</view>
+              </view>
             </view>
-          </view>
-          <view class="list-cell list-cell-arrow" @click="proxy.$settingStore.handleAbout()">
-            <view class="menu-item">
-              <view class="iconfont oaIcon-aixin menu-item-icon"></view>
-              <view>关于我们</view>
+            <view class="list-cell list-cell-arrow" @click="proxy.$settingStore.handleAbout()">
+              <view class="menu-item">
+                <view class="iconfont oaIcon-aixin menu-item-icon"></view>
+                <view>关于我们</view>
+              </view>
             </view>
-          </view>
-          <view class="list-cell list-cell-arrow" @click="proxy.$settingStore.handleHelp()">
-            <view class="menu-item">
-              <view class="iconfont oaIcon-Help menu-item-icon"></view>
-              <view>常见问题</view>
+            <view class="list-cell list-cell-arrow" @click="proxy.$settingStore.handleHelp()">
+              <view class="menu-item">
+                <view class="iconfont oaIcon-Help menu-item-icon"></view>
+                <view>常见问题</view>
+              </view>
             </view>
-          </view>
-          <view class="list-cell list-cell-arrow" @click="proxy.$settingStore.handleCleanTmp()">
-            <view class="menu-item">
-              <view class="iconfont oaIcon-qinglihuancun menu-item-icon"></view>
-              <view>清理缓存</view>
-              <view class="text-right">{{ proxy.$settingStore.currentSize }}</view>
+            <view class="list-cell list-cell-arrow" @click="proxy.$settingStore.handleCleanTmp()">
+              <view class="menu-item">
+                <view class="iconfont oaIcon-qinglihuancun menu-item-icon"></view>
+                <view>清理缓存</view>
+                <view class="text-right">{{ proxy.$settingStore.currentSize }}</view>
+              </view>
             </view>
-          </view>
-          <view class="list-cell list-cell-arrow" @click="handleToUpgrade" v-if="proxy.$common.isVisible()">
-            <view class="menu-item">
-              <view class="iconfont oaIcon-jianchagengxin menu-item-icon"></view>
-              <view>检查更新</view>
+            <view class="list-cell list-cell-arrow" @click="handleToUpgrade" v-if="proxy.$common.isVisible()">
+              <view class="menu-item">
+                <view class="iconfont oaIcon-jianchagengxin menu-item-icon"></view>
+                <view>检查更新</view>
+              </view>
             </view>
+            <!-- <view class="list-cell list-cell-arrow" @click="proxy.$settingStore.handleSetting()">
+              <view class="menu-item">
+                <view class="iconfont oaIcon-shezhi menu-item-icon"></view>
+                <view>设置</view>
+              </view>
+            </view> -->
           </view>
-          <!-- <view class="list-cell list-cell-arrow" @click="proxy.$settingStore.handleSetting()">
-            <view class="menu-item">
-              <view class="iconfont oaIcon-shezhi menu-item-icon"></view>
-              <view>设置</view>
-            </view>
-          </view> -->
-        </view>
 
-        <!-- <view class="menu-list">
-          <view class="list-cell list-cell-arrow" @click="goMessagePush()">
-            <view class="menu-item">
-              <view class="iconfont oaIcon-aixin menu-item-icon"></view>
-              <view>推送设置</view>
+          <!-- <view class="menu-list">
+            <view class="list-cell list-cell-arrow" @click="goMessagePush()">
+              <view class="menu-item">
+                <view class="iconfont oaIcon-aixin menu-item-icon"></view>
+                <view>推送设置</view>
+              </view>
             </view>
-          </view>
-          <view class="list-cell list-cell-arrow" @click="goBuilding()">
-            <view class="menu-item">
-              <view class="iconfont oaIcon-aixin menu-item-icon"></view>
-              <view>建筑管理</view>
+            <view class="list-cell list-cell-arrow" @click="goBuilding()">
+              <view class="menu-item">
+                <view class="iconfont oaIcon-aixin menu-item-icon"></view>
+                <view>建筑管理</view>
+              </view>
             </view>
-          </view>
-          <view class="list-cell list-cell-arrow" @click="goFunReport()">
-            <view class="menu-item">
-              <view class="iconfont oaIcon-aixin menu-item-icon"></view>
-              <view>功能报备</view>
+            <view class="list-cell list-cell-arrow" @click="goFunReport()">
+              <view class="menu-item">
+                <view class="iconfont oaIcon-aixin menu-item-icon"></view>
+                <view>功能报备</view>
+              </view>
             </view>
-          </view>
-        </view> -->
+          </view> -->
 
-        <view class="cu-list menu">
-          <view class="cu-item mt0">
-            <view class="content flex align-center">
-              <text class="iconfont oaIcon-colorlens" :class="'text-' + themeColor.name"></text>
-              <view class="padding solid radius shadow-blur ml10" :class="'bg-' + themeColor.name"></view>
-              <view class="title ml10">
-                主题色:<text :class="'text-' + themeColor.name">{{ themeColor.title }}</text>
+          <view class="cu-list menu">
+            <view class="cu-item mt0">
+              <view class="content flex align-center">
+                <text class="iconfont oaIcon-colorlens" :class="'text-' + themeColor.name"></text>
+                <view class="padding solid radius shadow-blur ml10" :class="'bg-' + themeColor.name"></view>
+                <view class="title ml10">
+                  主题色:<text :class="'text-' + themeColor.name">{{ themeColor.title }}</text>
+                </view>
+              </view>
+              <view class="action">
+                <button class="cu-btn round shadow" @click="colorModal = true" :class="'bg-' + themeColor.name">
+                  <text class="iconfont oaIcon-colorlens"></text>
+                  选择主题
+                </button>
               </view>
-            </view>
-            <view class="action">
-              <button class="cu-btn round shadow" @click="colorModal = true" :class="'bg-' + themeColor.name">
-                <text class="iconfont oaIcon-colorlens"></text>
-                选择主题
-              </button>
             </view>
           </view>
-        </view>
 
-        <view class="menu-list" @click="proxy.$settingStore.handleLogout">
-          <view class="list-cell">
-            <view class="menu-item">
-              <view class="button">退 出 登 录</view>
+          <view class="menu-list" @click="proxy.$settingStore.handleLogout">
+            <view class="list-cell">
+              <view class="menu-item">
+                <view class="button">退 出 登 录</view>
+              </view>
             </view>
           </view>
-        </view>
 
-        <!-- <view class="menu-list">
-          <view class="list-cell list-cell-arrow" @tap="goSiteManage" v-if="permissionLabel == 1">
-            <view class="menu-item">
-              <image class="menu-item-image" src="@/static/images/setting/setting-icon2.png" style="width: 15px; height: 15px"></image>
-              <view>站点管理</view>
+          <!-- <view class="menu-list">
+            <view class="list-cell list-cell-arrow" @tap="goSiteManage" v-if="permissionLabel == 1">
+              <view class="menu-item">
+                <image class="menu-item-image" src="@/static/images/setting/setting-icon2.png" style="width: 15px; height: 15px"></image>
+                <view>站点管理</view>
+              </view>
             </view>
-          </view>
-          <view class="list-cell list-cell-arrow" @tap="goAuthManage" v-if="permissionLabel == 1">
-            <view class="menu-item">
-              <image class="menu-item-image" src="@/static/images/setting/setting-icon4.png" style="width: 15px; height: 15px"></image>
-              <view>权限管理</view>
+            <view class="list-cell list-cell-arrow" @tap="goAuthManage" v-if="permissionLabel == 1">
+              <view class="menu-item">
+                <image class="menu-item-image" src="@/static/images/setting/setting-icon4.png" style="width: 15px; height: 15px"></image>
+                <view>权限管理</view>
+              </view>
             </view>
-          </view>
-        </view> -->
-      </template>
-    </oa-transForm>
+          </view> -->
+        </template>
+      </oa-transForm>
+    </template>
+  </oa-scroll>
 
-    <!-- 选择颜色模态框 -->
-    <view class="cu-modal" :class="{ show: colorModal }">
-      <view class="cu-dialog">
-        <view class="cu-bar justify-end solid-bottom">
-          <view class="content">选择颜色</view>
-          <view class="action" @tap="colorModal = false">
-            <u-icon name="close" size="14"></u-icon>
-            <text class="cuIcon-close text-red"></text>
-          </view>
+  <!-- 选择颜色模态框 -->
+  <view class="cu-modal" :class="{ show: colorModal }">
+    <view class="cu-dialog">
+      <view class="cu-bar justify-end solid-bottom">
+        <view class="content">选择颜色</view>
+        <view class="action" @tap="colorModal = false">
+          <u-icon name="close" size="14"></u-icon>
+          <text class="cuIcon-close text-red"></text>
         </view>
-        <view class="grid col-5 padding">
-          <view class="padding-xs" v-for="(item, index) in themeList" :key="index" @tap="SetColor(item)" :data-color="item.name">
-            <view class="padding-tb radius" :class="'bg-' + item.name">
-              {{ item.title }}
-            </view>
+      </view>
+      <view class="grid col-5 padding">
+        <view class="padding-xs" v-for="(item, index) in themeList" :key="index" @tap="SetColor(item)" :data-color="item.name">
+          <view class="padding-tb radius" :class="'bg-' + item.name">
+            {{ item.title }}
           </view>
         </view>
       </view>
     </view>
-
-    <oa-upgrade ref="oaUpgradeRef" :themesColor="proxy.$settingStore.themeColor.color" />
   </view>
 
+  <oa-upgrade ref="oaUpgradeRef" :themesColor="proxy.$settingStore.themeColor.color" />
+
   <oa-tabbar :tabbarValue="2"></oa-tabbar>
 </template>
 

+ 58 - 3
src/store/modules/setting.js

@@ -31,11 +31,13 @@ const settingStores = defineStore("storage-setting", {
             userName: null, //用户账号
             longitude: "", //经度
             latitude: "", //纬度
+            deviceStatus: 0,//设备状态
         },
 
         themeColor: storageSystem.get("themeColor"),//主题
         fingerprintUserList: storageSystem.get("fingerprintUserList"),//指纹登录用户数据
         nfcWaiting: "请将手机靠近NFC标签", //nfc读取页面-提示文字-数据存储
+        webSocket: null,//巡检webSocket
     }),
     actions: {
         /**
@@ -123,10 +125,12 @@ const settingStores = defineStore("storage-setting", {
                     _this.deviceList.longitude = res.longitude.toString();
                     _this.deviceList.latitude = res.latitude.toString();
                     baseAppInfoApi(_this.deviceList).then((res) => { })
-                    uni.setStorageSync("expirationTime", undefined);
+                    uni.setStorageSync("expirationTime", "");
                 },
                 fail: (res) => {
-                    uni.setStorageSync("expirationTime", Date.parse(new Date()) / 1000);
+                    if (res.errMsg.indexOf('获取定位权限失败') != -1) {
+                        uni.setStorageSync("expirationTime", Date.parse(new Date()) / 1000);
+                    }
                 },
             });
         },
@@ -181,7 +185,56 @@ const settingStores = defineStore("storage-setting", {
                 }
             });
         },
+        /**
+         * @初始化WebSocket
+         */
+        initWebSocket() {
+            var _this = this
+
+            const systemInfo = uni.getSystemInfoSync();
+            _this.webSocket = uni.connectSocket({
+                // url: `wss://gateway.usky.cn/wss${systemInfo.deviceId},${new Date().getTime()}`,
+                url: `ws://120.26.164.249:9891/webSocketPatrol/${systemInfo.deviceId},${new Date().getTime()}`,
+            });
+        },
+        /**
+         * @开启WebSocket
+         */
+        openWebSocket() {
+            var _this = this
+
+            if (uni.getStorageSync("serveUrl").indexOf("xf.usky.cn:13212") == -1) {
+                return false
+            }
 
+            _this.initWebSocket()
+
+            uni.onSocketOpen(function (res) {
+                console.log('WebSocket连接已打开!', res);
+            });
+
+            uni.onSocketMessage(function (res) {
+                console.log('收到服务器内容:' + res.data);
+                _this.baseAppInfo();
+            });
+
+            uni.onSocketClose(function (res) {
+                console.log('WebSocket 已关闭!', res);
+                _this.closeWebSocket();
+                _this.initWebSocket()
+            });
+
+            uni.onSocketError(function (res) {
+                console.log('WebSocket连接打开失败,请检查!');
+                _this.initWebSocket()
+            });
+        },
+        /**
+         * @关闭WebSocket
+         */
+        closeWebSocket() {
+            uni.closeSocket();
+        },
         /**
          * @点击登录
          */
@@ -193,13 +246,15 @@ const settingStores = defineStore("storage-setting", {
          * @点击头像
          */
         handleToAvatar(type) {
+            var _this = this
+
             if (type == 1) {
                 uni.chooseImage({
                     count: 1, //默认9
                     sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
                     sourceType: ["album", "camera"], //从相册选择、摄像头
                     success: function (res) {
-                        this.uploadApi(res);
+                        _this.uploadApi(res);
                     },
                 });
             } else if (type == 2) {

+ 105 - 0
src/utils/keyListen.js

@@ -0,0 +1,105 @@
+// 包路径
+// const package_Activity = 'android.app.Activity'; 
+// const package_Bundle = 'android.os.Bundle'; 
+// const package_MotionEvent = 'android.view.MotionEvent'; 
+// const package_KeyEvent = 'android.view.KeyEvent'; 
+
+
+const SYSTEM_REASON = "reason";
+//Home键
+const SYSTEM_HOME_KEY = "homekey";
+//最近使用的应用键
+const SYSTEM_RECENT_APPS = "recentapps";
+
+let receiver, Intent = false;
+export default {
+	startListen: function (needStopSystem = false) {//开始监听,初始化
+		//参数needStopSystem默认不阻止系统响应,如需阻止调用startListen(true)
+		/*特别提醒,全面屏手势Home和recent部分机型是监听不到的,自行测试,如遇卡死电脑控制台直接重新运行项目即可解决!*/
+		let that = this;
+		that.openListen();
+		let main = plus.android.runtimeMainActivity();
+		if (needStopSystem) {
+			main.startLockTask()//阻止系统home建和近期任务键
+			plus.key.addEventListener("backbutton", function () {
+				// main.stopLockTask()//按返回键恢复
+				// main.unregisterReceiver(receiver); //同时停止接收home和recent点击
+			});
+		} else {
+			plus.globalEvent.addEventListener('resume', function (e) {
+				that.openListen();//应用切换到前台时需要重新开启监听
+				main.startLockTask()//阻止系统home建和近期任务键
+			});
+			plus.key.addEventListener("backbutton", function () {
+				// main.unregisterReceiver(receiver); //同时停止监听home和recent
+			});
+		}
+	},
+	openListen: function () {//注册监听
+		let that = this;
+		try {
+			let main = plus.android.runtimeMainActivity();
+			Intent = plus.android.importClass('android.content.Intent');
+			let IntentFilter = plus.android.importClass('android.content.IntentFilter');
+			var filter = new IntentFilter();
+			filter.addAction(Intent.ACTION_SCREEN_ON);
+			filter.addAction(Intent.ACTION_SCREEN_OFF);
+			filter.addAction(Intent.ACTION_USER_PRESENT);
+			filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
+			filter.addAction(Intent.GLOBAL_ACTION_BACK);
+			receiver = plus.android.implements('io.dcloud.feature.internal.reflect.BroadcastReceiver', {
+				onReceive: function (context, intent) { //实现onReceiver回调函数  
+					let act = intent.getAction();
+					if (act == Intent.ACTION_SCREEN_ON) {
+						console.log('开屏')
+					} else if (act == Intent.ACTION_SCREEN_OFF) {
+						console.log('锁屏')
+					} else if (act == Intent.ACTION_USER_PRESENT) {
+						console.log('解锁')
+					} else if (act == Intent.ACTION_CLOSE_SYSTEM_DIALOGS) {
+						let systemReason = intent.getStringExtra(SYSTEM_REASON);
+						// console.log("关闭原因", systemReason);
+						if (systemReason != null) {
+							if (systemReason == SYSTEM_HOME_KEY) {
+								// System.out.println("按下HOME键");
+								console.log('按下HOME键')
+							} else if (systemReason == SYSTEM_RECENT_APPS) {
+								// System.out.println("按下多任务键");
+								console.log('按下多任务键')
+							}
+						}
+					} else if (act == Intent.GLOBAL_ACTION_BACK) {
+						console.log('返回')
+					}
+					// main.unregisterReceiver(receiver);
+					/*在这里取消会出现第二次监听无效,可根据不同业务要求
+					在不同时刻停止接收两个按键的广播,我的处理是在返回的时候停*/
+					// context.unregisterReceiver(receiver);
+				}
+			});
+			main.registerReceiver(receiver, filter); //注册监听  
+		} catch (e) {
+			console.error(e);
+			toast('初始化错误');
+		}
+	},
+	// 全屏函数
+	fullScreen() {
+		// Android全屏
+		if (uni.getSystemInfoSync().platform === "android") {
+			plus.android.invoke("setFullScreen", true);
+		}
+
+		// iOS全屏
+		if (uni.getSystemInfoSync().platform === "ios") {
+			// iOS无法通过API直接全屏,可以尝试隐藏所有导航栏
+			plus.navigator.hideSystemBar();
+		}
+	}
+}
+function toast(content) {
+	uni.showToast({
+		title: content,
+		icon: 'none'
+	})
+}

+ 84 - 3
src/utils/permission.js

@@ -5,7 +5,7 @@ import store from '@/store'
  * @param {Array} value 校验值
  * @returns {Boolean}
  */
-export function checkPermi(value) {
+function checkPermi(value) {
   if (value && value instanceof Array && value.length > 0) {
     const permissions = store.getters && store.getters.permissions
     const permissionDatas = value
@@ -30,7 +30,7 @@ export function checkPermi(value) {
  * @param {Array} value 校验值
  * @returns {Boolean}
  */
-export function checkRole(value) {
+function checkRole(value) {
   if (value && value instanceof Array && value.length > 0) {
     const roles = store.getters && store.getters.roles
     const permissionRoles = value
@@ -48,4 +48,85 @@ export function checkRole(value) {
     console.error(`need roles! Like checkRole="['admin','editor']"`)
     return false
   }
-}
+}
+
+/// null = 未请求,1 = 已允许,0 = 拒绝|受限, 2 = 系统未开启
+function requestIOS(permissionID) {
+  return new Promise((resolve, reject) => {
+    var result = 0;
+    var cllocationManger = plus.ios.import(permissionID);
+    var enable = cllocationManger.locationServicesEnabled();
+    var status = cllocationManger.authorizationStatus();
+    if (!enable) {
+      result = 2;
+    } else if (status === 0) {
+      result = null;
+    } else if (status === 3 || status === 4) {
+      result = 1;
+    } else {
+      result = 0;
+    }
+    plus.ios.deleteObject(cllocationManger);
+    resolve(result);
+  });
+}
+
+function requestAndroid(permissionID) {
+  return new Promise((resolve, reject) => {
+    var result = 0;
+    plus.android.requestPermissions([permissionID], (resultObj) => {
+      for (var i = 0; i < resultObj.granted.length; i++) {
+        var grantedPermission = resultObj.granted[i];
+        console.log('已获取的权限:');
+        result = 1
+      }
+      for (var i = 0; i < resultObj.deniedPresent.length; i++) {
+        var deniedPresentPermission = resultObj.deniedPresent[i];
+        console.log('拒绝本次申请的权限:');
+        result = 0
+      }
+      for (var i = 0; i < resultObj.deniedAlways.length; i++) {
+        var deniedAlwaysPermission = resultObj.deniedAlways[i];
+        console.log('永久拒绝申请的权限:');
+        result = -1
+      }
+      resolve(result);
+    });
+  });
+}
+
+function gotoAppSetting() {
+  if (isIOS()) {
+    var UIApplication = plus.ios.import("UIApplication");
+    var application2 = UIApplication.sharedApplication();
+    var NSURL2 = plus.ios.import("NSURL");
+    var setting2 = NSURL2.URLWithString("app-settings:");
+    application2.openURL(setting2);
+    plus.ios.deleteObject(setting2);
+    plus.ios.deleteObject(NSURL2);
+    plus.ios.deleteObject(application2);
+  } else {
+    var Intent = plus.android.importClass("android.content.Intent");
+    var Settings = plus.android.importClass("android.provider.Settings");
+    var Uri = plus.android.importClass("android.net.Uri");
+    var mainActivity = plus.android.runtimeMainActivity();
+    var intent = new Intent();
+    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
+    var uri = Uri.fromParts("package", mainActivity.getPackageName(), null);
+    intent.setData(uri);
+    mainActivity.startActivity(intent);
+  }
+}
+
+function isIOS() {
+  return uni.getSystemInfoSync().platform === 'ios' ? true : false
+}
+
+export {
+  isIOS,
+  checkPermi,
+  checkRole,
+  requestIOS,
+  requestAndroid,
+  gotoAppSetting
+}