Explorar el Código

js文件修改

fanghuisheng hace 2 años
padre
commit
2df872eaac
Se han modificado 9 ficheros con 119 adiciones y 111 borrados
  1. 20 0
      src/pages.json
  2. 17 21
      src/permission.js
  3. 27 0
      src/plugins/common.js
  4. 4 0
      src/plugins/index.js
  5. 28 26
      src/plugins/modal.js
  6. 12 1
      src/static/js/json.js
  7. 0 54
      src/utils/common.js
  8. 6 5
      src/utils/request.js
  9. 5 4
      src/utils/upload.js

+ 20 - 0
src/pages.json

@@ -267,6 +267,26 @@
     },
     //单位信息采集 结束
 
+    //消防报告 开始
+    {
+      "path": "pages/business/mhxf/fireReport/index",
+      "style": {
+        "navigationBarTitleText": "消防报告",
+        "enablePullDownRefresh": false
+      }
+    },
+    //消防报告 结束
+
+    //待办事项 开始
+    {
+      "path": "pages/business/mhxf/needMatter/index",
+      "style": {
+        "navigationBarTitleText": "待办事项",
+        "enablePullDownRefresh": false
+      }
+    },
+    //待办事项 结束
+
     //消息 开始
     {
       "path": "pages/info/info",

+ 17 - 21
src/permission.js

@@ -1,41 +1,37 @@
-import { getToken } from '@/utils/auth'
+import { getToken } from "@/utils/auth";
 
 // 登录页面
-const loginPage = "/pages/login"
-  
+const loginPage = "/pages/login";
+
 // 页面白名单
-const whiteList = [
-  '/pages/login', '/pages/common/webview/index',
-  '/pages/business/mhxf/unitInfoCollection/index', '/pages/business/mhxf/unitInfoCollection/index',
-]
+const whiteList = ["/pages/login", "/pages/common/webview/index", "/pages/business/mhxf/unitInfoCollection/index"];
 
 // 检查地址白名单
 function checkWhite(url) {
-  const path = url.split('?')[0]
-  return whiteList.indexOf(path) !== -1
+  const path = url.split("?")[0];
+  return whiteList.indexOf(path) !== -1;
 }
 
 // 页面跳转验证拦截器
-let list = ["navigateTo", "redirectTo", "reLaunch", "switchTab"]
-list.forEach(item => {
+let list = ["navigateTo", "redirectTo", "reLaunch", "switchTab"];
+list.forEach((item) => {
   uni.addInterceptor(item, {
     invoke(to) {
-      console.log(to)
       if (getToken()) {
         if (to.url === loginPage) {
-          uni.reLaunch({ url: "/" })
+          uni.reLaunch({ url: "/" });
         }
-        return true
+        return true;
       } else {
         if (checkWhite(to.url)) {
-          return true
+          return true;
         }
-        uni.reLaunch({ url: loginPage })
-        return false
+        uni.reLaunch({ url: loginPage });
+        return false;
       }
     },
     fail(err) {
-      console.log(err)
-    }
-  })
-})
+      console.log(err);
+    },
+  });
+});

+ 27 - 0
src/plugins/common.js

@@ -0,0 +1,27 @@
+export default {
+  /**
+   * 参数处理
+   * @param params 参数
+   */
+  tansParams(params) {
+    let result = "";
+    for (const propName of Object.keys(params)) {
+      const value = params[propName];
+      var part = encodeURIComponent(propName) + "=";
+      if (value !== null && value !== "" && typeof value !== "undefined") {
+        if (typeof value === "object") {
+          for (const key of Object.keys(value)) {
+            if (value[key] !== null && value[key] !== "" && typeof value[key] !== "undefined") {
+              let params = propName + "[" + key + "]";
+              var subPart = encodeURIComponent(params) + "=";
+              result += subPart + encodeURIComponent(value[key]) + "&";
+            }
+          }
+        } else {
+          result += part + encodeURIComponent(value) + "&";
+        }
+      }
+    }
+    return result;
+  },
+};

+ 4 - 0
src/plugins/index.js

@@ -1,6 +1,7 @@
 import tab from "./tab";
 import auth from "./auth";
 import modal from "./modal";
+import common from "./common";
 
 export default {
   install(app) {
@@ -13,5 +14,8 @@ export default {
     // 模态框对象
     app.provide("$modal", modal);
     app.config.globalProperties.$modal = modal;
+    // 数据处理
+    app.provide("$common", common);
+    app.config.globalProperties.$common = common;
   },
 };

+ 28 - 26
src/plugins/modal.js

@@ -3,72 +3,74 @@ export default {
   msg(content) {
     uni.showToast({
       title: content,
-      icon: 'none'
-    })
+      icon: "none",
+    });
   },
   // 错误消息
   msgError(content) {
     uni.showToast({
       title: content,
-      icon: 'error'
-    })
+      icon: "error",
+    });
   },
   // 成功消息
   msgSuccess(content) {
     uni.showToast({
       title: content,
-      icon: 'success'
-    })
+      icon: "success",
+    });
   },
   // 隐藏消息
   hideMsg(content) {
-    uni.hideToast()
+    uni.hideToast();
   },
   // 弹出提示
   alert(content) {
     uni.showModal({
-      title: '提示',
+      title: "提示",
       content: content,
-      showCancel: false
-    })
+      showCancel: false,
+      mask: true,
+    });
   },
   // 确认窗体
   confirm(content) {
     return new Promise((resolve, reject) => {
       uni.showModal({
-        title: '系统提示',
+        title: "系统提示",
         content: content,
-        cancelText: '取消',
-        confirmText: '确定',
-        success: function(res) {
+        cancelText: "取消",
+        confirmText: "确定",
+        success: function (res) {
           if (res.confirm) {
-            resolve(res.confirm)
+            resolve(res.confirm);
           }
-        }
-      })
-    })
+        },
+      });
+    });
   },
   // 提示信息
   showToast(option) {
     if (typeof option === "object") {
-      uni.showToast(option)
+      uni.showToast(option);
     } else {
       uni.showToast({
         title: option,
         icon: "none",
-        duration: 2500
-      })
+        duration: 2500,
+      });
     }
   },
   // 打开遮罩层
   loading(content) {
     uni.showLoading({
       title: content,
-      icon: 'none'
-    })
+      icon: "none",
+      mask: true,
+    });
   },
   // 关闭遮罩层
   closeLoading() {
-    uni.hideLoading()
-  }
-}
+    uni.hideLoading();
+  },
+};

