Selaa lähdekoodia

增加签到按钮

chenrong 1 vuosi sitten
vanhempi
commit
77bf91e044
1 muutettua tiedostoa jossa 23 lisäystä ja 3 poistoa
  1. 23 3
      pages/task/index.vue

+ 23 - 3
pages/task/index.vue

@@ -34,7 +34,6 @@
             :class="{ 'bg-amber-200': i >= todayIndex || day.status, 'bg-gray-200': i < todayIndex }"
             class="flex justify-center items-center rounded-full"
             v-for="(day, i) in signList"
-            @click="sign(i)"
           >
             <div
               style="width: 45rpx; height: 45rpx"
@@ -56,6 +55,9 @@
             <span v-else="day.status" class="fs12 text-grey-500">未签到</span>
           </div>
         </div>
+        <div class="signInButton" @click="sign()">
+          {{ signList[todayIndex].status ? '今日已签到' : '立即签到' }}
+        </div>
       </div>
       <div class="card rounded-md shadow-sm mx-auto mt-4 py-2">
         <div class="fs16 bold italic text-gray-900 pl-3 my-2">消费领优惠券</div>
@@ -169,13 +171,20 @@ export default {
       })
     },
     sign(i) {
-      console.log(this.signList[i].status)
-      if (i == this.todayIndex && !this.signList[i].status) {
+      // console.log(this.signList[i].status)
+      // if (i == this.todayIndex && !this.signList[i].status) {
+      // }
+      if (!this.signList[this.todayIndex].status) {
         signToday().then(this.getList)
         wx.showToast({
           title: '签到成功',
           icon: 'sucess',
         })
+      } else {
+        wx.showToast({
+          title: '今日已签到',
+          icon: 'none',
+        })
       }
     },
     getSafeAreaTop() {
@@ -200,4 +209,15 @@ export default {
   color: #969696;
   font-size: 12px;
 }
+.signInButton {
+  margin: 10px auto;
+  background: #ff9235;
+  width: 20vw;
+  height: 30px;
+  color: #fff;
+  border-radius: 15px;
+  line-height: 30px;
+  text-align: center;
+  font-size: 12px;
+}
 </style>