coderzzp 3 年之前
父節點
當前提交
0825b1ba7b
共有 7 個文件被更改,包括 78 次插入43 次删除
  1. 2 1
      index.html
  2. 5 4
      src/App.vue
  3. 10 4
      src/utils/request.js
  4. 1 1
      src/views/base/departmentStatistics.vue
  5. 37 20
      src/views/base/peopleManage.vue
  6. 20 10
      src/views/base/punch.vue
  7. 3 3
      src/views/base/statistics.vue

+ 2 - 1
index.html

@@ -11,5 +11,6 @@
   </body>
   <script src="ebeiapp://cordova.js"></script>
   <script src="ebeiapp://EbeiPlugins.js"></script>
-  <script src="https://webapi.amap.com/maps?v=1.4.15&key=73f14a1c454d2bc6358609ca99885496&plugin=AMap.CircleEditor,AMap.PolyEditor"></script>
+  <!-- <script src="https://webapi.amap.com/maps?v=1.4.15&key=73f14a1c454d2bc6358609ca99885496&plugin=AMap.CircleEditor,AMap.PolyEditor"></script> -->
+  <script src="https://webapi.amap.com/maps?v=1.4.15&key=48723d1b64db9db0d0af8ec8ce01b8a9&plugin=AMap.CircleEditor,AMap.PolyEditor"></script>
 </html>

+ 5 - 4
src/App.vue

@@ -10,10 +10,11 @@ export default {
   name: 'App',
   created() {
       // token 
-      let token = this.$route.query.token
-      if(token) {
-        setStore({'name':'token', 'content': token, 'type':''})
-      }
+      // let token = this.$route.query.token
+      // console.log(this.$route.query.token)
+      // if(token) {
+      //   setStore({'name':'token', 'content': token, 'type':''})
+      // }
     }
 }
 </script>

+ 10 - 4
src/utils/request.js

@@ -2,14 +2,15 @@ import axios from 'axios'
 import { getToken } from '@/utils/auth'
 import { Notify } from 'vant'
 import Router from '../router'