+ 12 - 1
src/static/js/json.js

@@ -25,13 +25,24 @@ let cuIconList = [
     name: "协同作战",
     redirectUrl: "/pages/business/mhxf/coordination/index",
   },
-
   {
     imgUrl: "/static/images/index/ge5.png",
     badge: 0,
     name: "单位采集",
     redirectUrl: "/pages/business/mhxf/unitInfoCollection/index",
   },
+  {
+    imgUrl: "/static/images/index/ge6.png",
+    badge: 0,
+    name: "消防报告",
+    redirectUrl: "/pages/business/mhxf/fireReport/index",
+  },
+  {
+    imgUrl: "/static/images/index/ge7.png",
+    badge: 0,
+    name: "待办事项",
+    redirectUrl: "/pages/business/mhxf/needMatter/index",
+  },
   // {
   //   imgUrl: "/static/images/square/square-xf.png",
   //   badge: 0,

+ 0 - 54
src/utils/common.js

@@ -1,54 +0,0 @@
-/**
-* 显示消息提示框
-* @param content 提示的标题
-*/
-export function toast(content) {
-  uni.showToast({
-    icon: 'none',
-    title: content
-  })
-}
-
-/**
-* 显示模态弹窗
-* @param content 提示的标题
-*/
-export function showConfirm(content) {
-  return new Promise((resolve, reject) => {
-    uni.showModal({
-      title: '提示',
-      content: content,
-      cancelText: '取消',
-      confirmText: '确定',
-      success: function(res) {
-        resolve(res)
-      }
-    })
-  })
-}
-
-/**
-* 参数处理
-* @param params 参数
-*/
-export function tansParams(params) {
-  let result = ''
-  for (const propName of Object.keys(params)) {
-    const value = params[propName]
-    var part = encodeURIComponent(propName) + "="
-    if (value !== null && value !== "" && typeof (value) !== "undefined") {
-      if (typeof value === 'object') {
-        for (const key of Object.keys(value)) {
-          if (value[key] !== null && value[key] !== "" && typeof (value[key]) !== 'undefined') {
-            let params = propName + '[' + key + ']'
-            var subPart = encodeURIComponent(params) + "="
-            result += subPart + encodeURIComponent(value[key]) + "&"
-          }
-        }
-      } else {
-        result += part + encodeURIComponent(value) + "&"
-      }
-    }
-  }
-  return result
-}

+ 6 - 5
src/utils/request.js

@@ -1,7 +1,8 @@
 import useStores from "@/store/modules/user.js";
 import config from "@/config";
 import { getToken } from "@/utils/auth";
-import { toast, showConfirm, tansParams } from "@/utils/common";
+import modal from "@/plugins/modal";
+import common from "@/plugins/common";
 
 let timeout = 10000;
 const baseUrl = config.baseUrl;
@@ -16,7 +17,7 @@ const request = (config) => {
   }
   // get请求映射params参数
   if (config.params) {
-    let url = config.url + "?" + tansParams(config.params);
+    let url = config.url + "?" + common.tansParams(config.params);
     url = url.slice(0, -1);
     config.url = url;
   }
@@ -33,15 +34,15 @@ const request = (config) => {
       .then((response) => {
         let res = response;
         if (res.error) {
-          toast("后端接口连接异常");
+          modal.msg("后端接口连接异常");
           reject("后端接口连接异常");
           return;
         }
         const code = res.data.code || 200;
 
         if (code === 401) {
-          showConfirm("登录状态已过期,您可以继续留在该页面,或者重新登录?").then((res) => {
-            if (res.confirm) {
+          modal.confirm("登录状态已过期,您可以继续留在该页面,或者重新登录?").then((res) => {
+            if (res) {
               useStore.LogOut().then((res) => {
                 uni.reLaunch({ url: "/pages/login" });
               });

+ 5 - 4
src/utils/upload.js

@@ -1,7 +1,8 @@
 import useStores from "@/store/modules/user.js";
 import config from "@/config";
 import { getToken } from "@/utils/auth";
-import { toast, showConfirm, tansParams } from "@/utils/common";
+import modal from "@/plugins/modal";
+import common from "@/plugins/common";
 
 let timeout = 10000;
 const baseUrl = config.baseUrl;
@@ -16,7 +17,7 @@ const upload = (config) => {
   }
   // get请求映射params参数
   if (config.params) {
-    let url = config.url + "?" + tansParams(config.params);
+    let url = config.url + "?" + common.tansParams(config.params);
     url = url.slice(0, -1);
     config.url = url;
   }
@@ -34,8 +35,8 @@ const upload = (config) => {
         if (code === 200) {
           resolve(result);
         } else if (code == 401) {
-          showConfirm("登录状态已过期,您可以继续留在该页面,或者重新登录?").then((res) => {
-            if (res.confirm) {
+          modal.confirm("登录状态已过期,您可以继续留在该页面,或者重新登录?").then((res) => {
+            if (res) {
               useStore.LogOut().then((res) => {
                 uni.reLaunch({ url: "/pages/login" });
               });