Browse Source

添加公共存储SOTRE/代码优化/消息中心接口对决

fanghuisheng 11 months ago
parent
commit
4021131292

+ 18 - 0
src/api/mine/index.js

@@ -0,0 +1,18 @@
+
+import { request } from "@/utils/request";
+
+/**
+ * 消息通知配置接口集合
+ * @method WxLogin 微信登录
+ */
+export function msgApi() {
+    return {
+        Select(data) {
+            return request({
+                url: "/service-iot/mceSetting/mceSettingInfo",
+                method: "GET",
+                data: data,
+            });
+        },
+    };
+}

+ 22 - 0
src/api/mine/info.js

@@ -21,3 +21,25 @@ export function getKnowledgeBaseDetails(param) {
     data: param,
   });
 }
+
+/**
+ * @消息接收分类统计接口
+ */
+export function getMceReceiveStatic(param) {
+  return request({
+    url: "/service-iot/mceReceive/mceReceiveStatic",
+    method: "GET",
+    data: param,
+  });
+}
+
+/**
+ * @字典类型接口
+ */
+export function getDictList(param) {
+  return request({
+    url: "/system/dict/data/list",
+    method: "GET",
+    data: param,
+  });
+}

+ 2 - 2
src/config.js

@@ -1,11 +1,11 @@
 // 应用全局配置
 export default {
   //#ifdef APP-PLUS || MP-WEIXIN
-  baseUrl: "http://manager.usky.cn/prod-api",
+  baseUrl: "https://gateWay.usky.cn/prod-api",
   //#endif
 
   //#ifdef H5
-  baseUrl: import.meta.env.MODE === "production" ? `http://${window.location.host}/prod-api` : `http://172.16.120.165:13200/dev-api`,
+  baseUrl: import.meta.env.MODE === "production" ? `https://${window.location.host}/prod-api` : `http://172.16.120.165:13200/dev-api`,
   //#endif
 
   websiteUrl: "https://qhome.usky.cn",

+ 1 - 1
src/pages/business/mhxf/unitInfoCollection/index.vue

@@ -1194,7 +1194,7 @@ function handleDateTime(value, index, time) {
  * @确定按钮事件
  */
 function timeSubmit(data) {
-  let time = commonStore.formatterDateTime(data.value);
+  let time = proxy.$common.formatterDateTime(data.value);
   let timeData = time.split(" ")[0];
   if (timeTitle.value == "成立时间") {
     form.value.foundTime = timeData;

+ 2 - 5
src/pages/business/zhaf/signIn/index.vue

@@ -33,12 +33,9 @@
 <script setup>
 import { onLoad, onShow, onHide, onLaunch, onUnload } from "@dcloudio/uni-app";
 import { ref, reactive, computed, onMounted, getCurrentInstance, toRefs, inject } from "vue";
-import { useStores, commonStores } from "@/store/modules/index";
 import { add, getStatus } from "@/api/business/zhaf/signIn.js";
 
-const commonStore = commonStores();
 const { proxy } = getCurrentInstance();
-
 const themeColor = computed(() => {
   return proxy.$settingStore.themeColor;
 });
@@ -47,7 +44,7 @@ const state = reactive({
   address: "", //准确位置信息
   deviceCode: uni.getSystemInfoSync().deviceId, //设备编号
   signInType: 1, //签到类型(0:已签到 1:已签退)
-  operateDate: commonStore.formatterDateTime(new Date()), //操作时间
+  operateDate: proxy.$common.formatterDateTime(new Date()), //操作时间
   operateCode: 0, //操作类型
   longitude: "", //经度
   latitude: "", //纬度
@@ -113,7 +110,7 @@ onLoad(() => {
   }, 1000 * 10);
   //#endif
   inter.interOperateDate = setInterval(() => {
-    state.operateDate = commonStore.formatterDateTime(new Date());
+    state.operateDate = proxy.$common.formatterDateTime(new Date());
   }, 1000);
 });
 

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

@@ -23,9 +23,7 @@ import { onReady, onLoad, onShow } from "@dcloudio/uni-app";
 import { ref, onMounted, inject, shallowRef, reactive, getCurrentInstance, toRefs } from "vue";
 import { useStores, commonStores, xunJianStores } from "@/store/modules/index";
 
-const commonStore = commonStores(); //全局公共Store
 const xunJianStore = xunJianStores(); //全局变量值Store
-
 const { proxy } = getCurrentInstance();
 
 const form = ref(null); //表单refs获取
@@ -56,7 +54,7 @@ function handleInsert() {
     .validate()
     .then((res) => {
       let endTime = new Date();
-      model.siteTime = commonStore.formatterDate(endTime, "yyyy-MM-dd hh:mm:ss");
+      model.siteTime = proxy.$common.formatterDate(endTime, "yyyy-MM-dd hh:mm:ss");
 
       xunJianStore.collectDataList.push(model);
       uni.navigateBack({

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

@@ -112,9 +112,7 @@ import { recordList, recordOption, planList, patrolInspectionPlan, appPlanStatis
 import drawer from "./components/drawer.vue"; // 引入组件
 import oaMovable from "@/components/oa-movable/index.vue"; // 引入组件
 
-const commonStore = commonStores(); //全局公共Store
 const xunJianStore = xunJianStores(); //全局变量值Store
-
 const { proxy } = getCurrentInstance();
 
 const info = ref({
@@ -292,7 +290,7 @@ function activitiesApi() {
  * @统计
  * @api接口请求
  */
-const currentDate = ref(commonStore.getDate().year + "-" + commonStore.getDate().month + "-" + commonStore.getDate().dates); //统计时间数据存储
+const currentDate = ref(proxy.$common.getDate().year + "-" + proxy.$common.getDate().month + "-" + proxy.$common.getDate().dates); //统计时间数据存储
 const currentDatevalue = ref(new Date());
 const currentDateList = ref({}); //统计list数据存储
 function currentApi() {

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

@@ -40,7 +40,7 @@ const { proxy } = getCurrentInstance();
 
 const inspectList = proxy.$grid.xunJianList; //九宫格json数据
 
-const currentDate = commonStore.getDate().year + "-" + commonStore.getDate().month + "-" + commonStore.getDate().dates;
+const currentDate = proxy.$common.getDate().year + "-" + proxy.$common.getDate().month + "-" + proxy.$common.getDate().dates;
 const currentDateList = ref([]);
 
 function navItemClick(url, id) {

+ 35 - 42
src/pages/common/alarmMessage/index.vue

@@ -1,8 +1,8 @@
 <template>
   <oa-scroll
     customClass="alarmMessage-container scroll-height"
-    :pageSize="pageSize"
-    :total="total"
+    :pageSize="state.pageSize"
+    :total="state.total"
     :refresherLoad="true"
     :refresherEnabled="true"
     :refresherDefaultStyle="'none'"
@@ -13,6 +13,7 @@
     :data-theme="'theme-' + proxy.$settingStore.themeColor.name"
   >
     <template #default>
+      <u-loading-page :loading="state.loading" fontSize="16" style="z-index: 99"></u-loading-page>
       <view class="content-area">
         <view :id="ind == allInfoList.length - 1 ? 'bottomInfo' : ''" v-for="(el, ind) in allInfoList" :key="ind" v-show="allInfoList.length > 0" @click="goContentDetails(el)">
           <view class="content-area-time font12">{{ el.time }}</view>
@@ -25,7 +26,7 @@
             </view>
             <view class="content-area-center-cont">
               <span class="label">告警类型:</span>
-              {{ mapping("typeName", el.alarmType, alarmTypeData) }}
+              {{ proxy.$common.mapping("typeName", "typeCode", el.alarmType, alarmTypeData) }}
             </view>
             <view class="content-area-center-cont">
               <span class="label">告警时间:</span>
@@ -42,23 +43,21 @@
 <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 { infoList } from "@/api/common/message.js";
 import { baseAlarmList, getTypePage } from "@/api/business/fireIot/alarmManage.js";
 
-const useStore = useStores();
 const { proxy } = getCurrentInstance();
 
-const pageSize = ref(20);
-const current = ref(1);
-const total = ref(0);
-const data = reactive({
+const state = reactive({
+  loading: false,
+  pageSize: 20,
+  current: 1,
+  total: 0,
   allInfoList: [],
   alarmTypeData: [],
 });
 
-const { allInfoList, alarmTypeData } = toRefs(data);
+const { allInfoList, alarmTypeData } = toRefs(state);
 
 /**
  * @初始化
@@ -69,41 +68,35 @@ function init() {
     size: 1000,
   }).then((requset) => {
     if (requset.status === "SUCCESS") {
-      alarmTypeData.value = requset.data.records;
+      state.alarmTypeData = requset.data.records;
     }
   });
 
-  proxy.$modal.loading("加载中");
+  state.loading = true;
   baseAlarmList({
     productCode: "",
-    current: current.value,
-    size: pageSize.value,
-  }).then((requset) => {
-    if (requset.status === "SUCCESS") {
-      requset.data.records.forEach((el) => {
-        allInfoList.value.push({
-          sitePhoto: el.sitePhoto,
-          time: proxy.$common.jktTimes(el.alarmTime),
-          deviceId: el.deviceId,
-          deviceName: el.deviceName,
-          alarmType: el.alarmType,
-          alarmTime: el.alarmTime,
+    current: state.current,
+    size: state.pageSize,
+  })
+    .then((requset) => {
+      if (requset.status === "SUCCESS") {
+        requset.data.records.forEach((el) => {
+          state.allInfoList.push({
+            sitePhoto: el.sitePhoto,
+            time: proxy.$common.jktTimes(el.alarmTime),
+            deviceId: el.deviceId,
+            deviceName: el.deviceName,
+            alarmType: el.alarmType,
+            alarmTime: el.alarmTime,
+          });
         });
-      });
-      total.value = requset.data.total;
-
-      proxy.$modal.closeLoading();
-    }
-  });
-}
-
-/** 映射 */
-function mapping(type, val, data) {
-  for (let i = 0; i < data.length; i++) {
-    if (val == data[i].typeCode) {
-      return data[i][type];
-    }
-  }
+        state.total = requset.data.total;
+        state.loading = false;
+      }
+    })
+    .catch((err) => {
+      state.loading = false;
+    });
 }
 
 /**
@@ -117,7 +110,7 @@ function goContentDetails(e) {
  * @scrollView加载数据
  */
 function load() {
-  pageSize.value += 10;
+  state.pageSize += 10;
   init();
 }
 
@@ -125,7 +118,7 @@ function load() {
  * @scrollView刷新数据
  */
 function refresh() {
-  pageSize.value = 20;
+  state.pageSize = 20;
   init();
 }
 

+ 2 - 7
src/pages/common/invoicing/index.vue

@@ -167,16 +167,11 @@
 </template>
 
 <script setup>
-import config from "@/config";
-import storage from "@/utils/storage";
 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 { crmInvoiceInfo, page } from "@/api/common/invoicing.js";
 
 const { proxy } = getCurrentInstance();
-const commonStore = commonStores();
 
 const uForm = ref(null);
 const data = reactive({
@@ -238,8 +233,8 @@ function handleSubmit(value) {
         current: 1,
         size: 10,
         invoiceTitle: form.value.invoiceTitle,
-        startTime: commonStore.getYearLast(new Date()),
-        endTime: commonStore.formatterDateTime(new Date()),
+        startTime: proxy.$common.getYearLast(new Date()),
+        endTime: proxy.$common.formatterDateTime(new Date()),
       }).then((requset) => {
         if (requset.status === "SUCCESS") {
           proxy.$modal.closeLoading();

+ 25 - 5
src/pages/info.vue

@@ -42,13 +42,19 @@
 </template>
 
 <script setup>
+/*----------------------------------依赖引入-----------------------------------*/
 import { onLoad, onShow, onHide, onLaunch } from "@dcloudio/uni-app";
 import { ref, onMounted, inject, shallowRef, reactive, getCurrentInstance, toRefs } from "vue";
-
-//引用API
-import {} from "@/api/mine/info.js";
-
+/*----------------------------------接口引入-----------------------------------*/
+import { getMceReceiveStatic, getDictList } from "@/api/mine/info.js";
+/*----------------------------------组件引入-----------------------------------*/
+/*----------------------------------store引入-----------------------------------*/
+import { stystemStores } from "@/store/modules/index";
+/*----------------------------------公共方法引入-----------------------------------*/
+/*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
+const stystemStore = stystemStores();
+/*----------------------------------变量声明-----------------------------------*/
 
 const data = reactive({
   infoList: [
@@ -82,6 +88,18 @@ const data = reactive({
 
 const { infoList } = toRefs(data);
 
+function init() {
+  getMceReceiveStatic().then((res) => {
+    stystemStore.infoList.messageCountData = res.data;
+    getDictList({
+      dictType: "sys_message_type",
+    }).then((res1) => {
+      stystemStore.infoList.messageTypeData = res1.data.rows;
+      res.data.infoTypeStatic.forEach((e) => {});
+    });
+  });
+}
+
 function goAppMessage(path) {
   proxy.$tab.navigateTo(path);
 }
@@ -94,7 +112,9 @@ function handleIconClick(type) {
   }
 }
 
-onShow(() => {});
+onShow(() => {
+  init();
+});
 
 onLoad((options) => {
   uni.hideTabBar(); //隐藏自带tabbar

+ 22 - 12
src/pages/mine/msg/index.vue

@@ -4,32 +4,26 @@
       <view class="menu-list mt0 mlr0">
         <view class="list-cell">
           <view class="menu-item">
-            <view class="title" style="width: 100%">通知</view>
-            <u-switch v-model="state.switchValue" size="20"></u-switch>
-          </view>
-        </view>
-        <view class="list-cell">
-          <view class="menu-item">
-            <view class="title" style="width: 100%">公告</view>
-            <u-switch v-model="state.switchValue" size="20"></u-switch>
+            <view class="title" style="width: 100%">通知公告</view>
+            <u-switch v-model="state.switchList.noticeBulletin" size="20"></u-switch>
           </view>
         </view>
         <view class="list-cell">
           <view class="menu-item">
             <view class="title" style="width: 100%">设备告警</view>
-            <u-switch v-model="state.switchValue" size="20"></u-switch>
+            <u-switch v-model="state.switchList.deviceAlarm" size="20"></u-switch>
           </view>
         </view>
         <view class="list-cell">
           <view class="menu-item">
             <view class="title" style="width: 100%">巡检系统</view>
-            <u-switch v-model="state.switchValue" size="20"></u-switch>
+            <u-switch v-model="state.switchList.inspectionSystem" size="20"></u-switch>
           </view>
         </view>
         <view class="list-cell">
           <view class="menu-item">
             <view class="title" style="width: 100%">会议系统</view>
-            <u-switch v-model="state.switchValue" size="20"></u-switch>
+            <u-switch v-model="state.switchList.meetingNotice" size="20"></u-switch>
           </view>
         </view>
       </view>
@@ -42,12 +36,28 @@ import config from "@/config";
 import { onReady, onLoad, onShow, onNavigationBarButtonTap } from "@dcloudio/uni-app";
 import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
 import { useStores, commonStores } from "@/store/modules/index";
+import { msgApi } from "@/api/mine";
 
 const useStore = useStores();
 const { proxy } = getCurrentInstance();
 
 const state = reactive({
-  switchValue: true,
+  switchList: {},
+});
+
+/**
+ * @初始化
+ */
+function init() {
+  msgApi()
+    .Select()
+    .then((res) => {
+      state.switchList = res.data.appMode;
+    });
+}
+
+onLoad(() => {
+  init();
 });
 
 onShow(() => {

+ 0 - 1
src/pages/register.vue

@@ -65,7 +65,6 @@ const dataList = reactive({
   confirmPasswordBool: true,
 });
 
-const uForm = ref(null);
 const { nickName, phone, verify, newPassword, newPasswordBool, confirmPassword, confirmPasswordBool } = toRefs(dataList);
 
 /**

+ 111 - 1
src/plugins/common.plugins.js

@@ -24,6 +24,20 @@ export default {
     }
     return result;
   },
+  /**
+   * 数据映射
+   * @param reKey 需要返回的key
+   * @param isKey 需要比对的key
+   * @param value 对比值
+   * @param data 数据集
+   */
+  mapping(reKey, isKey, value, data) {
+    for (let i = 0; i < data.length; i++) {
+      if (value == data[i][isKey]) {
+        return data[i][reKey];
+      }
+    }
+  },
   /**
    * @一键拨号
    */
@@ -120,7 +134,6 @@ export default {
     const days = [startTime, endTime,]
     return days;
   },
-
   /**
    * @处理公共日期格式
    */
@@ -143,6 +156,103 @@ export default {
     }
     return fmt;
   },
+  /**
+   * @获取当前日期前一年的日期
+   */
+  getYearLast(dateStr) {
+    // 假设要获取的日期为dateStr,格式为"YYYY-MM-DD"
+    let date = new Date(dateStr);
+    let Y = date.getFullYear() - 1; // 获取前一年的年份
+    let M = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1; // 月
+    let D; // 日
+
+    var h = (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
+    var m = (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) + ":";
+    var s = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
+
+    // 判断原日期的月份是否为2月份
+    if (date.getMonth() === 1) { // 2月份
+      // 判断前一年是否为闰年
+      if (Y % 4 === 0 && Y % 100 !== 0 || Y % 400 === 0) { // 闰年
+        D = Math.min(date.getDate(), 29); // 新日期的日期最大为29
+      } else { // 平年
+        D = Math.min(date.getDate(), 28); // 新日期的日期最大为28
+      }
+    } else { // 非2月份
+      D = date.getDate(); // 新日期的日期为原日期的日期
+    }
+
+    let newDateStr = Y + "-" + M + "-" + (D < 10 ? "0" + D : D) + " " + h + m + s; // 格式化日期字符串
+
+    return newDateStr
+  },
+  /**
+   * @获取年月日时分秒
+   * @returns
+   */
+  formatterDateTime(time3) {
+    var date = new Date(time3);
+    var Y = date.getFullYear() + "-";
+    var M = (date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1) + "-";
+    var D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
+
+    var h = (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
+    var m = (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) + ":";
+    var s = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
+    var strDate = Y + M + D + h + m + s;
+
+    return strDate;
+  },
+  /**
+   * @统计两个日期之间的月份
+   */
+  getMonths(date1, date2) {
+    //用-分成数组
+    date1 = date1.split("-");
+    date2 = date2.split("-");
+    //获取年,月数
+    var year1 = parseInt(date1[0]),
+      month1 = parseInt(date1[1]),
+      year2 = parseInt(date2[0]),
+      month2 = parseInt(date2[1]),
+      //通过年,月差计算月份差
+      months = (year2 - year1) * 12 + (month2 - month1) + 1;
+    return months;
+  },
+  getDate() {
+    var date = new Date();
+    var year = date.getFullYear(); //  返回的是年份
+    var month = date.getMonth() + 1; //  返回的月份上个月的月份,记得+1才是当月
+    if (month < 10) {
+      month = "0" + month;
+    }
+    var dates = date.getDate(); //  返回的是几号
+    if (dates < 10) {
+      dates = "0" + dates;
+    }
+    var day = date.getDay(); //  周一返回的是1,周六是6,但是周日是0
+    var arr = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
+    return { year, month, dates, day, arr, };
+  },
+  /**
+   * @数组对象排序
+   * @return
+   * @param {数据} data
+   * @param {0 从小到大 1 从大到小} sort
+   */
+  sortEvent(data, sort) {
+    let arr = [];
+    // 将需要排序的 key, 进行排列
+    let sortKeys = Object.keys(JSON.parse(JSON.stringify(data))).sort((a, b) => {
+      return sort == 0 ? JSON.parse(JSON.stringify(data))[a].sort - JSON.parse(JSON.stringify(data))[b].sort : JSON.parse(JSON.stringify(data))[b].sort - JSON.parse(JSON.stringify(data))[a].sort;
+    });
+    // 循环排列好的 key, 重新组成一个新的数组
+    for (var sortIndex in sortKeys) {
+      arr.push(JSON.parse(JSON.stringify(data))[sortKeys[sortIndex]]);
+    }
+
+    return arr;
+  },
   /**
    * @数组对象去重
    * @methods data 需要去重的数据

+ 19 - 222
src/store/modules/common.js

@@ -36,95 +36,25 @@ const commonStore = defineStore("common", {
 
     mhjz: [
       { streetTown: "全区", id: 12, x: 121.4175597, y: 31.119248 },
-      {
-        streetTown: "江川路街道",
-        id: 1201,
-        x: 121.399126538181,
-        y: 31.0099719391863,
-      },
-      {
-        streetTown: "新虹街道",
-        id: 1217,
-        x: 121.319329296294,
-        y: 31.1983901916889,
-      },
-      {
-        streetTown: "古美路街道",
-        id: 1206,
-        x: 121.388451866936,
-        y: 31.1478233480159,
-      },
-      {
-        streetTown: "浦锦街道",
-        id: 1218,
-        x: 121.483929120352,
-        y: 31.089967318558,
-      },
-      {
-        streetTown: "浦江镇",
-        id: 1215,
-        x: 121.524058543447,
-        y: 31.0540039472667,
-      },
-      {
-        streetTown: "吴泾镇",
-        id: 1213,
-        x: 121.454076463728,
-        y: 31.04860402113,
-      },
-      {
-        streetTown: "马桥镇",
-        id: 1214,
-        x: 121.352680027718,
-        y: 31.0213512298508,
-      },
-      {
-        streetTown: "颛桥镇",
-        id: 1209,
-        x: 121.40607138504,
-        y: 31.0612972443508,
-      },
-      {
-        streetTown: "莘庄镇",
-        id: 1207,
-        x: 121.37064864047,
-        y: 31.1154549548722,
-      },
-      {
-        streetTown: "梅陇镇",
-        id: 1212,
-        x: 121.421346814491,
-        y: 31.1069718313722,
-      },
-      {
-        streetTown: "七宝镇",
-        id: 1208,
-        x: 121.350366186317,
-        y: 31.1553292680362,
-      },
-      {
-        streetTown: "虹桥镇",
-        id: 1211,
-        x: 121.37956256207,
-        y: 31.1806219953212,
-      },
-      {
-        streetTown: "华漕镇",
-        id: 1210,
-        x: 121.277541517147,
-        y: 31.2289121171624,
-      },
-      {
-        streetTown: "莘庄工业区",
-        id: 1216,
-        x: 121.376508452784,
-        y: 31.0678185611843,
-      },
+      { streetTown: "江川路街道", id: 1201, x: 121.399126538181, y: 31.0099719391863 },
+      { streetTown: "新虹街道", id: 1217, x: 121.319329296294, y: 31.1983901916889 },
+      { streetTown: "古美路街道", id: 1206, x: 121.388451866936, y: 31.1478233480159 },
+      { streetTown: "浦锦街道", id: 1218, x: 121.483929120352, y: 31.089967318558 },
+      { streetTown: "浦江镇", id: 1215, x: 121.524058543447, y: 31.0540039472667 },
+      { streetTown: "吴泾镇", id: 1213, x: 121.454076463728, y: 31.04860402113 },
+      { streetTown: "马桥镇", id: 1214, x: 121.352680027718, y: 31.0213512298508 },
+      { streetTown: "颛桥镇", id: 1209, x: 121.40607138504, y: 31.0612972443508 },
+      { streetTown: "莘庄镇", id: 1207, x: 121.37064864047, y: 31.1154549548722 },
+      { streetTown: "梅陇镇", id: 1212, x: 121.421346814491, y: 31.1069718313722 },
+      { streetTown: "七宝镇", id: 1208, x: 121.350366186317, y: 31.1553292680362 },
+      { streetTown: "虹桥镇", id: 1211, x: 121.37956256207, y: 31.1806219953212 },
+      { streetTown: "华漕镇", id: 1210, x: 121.277541517147, y: 31.2289121171624 },
+      { streetTown: "莘庄工业区", id: 1216, x: 121.376508452784, y: 31.0678185611843 },
     ],
 
-    deviceDetailsArray: {},//设备详情页面-数据存储
+    deviceDetailsArray: {}, //设备详情页面-数据存储
 
-    facilitiesGatherType: "",//设施采集类型-数据存储
+    facilitiesGatherType: "", //设施采集类型-数据存储
     facilitiesGatherArray: {
       department: "", //所属部门
       facilityType: "", //设施类型
@@ -147,122 +77,11 @@ const commonStore = defineStore("common", {
       extendData: [], //扩展属性
       recordPictureList: [],
       typeGuise: "", //点线面类型
-    },//设施采集页面-数据存储
+    }, //设施采集页面-数据存储
 
-    nfcWaiting: '请将手机靠近NFC标签',//nfc读取页面-提示文字-数据存储
+    nfcWaiting: "请将手机靠近NFC标签", //nfc读取页面-提示文字-数据存储
   }),
   actions: {
-    getDate() {
-      var date = new Date();
-      var year = date.getFullYear(); //  返回的是年份
-      var month = date.getMonth() + 1; //  返回的月份上个月的月份,记得+1才是当月
-      if (month < 10) {
-        month = "0" + month;
-      }
-      var dates = date.getDate(); //  返回的是几号
-      if (dates < 10) {
-        dates = "0" + dates;
-      }
-      var day = date.getDay(); //  周一返回的是1,周六是6,但是周日是0
-      var arr = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
-      return {
-        year,
-        month,
-        dates,
-        day,
-        arr,
-      };
-    },
-
-    /**
-     * @处理公共日期格式
-     */
-    formatterDate(date, fmt) {
-      let nowDate = {
-        yyyy: date.getFullYear(), // 年
-        MM: date.getMonth() + 1, // 月份
-        dd: date.getDate(), //日
-        hh: date.getHours(),
-        mm: date.getMinutes(),
-        ss: date.getSeconds(),
-      };
-      if (/(y+)/.test(fmt)) {
-        fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
-      }
-      for (var k in nowDate) {
-        if (new RegExp("(" + k + ")").test(fmt)) {
-          fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? nowDate[k] : ("00" + nowDate[k]).substr(("" + nowDate[k]).length));
-        }
-      }
-      return fmt;
-    },
-
-    /**
-     * @获取当前日期前一年的日期
-     */
-    getYearLast(dateStr) {
-      // 假设要获取的日期为dateStr,格式为"YYYY-MM-DD"
-      let date = new Date(dateStr);
-      let Y = date.getFullYear() - 1; // 获取前一年的年份
-      let M = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1; // 月
-      let D; // 日
-
-      var h = (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
-      var m = (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) + ":";
-      var s = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
-
-      // 判断原日期的月份是否为2月份
-      if (date.getMonth() === 1) { // 2月份
-        // 判断前一年是否为闰年
-        if (Y % 4 === 0 && Y % 100 !== 0 || Y % 400 === 0) { // 闰年
-          D = Math.min(date.getDate(), 29); // 新日期的日期最大为29
-        } else { // 平年
-          D = Math.min(date.getDate(), 28); // 新日期的日期最大为28
-        }
-      } else { // 非2月份
-        D = date.getDate(); // 新日期的日期为原日期的日期
-      }
-
-      let newDateStr = Y + "-" + M + "-" + (D < 10 ? "0" + D : D) + " " + h + m + s; // 格式化日期字符串
-
-      return newDateStr
-    },
-
-    /**
-     * @获取年月日时分秒
-     * @returns
-     */
-    formatterDateTime(time3) {
-      var date = new Date(time3);
-      var Y = date.getFullYear() + "-";
-      var M = (date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1) + "-";
-      var D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
-
-      var h = (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
-      var m = (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) + ":";
-      var s = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
-      var strDate = Y + M + D + h + m + s;
-
-      return strDate;
-    },
-
-    /**
-     * @统计两个日期之间的月份
-     */
-    getMonths(date1, date2) {
-      //用-分成数组
-      date1 = date1.split("-");
-      date2 = date2.split("-");
-      //获取年,月数
-      var year1 = parseInt(date1[0]),
-        month1 = parseInt(date1[1]),
-        year2 = parseInt(date2[0]),
-        month2 = parseInt(date2[1]),
-        //通过年,月差计算月份差
-        months = (year2 - year1) * 12 + (month2 - month1) + 1;
-      return months;
-    },
-
     /**
      * @计算当前坐标和G点坐标的偏差值
      * @returns
@@ -278,28 +97,6 @@ const commonStore = defineStore("common", {
       console.log(s);
       return s;
     },
-
-    /**
-     * @数组对象排序
-     * @return
-     * @param {数据} data
-     * @param {0 从小到大 1 从大到小} sort
-     */
-    sortEvent(data, sort) {
-      let arr = [];
-      // 将需要排序的 key, 进行排列
-      let sortKeys = Object.keys(JSON.parse(JSON.stringify(data))).sort((a, b) => {
-        return sort == 0 ? JSON.parse(JSON.stringify(data))[a].sort - JSON.parse(JSON.stringify(data))[b].sort : JSON.parse(JSON.stringify(data))[b].sort - JSON.parse(JSON.stringify(data))[a].sort;
-      });
-      // 循环排列好的 key, 重新组成一个新的数组
-      for (var sortIndex in sortKeys) {
-        arr.push(JSON.parse(JSON.stringify(data))[sortKeys[sortIndex]]);
-      }
-
-      return arr;
-    },
-
-
     /**
      * @公共添加服务器列表
      */
@@ -327,7 +124,7 @@ const commonStore = defineStore("common", {
 
         uni.setStorageSync("serveList", serveList);
       }
-    }
+    },
   },
 });
 

+ 2 - 0
src/store/modules/index.js

@@ -2,10 +2,12 @@ import useStores from "@/store/modules/user.js";
 import commonStores from "@/store/modules/common.js";
 import settingStores from "@/store/modules/setting.js";
 import xunJianStores from "@/store/modules/xunJian.js";
+import stystemStores from "@/store/modules/stystem.js";
 
 export {
     useStores,
     commonStores,
     settingStores,
     xunJianStores,
+    stystemStores,
 };

+ 66 - 0
src/store/modules/stystem.js

@@ -0,0 +1,66 @@
+// 组件引用
+import { defineStore } from "pinia";
+// 接口引用
+// 公共方法引用
+import storage from "@/utils/storage";
+import common from "@/plugins/common.plugins.js";
+
+
+const stystemStores = defineStore(`${storage.get("nickName") + storage.get("tenantId")}_storage-stystem`, {
+    state: () => ({
+        homeList: {
+            swiperBool: false,
+            swiperIndex: 0,
+            swiperTime: 5000,
+            swiperList: [],
+
+            cuIconList: [],
+            recentlyUsed: [],
+        },
+        infoList: {},
+    }),
+    unistorage: true,
+    actions: {
+        /**
+         * @九宫格页面跳转
+         */
+        navItemClick(item) {
+            if (item.path) {
+                item.sort = 0;
+
+                this.homeList.recentlyUsed.push(item);
+                this.homeList.recentlyUsed = common.uniq(this.homeList.recentlyUsed, "path");
+                this.homeList.recentlyUsed.filter((el) => {
+                    if (el.path === item.path) {
+                        el.meta.icon = item.meta.icon;
+                        el.sort++;
+                    }
+                });
+                this.homeList.recentlyUsed = common.sortEvent(this.homeList.recentlyUsed, 1);
+
+                if (item.path.indexOf("http") != -1) {
+                    uni.navigateTo({
+                        url: "/pages/common/webview/index?url=" + item.path,
+                    });
+                } else {
+                    uni.navigateTo({
+                        url: item.path,
+                    });
+                }
+            } else {
+                uni.showModal({
+                    title: "Tips",
+                    content: "此模块开发中~",
+                    showCancel: false,
+                    success: function (res) {
+                        if (res.confirm) {
+                        } else if (res.cancel) {
+                        }
+                    },
+                });
+            }
+        }
+    },
+});
+
+export default stystemStores;

+ 17 - 15
src/utils/request.js

@@ -98,15 +98,16 @@ const request = (config) => {
         verification(res, resolve, reject);//调用校验结果方法
       })
       .catch((error) => {
-        let { message } = error;
-        if (!message) return;
-        if (message === "Network Error") {
-          message = "后端接口连接异常";
-        } else if (message.includes("timeout")) {
-          message = "系统接口请求超时";
-        } else if (message.includes("Request failed with status code")) {
-          message = "系统接口" + message.substr(message.length - 3) + "异常";
+        let { errMsg } = error;
+        if (!errMsg) return;
+        if (errMsg === "Network Error") {
+          errMsg = "后端接口连接异常";
+        } else if (errMsg.includes("timeout")) {
+          errMsg = "系统接口请求超时";
+        } else if (errMsg.includes("Request failed with status code")) {
+          errMsg = "系统接口" + errMsg.substr(errMsg.length - 3) + "异常";
         }
+        modal.msg(errMsg);
         reject(error);
       });
   });
@@ -139,14 +140,15 @@ const uploads = (config) => {
         verification(res, resolve, reject);//调用校验结果方法
       },
       fail: (error) => {
-        let { message } = error;
-        if (message == "Network Error") {
-          message = "后端接口连接异常";
-        } else if (message.includes("timeout")) {
-          message = "系统接口请求超时";
-        } else if (message.includes("Request failed with status code")) {
-          message = "系统接口" + message.substr(message.length - 3) + "异常";
+        let { errMsg } = error;
+        if (errMsg == "Network Error") {
+          errMsg = "后端接口连接异常";
+        } else if (errMsg.includes("timeout")) {
+          errMsg = "系统接口请求超时";
+        } else if (errMsg.includes("Request failed with status code")) {
+          errMsg = "系统接口" + errMsg.substr(errMsg.length - 3) + "异常";
         }
+        modal.msg(errMsg);
         reject(error);
       },
     });