Pārlūkot izejas kodu

投票加个字段

zyx 3 gadi atpakaļ
vecāks
revīzija
6a62d3b7c5
1 mainītis faili ar 31 papildinājumiem un 11 dzēšanām
  1. 31 11
      src/pages/vote/Index.vue

+ 31 - 11
src/pages/vote/Index.vue

@@ -9,7 +9,7 @@
       <van-checkbox-group v-model="checkboxGroup">
         <van-cell-group>
           <van-cell
-            :label="'作者:' + item.userName + '       票数:' +item.vote"
+            :label="voteLabel(item)"
             v-for="item in appNameList"
             :key="item.infoId"
             size="large"
@@ -100,6 +100,20 @@ export default {
     };
   },
   methods: {
+    voteLabel(item) {
+      if (this.disable) {
+        return "作者:" + item.userName + "       票数:" + item.vote;
+      }
+      return "作者:" + item.userName;
+    },
+    refresh() {
+      data = {
+        size: 50,
+        total: 0
+      };
+      this.appNameList = [];
+      this.addList();
+    },
     addList() {
       if (!getload) return;
       getload = false;
@@ -178,6 +192,7 @@ export default {
                 message: "投票成功",
                 position: "bottom"
               });
+              this.refresh();
             })
             .catch(() => {
               load.clear();
@@ -203,12 +218,12 @@ export default {
       if (this.$user) setToken(this.$user.accessToken);
       else setToken("");
       this.$user.accessToken &&
-        isVote().then(res => {
-          this.disable = (res || []).length !== 0;
-          this.checkboxGroup = (res || []).map(v => v.infoId);
-          console.log(res);
-          this.addList();
-        });
+      isVote().then(res => {
+        this.disable = (res || []).length !== 0;
+        this.checkboxGroup = (res || []).map(v => v.infoId);
+        console.log(res);
+        this.addList();
+      });
       if (!this.$user.accessToken) {
         this.addList();
       }
@@ -218,7 +233,8 @@ export default {
     let width = document.body.offsetWidth || 0;
     this.$refs.vote.style.minHeight = height - (856 / 1500) * width + "px";
   },
-  beforeDestroy: function() {},
+  beforeDestroy: function() {
+  },
   components: {
     vanPopup,
     vanIcon,
@@ -242,11 +258,13 @@ $themeColor: #e6837c;
 
   .introduction {
     font-size: 14px;
+
     .head {
       height: 54px;
       line-height: 54px;
       text-align: center;
     }
+
     .body {
       line-height: 30px;
       text-indent: 2em;
@@ -260,9 +278,9 @@ $themeColor: #e6837c;
     padding: 1em 0;
     bottom: 0;
     background-image: linear-gradient(
-      0deg,
-      rgba(170, 170, 170, 0.8) 5%,
-      rgba(0, 0, 0, 0)
+        0deg,
+        rgba(170, 170, 170, 0.8) 5%,
+        rgba(0, 0, 0, 0)
     );
   }
 
@@ -272,11 +290,13 @@ $themeColor: #e6837c;
 
   .van-checkbox__icon--checked {
     background: #fff;
+
     .van-icon-success {
       background: $themeColor;
       border-color: $themeColor;
     }
   }
+
   .van-checkbox__label--disabled {
     color: #323233;
   }