Просмотр исходного кода

修改页面和增加token失效处理

shaogen1995 4 лет назад
Родитель
Сommit
e88d695090

+ 8 - 6
src/utils/request.js

@@ -1,4 +1,5 @@
 import axios from 'axios'
+import { Message } from 'element-ui'
 // export const baseURL = '666初始地址'
 const service = axios.create({
   baseURL: 'http://192.168.0.135:8006',
@@ -24,13 +25,14 @@ service.interceptors.request.use(function (config) {
 
 // 添加响应拦截器
 service.interceptors.response.use(function (response) {
-  // console.log('触发相应拦截器')
+  // console.log('触发相应拦截器', response)
   // 对响应数据做点什么--response就是发送每个请求的返回值
-  // if (response.data.message === '用户信息验证失败') {
-  //   // Toast.fail('未登录,请先登录')
-  //   // 登录完之后能返回刚刚的页面
-  //   location.href = '#/login?redirectUrl=' + location.href
-  // }
+  if (response.data.code === 5001 || response.data.code === 5002) {
+    // Toast.fail('未登录,请先登录')
+    Message.warning('登录失效,请重新登录')
+    // 登录完之后能返回刚刚的页面
+    location.href = '#/login'
+  }
   return response.data
 }, function (error) {
   // 对响应错误做点什么

+ 4 - 4
src/views/holding/holding0_add.vue

@@ -257,7 +257,7 @@ export default {
     this.fromData.number = this.mydata.num
     this.fromData.unit = this.mydata.unit
     this.fromData.description = this.mydata.description
-
+    this.fromData.people = this.mydata.realName
     // 获取服务器前缀地址
     this.baseURL = axios.defaults.baseURL
     // 调用藏品登记方法
@@ -270,9 +270,9 @@ export default {
     this.sourceList = res.data
     // console.log(6666, res.data)
     // 获取用户名
-    let userData = localStorage.getItem('daliCK')
-    userData = JSON.parse(userData)
-    this.fromData.people = userData.user.nickName
+    // let userData = localStorage.getItem('daliCK')
+    // userData = JSON.parse(userData)
+    // this.fromData.people = userData.user.nickName
   },
   beforeCreate () {}, // 生命周期 - 创建之前
   beforeMount () {}, // 生命周期 - 挂载之前

+ 32 - 0
src/views/holding/holding1.vue

@@ -12,7 +12,11 @@
         </el-breadcrumb>
       </div>
       <div class="conten">
+
         <div class="middle">
+          <ul class="title">
+            <li :class="{active:stateInd===index}" @click="stateInd=index" v-for="(item,index) in stateArr" :key="index">{{item.txt}}({{item.num}})</li>
+          </ul>
           <div class="select">
             <span>登记人:</span>
             <el-input
@@ -83,6 +87,14 @@ export default {
   components: { TabList },
   data () {
     return {
+      // 选择状态的变量
+      stateInd: 0,
+      stateArr: [
+        { txt: '全部', num: 356 },
+        { txt: '待审核', num: 35 },
+        { txt: '待办理', num: 35 },
+        { txt: '已完成', num: 35 }
+      ],
       type: '',
       time: '',
       // 表格数据
@@ -146,6 +158,26 @@ export default {
       width: 100%;
       height: 829px;
       .middle {
+        .title{
+          height: 60px;
+          border-bottom: 1px solid #ccc;
+          margin: 0 25px;
+          display: flex;
+          align-items: center;
+          color: black;
+          .active{
+            color: #409eff;
+            border-bottom: 2px solid #409eff;
+          }
+          li {
+            height: 60px;
+            line-height: 60px;
+            width: 120px;
+            text-align: center;
+            margin-left: 40px;
+            cursor: pointer;
+          }
+        }
         position: relative;
         width: 100%;
         height: 100%;

+ 32 - 1
src/views/holding/holding2.vue

@@ -12,6 +12,10 @@
       </div>
       <div class="conten">
         <div class="middle">
+                    <ul class="title">
+            <li :class="{active:stateInd===index}" @click="stateInd=index" v-for="(item,index) in stateArr" :key="index">{{item.txt}}({{item.num}})</li>
+          </ul>
+
           <div class="select">
             <span>登记人:</span>
             <el-input
@@ -83,7 +87,14 @@ export default {
   components: { TabList },
   data () {
     return {
-
+      // 选择状态的变量
+      stateInd: 0,
+      stateArr: [
+        { txt: '全部', num: 356 },
+        { txt: '待审核', num: 35 },
+        { txt: '待办理', num: 35 },
+        { txt: '已完成', num: 35 }
+      ],
       type: '',
       time: '',
       // 表格数据
@@ -146,6 +157,26 @@ export default {
       width: 100%;
       height: 829px;
       .middle {
+                .title{
+          height: 60px;
+          border-bottom: 1px solid #ccc;
+          margin: 0 25px;
+          display: flex;
+          align-items: center;
+          color: black;
+          .active{
+            color: #409eff;
+            border-bottom: 2px solid #409eff;
+          }
+          li {
+            height: 60px;
+            line-height: 60px;
+            width: 120px;
+            text-align: center;
+            margin-left: 40px;
+            cursor: pointer;
+          }
+        }
         position: relative;
         width: 100%;
         height: 100%;