liyongli 3 jaren geleden
bovenliggende
commit
c9fbe7e31c
2 gewijzigde bestanden met toevoegingen van 33 en 13 verwijderingen
  1. 33 12
      src/pages/vote/Index.vue
  2. 0 1
      src/utils/request.js

+ 33 - 12
src/pages/vote/Index.vue

@@ -103,15 +103,25 @@ export default {
     addList() {
       if (!getload) return;
       getload = false;
-      voteList("size=" + data.size + "&total=" + data.total).then(res => {
-        this.appNameList.push(...(res || []));
-        data.total = this.appNameList.length;
-        let checkboxGroup = [];
-        this.checkboxGroup = checkboxGroup;
-        this.$nextTick(() => {
-          res.length && (getload = true);
-        });
+      let load = Toast.loading({
+        message: "加载中...",
+        duration: 0,
+        forbidClick: false
       });
+      voteList("size=" + data.size + "&total=" + data.total)
+        .then(res => {
+          this.appNameList.push(...(res || []));
+          data.total = this.appNameList.length;
+          let checkboxGroup = [];
+          this.checkboxGroup = checkboxGroup;
+          this.$nextTick(() => {
+            res.length && (getload = true);
+            load.clear();
+          });
+        })
+        .catch(() => {
+          load.clear();
+        });
     },
     showPop(item) {
       if (!item.appDesc) return;
@@ -157,9 +167,16 @@ export default {
               view: ""
             });
           }
+
+          let load = Toast.loading({
+            message: "加载中...",
+            duration: 0,
+            forbidClick: false
+          });
           saveVote({ source: "智慧融媒", items: r })
             .then(() => {
               this.disable = true;
+              load.clear();
               Toast({
                 message: "投票成功",
                 position: "bottom"
@@ -167,6 +184,7 @@ export default {
             })
             .catch(err => {
               console.log(err);
+              load.clear();
             });
           return false;
         })
@@ -186,13 +204,16 @@ export default {
       if (isAndroid && window.H5Listener)
         this.$user = window.H5Listener.getUserInfo() || {};
       this.$user = JSON.parse(this.$user);
-      console.log("-->", this.$user);
       if (this.$user) setToken(this.$user.accessToken);
       else setToken("");
-      isVote().then(res => {
-        this.disable = (res || []).length === 0;
+      this.$user.accessToken &&
+        isVote().then(res => {
+          this.disable = (res || []).length === 0;
+          this.addList();
+        });
+      if (!this.$user.accessToken) {
         this.addList();
-      });
+      }
     };
     window.voteNext();
     let height = document.body.offsetHeight || 0;

+ 0 - 1
src/utils/request.js

@@ -64,7 +64,6 @@ service.interceptors.response.use(
   error => {
     //if(LoadingInstance){LoadingInstance.clear();}
     //Toast("网络错误");
-    console.log();
     if (/403/.test(error.toString()))
       window.parent
         ? (window.parent.location.href = "/login.html")