Browse Source

修改登陆状态时效问题

plg 2 weeks ago
parent
commit
7d2de94022
2 changed files with 37 additions and 27 deletions
  1. 9 3
      src/components/PlanUserStatus.vue
  2. 28 24
      src/utils/http.js

+ 9 - 3
src/components/PlanUserStatus.vue

@@ -90,7 +90,7 @@
                   width=""
                 >
                 </el-table-column>
-                <el-table-column label="操作" width="" align="center">
+                <el-table-column label="操作" width="" align="center" v-if="proDataLin.planStatus=='2'">
                   <template slot-scope="scope">
                     <div class="detail_button_out" v-show="scope.row.isComplete == '1'&&proDataLin.planStatus=='2'&&scope.row.isReset=='0'">
                       <div class="detail_button" @click="anewStart(scope.row)">
@@ -309,8 +309,14 @@ export default {
     },
     //进来调用已选列表接口
     searchList() {
-     
-      let url = `/planUser/findUserProgressByPage?pageSize=${this.pageSize}&pageNum=${this.pageNum}&planId=${this.proDataLin.id}&userName=${this.studentName}`;
+      //
+      let url=''
+      if(this.studentName==''){
+        url = `/planUser/findUserProgressByPage?pageSize=${this.pageSize}&pageNum=${this.pageNum}&planId=${this.proDataLin.id}`;
+      }else{
+        url = `/planUser/findUserProgressByPage?pageSize=${this.pageSize}&pageNum=${this.pageNum}&planId=${this.proDataLin.id}&userName=${this.studentName}`;
+      }
+    
       this.$http.get(url, {}, (res) => {
         if (res && res.code == 200) {
           this.tableData = res.data.content;

+ 28 - 24
src/utils/http.js

@@ -18,9 +18,9 @@ import { router } from "@/router";
 // axios.defaults.baseURL = 'https://child.hhnao.com:8070';
 //https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx01d1a44906973cf2&redirect_uri=http%3A%2F%2F192.168.18.51%3A8085&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect
 //本地
-// export const basePath='http://10.113.248.4:8089'
+export const basePath = "http://10.113.248.4:8089";
 //30
-export const basePath = "http://43.143.198.30:8089";
+// export const basePath = "http://43.143.198.30:8089";
 //
 // export const basePath = "http://129.211.221.44:8089";
 // const base_url = 'http://43.143.198.30:8089/'
@@ -34,7 +34,7 @@ axios.defaults.baseURL = basePath;
 // var urlCode ='http://43.143.198.30:8085';
 // var urlCode ='https://child.hhnao.com';
 var urlCode = "";
-
+let time;
 //接口白名单
 var whiteList = ["/user/blogin", "/user/getCode"];
 
@@ -50,7 +50,7 @@ axios.defaults.headers.common["Content-Type"] =
   "application/JSON;charset=UTF-8";
 axios.defaults.withCredentials = true;
 // let loadingInstance
-var noTime = false
+var noTime = false;
 axios.interceptors.request.use(
   function (config) {
     for (let i = 0; i < whiteList.length; i++) {
@@ -105,11 +105,22 @@ axios.interceptors.response.use(
     //返回code若为401,则表示token有问题
     if (response.data.code === 401) {
       //当401时清除缓存信息
-     
-      if(oSessionStorage.getItem("userInfo") !== ""){
-        oSessionStorage.removeItem('userInfo')
-        Message.error(response.data.msg);
+
+      if (oSessionStorage.getItem("userInfo") !== "") {
+        oSessionStorage.removeItem("userInfo");
+        // Message.error(response.data.msg);
       
+        //搞个节流函数
+        let flagT = false;
+        clearTimeout(time);
+        time = setTimeout(() => {
+          flagT = true;
+          if (flagT) {
+            Message.error(response.data.msg);
+          }
+        }, 500);
+
+        // alert('1111')
       }
       // 重定向到登录页
       router.replace({
@@ -121,7 +132,6 @@ axios.interceptors.response.use(
       // if(){
 
       // }
-     
     }
 
     return response;
@@ -135,7 +145,6 @@ axios.interceptors.response.use(
 
 const http = {
   get: (url, data, sCallBack) => {
-  
     if (data) {
       if (isMI) {
         data = Encrypt(JSON.stringify(data));
@@ -169,10 +178,10 @@ const http = {
           Accept: "application/octet-stream",
           //  "Content-Disposition":"attachment"
         },
-      },{
-        responseType:'arraybuffer'
+      },
+      {
+        responseType: "arraybuffer",
       }
-
     ).then((res) => {
       sCallBack(res);
     });
@@ -225,12 +234,12 @@ const http = {
         // data = data;
       }
     }
-    axios.post(url,  data ).then((res) => {
+    axios.post(url, data).then((res) => {
       // res.status
       if (res) {
         if (isMI) {
           res.data = JSON.parse(Decrypt(res.data));
-        }else{
+        } else {
           // res.data = JSON.parse(res.data);
         }
       }
@@ -241,7 +250,6 @@ const http = {
         }
       } else if (res.status === 401) {
         //token过期了
-        
       } else {
         if (errCallBack) {
           errCallBack(res.data);
@@ -254,23 +262,20 @@ const http = {
   },
   delete: (url, data, sucessCallBack, errCallBack) => {
     if (data) {
-      if(isMI){
+      if (isMI) {
         data = Encrypt(JSON.stringify(data));
-      }else{
+      } else {
         data = JSON.stringify(data);
       }
-   
     }
     axios.delete(url, { data: data }).then((res) => {
-   
       // res.status
       if (res) {
-        if(isMI){
+        if (isMI) {
           res.data = JSON.parse(Decrypt(res.data));
-        }else{
+        } else {
           res.data = JSON.parse(res.data);
         }
-       
       }
 
       if (res.status >= 200 && res.status < 300) {
@@ -279,7 +284,6 @@ const http = {
         }
       } else if (res.status === 401) {
         //token过期了
-      
       } else {
         if (errCallBack) {
           errCallBack(res.data);