-
+import { returnApp } from '@/utils/native'
 /**
  * 使用自定义配置新建一个 axios 实例
  * baseURL = 请求路径
  * timeout = 请求超时配置
  */
  export const request = axios.create({
-  baseURL: 'https://www.gzjlzhwy.com:4433/',
+  baseURL: 'http://www.gzjlzhwy.com/',
+  // baseURL: 'https://www.gzjlzhwy.com:4433/',
   // baseURL: 'http://172.18.0.15:30000/',
   // baseURL: process.env.BASE_API,
   timeout: process.env.TIME_OUT,
@@ -33,7 +34,7 @@ request.interceptors.request.use(config => {
     config.headers.Authorization = accessToken
   } else {
     // config.headers.Authorization = 'Basic dnVlOnZ1ZQ=='
-    config.headers.Authorization = '374b833554225792a221a64529f8d791'
+    config.headers.Authorization = ''
   }
   //  添加时间戳防止IE不刷新页面
   if (config.type != 'FORM') {
@@ -72,6 +73,11 @@ request.interceptors.response.use(
     // Spin.hide()
     // 请求成功处理
     const res = response.data
+    if(res.status == 50000 && res.message == '请登录') {
+      console.log(2222);
+      Notify({ type: 'warning', message: '凭证过期,请重新登录',duration: 1000 })
+      setTimeout(() => returnApp(),1000)
+    }
     // debugger
     return res
   },
@@ -83,7 +89,7 @@ request.interceptors.response.use(
     if (response != undefined && response.data) {
       if (response.data.statusCode == '401' && response.status == 401) {
         Notify({ type: 'warning', message: '凭证过期,请重新登录' })
-        Router.push('/')
+        setTimeout(() => returnApp(),1000)
       } else if (response.status == 500) {
         Notify({ type: 'warning', message: response.data.message })
       } else if (response.status != 200) {

+ 1 - 1
src/views/base/departmentStatistics.vue

@@ -124,4 +124,4 @@ $grey: #f2f2f2;
   border-left: 10px solid $grey;
   border-right: 10px solid $grey;
 }
-</style>
+</style>

+ 37 - 20
src/views/base/peopleManage.vue

@@ -1,7 +1,10 @@
 <template>
   <div>
     <nav-bar />
-    <manage-index :listData="listData" style="overflow-y:auto;height:calc( 100vh - 44px );" />
+    <manage-index
+      :listData="listData"
+      style="overflow-y: auto; height: calc(100vh - 46px)"
+    />
   </div>
 </template>
 
@@ -9,42 +12,56 @@
 import navBar from "@/components/peopleManage/navBarPeople";
 import manageIndex from "@/components/peopleManage/index";
 import { Notify } from "vant";
-import { userManageList } from "@/api"
-import { getStore } from "@/utils/store"
+import { userManageList } from "@/api";
+import { getStore, setStore } from "@/utils/store";
+import { getToken } from "@/utils/auth";
 export default {
   name: "peopleManage",
   components: {
     navBar,
-    manageIndex
+    manageIndex,
   },
   created() {
-    if(!getStore({'name':'projectId','type':'','debug':''})){
-      Notify({ type: 'warning', message: '请先选择项目',duration:1000 })
-      setTimeout(()=> {
-        this.$router.push('/chooseProject')
-      },1000)
+    // 路径获取token或者缓存中已经存在token
+    let token = this.$route.query.token || getToken();
+    if (token) {
+      setStore({ name: "token", content: token, type: "" });
+      // 是否已经选择项目
+      if (!getStore({ name: "projectId", type: "", debug: "" })) {
+        Notify({ type: "warning", message: "请先选择项目", duration: 1000 });
+        setTimeout(() => {
+          this.$router.push("/chooseProject");
+        }, 1000);
+      } else {
+        this.getUserManageList();
+      }
     } else {
-      this.getUserManageList()
+      Notify({
+        type: "warning",
+        message: "凭证过期,请重新登录",
+        duration: 1000,
+      });
+      setTimeout(() => returnApp(), 1000);
     }
   },
   data() {
     return {
-      listData: []
-    }
+      listData: [],
+    };
   },
   methods: {
     getUserManageList() {
-      userManageList(this.$store.state.pid).then( res => {
-        if(res.status === 10000) {
-          this.listData = res.data
+      userManageList(this.$store.state.pid).then((res) => {
+        if (res.status === 10000) {
+          this.listData = res.data;
         } else {
-          Notify({ type: 'warning', message: res.message })
+          Notify({ type: "warning", message: res.message });
         }
-      })
-    }
-  }
+      });
+    },
+  },
 };
 </script>
 
 <style lang="scss" scoped>
-</style>
+</style>

+ 20 - 10
src/views/base/punch.vue

@@ -33,7 +33,7 @@
     </template>
     <van-tabbar v-model="active">
       <van-tabbar-item icon="location-o">打卡</van-tabbar-item>
-      <van-tabbar-item to="/statistics" icon="records">统计</van-tabbar-item>
+      <van-tabbar-item to="/statistics" replace icon="records">统计</van-tabbar-item>
     </van-tabbar>
   </div>
 </template>
@@ -46,6 +46,9 @@ import Loading from "@/components/loading";
 import { mapState } from "vuex";
 import empty from "@/assets/empty.png";
 import { Toast,Notify } from "vant";
+import { returnApp } from '@/utils/native'
+import { setStore } from '@/utils/store'
+import { getToken } from "@/utils/auth";
 import { getButtonState,getTodaySignRecord,signRecord,userInfoHead } from "@/api"
 export default {
   name: "punch",
@@ -87,10 +90,17 @@ export default {
     },
   },
   created() {
-    this.$store.commit('showLoading')
-    this.currentTime();
-    this.getUserInfoHead()
-    this.getButtonStateInfo()
+    let token = this.$route.query.token || getToken();
+    if(token) {
+      setStore({'name':'token', 'content': token, 'type':''})
+      this.$store.commit('showLoading')
+      this.currentTime();
+      this.getUserInfoHead()
+      this.getButtonStateInfo()
+    } else {
+      Notify({ type: 'warning', message: '凭证过期,请重新登录',duration: 1000 })
+      setTimeout(() => returnApp(),1000)
+    }
   },
   beforeDestroy() {
     clearInterval(this.interOne)
@@ -103,7 +113,6 @@ export default {
           this.$store.commit('setUserInfo',res.data)
         } else {
           this.$store.commit('hideLoading')
-          Notify({ type: 'warning', message: res.message })
         }
       })
     },
@@ -114,11 +123,11 @@ export default {
           this.buttonData = res.data
           if(arg) {
             this.getTodaySignRecordInfo()
-          }  
+          }
         } else {
+          Notify({ type: 'warning', message: res.message, duration: 1000 })
           this.$store.commit('hideLoading')
-          clearInterval(this.interOne)
-          Notify({ type: 'warning', message: res.data })
+          setTimeout(() => returnApp(),1000)
         }
       })
     },
@@ -133,7 +142,8 @@ export default {
           }
         } else {
           this.$store.commit('hideLoading')
-          Notify({ type: 'warning', message: res.data })
+          Notify({ type: 'warning', message: res.message, duration: 1000 })
+          setTimeout(() => returnApp(),1000)
         }
       })
     },

+ 3 - 3
src/views/base/statistics.vue

@@ -74,7 +74,7 @@
       </template>
     </div>
     <van-tabbar v-model="active">
-      <van-tabbar-item to="/punch" icon="location-o">打卡</van-tabbar-item>
+      <van-tabbar-item to="/punch" replace icon="location-o">打卡</van-tabbar-item>
       <van-tabbar-item icon="records">统计</van-tabbar-item>
     </van-tabbar>
   </div>
@@ -190,7 +190,7 @@ export default {
       } else {
         this.dkInfo = {}
       }
-     
+
     },
   },
 };
@@ -285,4 +285,4 @@ $height: 0.6vh;
 /deep/ .van-empty__description {
   color: #aaa;
 }
-</style>
+</style>