Forráskód Böngészése

抽奖页面 防止重复提交

DESKTOP-O04BTUJ\muzen 2 éve
szülő
commit
4501c57e55
2 módosított fájl, 15 hozzáadás és 5 törlés
  1. 14 4
      src/pages/lottery/detail.vue
  2. 1 1
      src/pages/lottery/index.vue

+ 14 - 4
src/pages/lottery/detail.vue

@@ -15,8 +15,10 @@
       <uni-forms-item label="收货地址:" name="receiveAddress" required>
         <textarea v-model="form.receiveAddress" placeholder="请输入收货地址" />
       </uni-forms-item>
-      <button @click="getSubmit" :disabled="disabled">确认</button>
     </uni-forms>
+    <view class="submit">
+      <button @click="getSubmit" :disabled="disabled">确认</button>
+    </view>
   </view>
 </template>
 
@@ -69,9 +71,9 @@ export default {
 
     // 确定
     getSubmit() {
-      this.disabled = true
       this.$refs.form.validate((valid) => {
         if (!valid) {
+          this.disabled = true
           receive(getApp().globalData.userInfo, this.form).then(res => {
             if (res.data.code === 0) {
               uni.showToast({
@@ -81,11 +83,12 @@ export default {
               setTimeout(() => {
                 this.getBack()
               }, 3000)
-            }else{
+            } else {
               uni.showToast({
                 icon: 'error',
                 title: res.data.message,
               })
+              this.disabled = false
             }
           })
         }
@@ -139,11 +142,18 @@ export default {
     .form-item {
       margin: 32rpx 0 0 0;
     }
+  }
+
+  .submit {
+    position: absolute;
+    bottom: 100rpx;
+    left: 50%;
+    transform: translate(-50%);
 
     button {
       background: linear-gradient(180deg, #72cdae 0%, #599f82 100%);
       color: #fff;
-      // width: 480rpx;
+      width: 480rpx;
       height: 80rpx;
       line-height: 80rpx;
       border-radius: 50rpx;

+ 1 - 1
src/pages/lottery/index.vue

@@ -191,7 +191,7 @@ export default {
               uni.showToast({
                 title: '领取成功,已累积到积分中!'
               })
-            }, 2000)
+            }, 1000)
           }
         })
       }