DESKTOP-O04BTUJ\muzen %!s(int64=3) %!d(string=hai) anos
pai
achega
1e7ef8576d
Modificáronse 2 ficheiros con 58 adicións e 48 borrados
  1. 9 8
      src/pages/lottery/detail.vue
  2. 49 40
      src/pages/lottery/index.vue

+ 9 - 8
src/pages/lottery/detail.vue

@@ -18,7 +18,7 @@
         <view>收货地址</view>
         <view>收货地址</view>
         <textarea v-model="form.receiveAddress" placeholder="请输入收货地址" />
         <textarea v-model="form.receiveAddress" placeholder="请输入收货地址" />
       </view>
       </view>
-      <button @click="getSubmit">确认</button>
+      <button @click="getSubmit" :disabled="disabled">确认</button>
     </view>
     </view>
   </view>
   </view>
 </template>
 </template>
@@ -31,8 +31,8 @@ export default {
       statusBarHeight: 0,
       statusBarHeight: 0,
       // 表单
       // 表单
       form: {},
       form: {},
-      // 定时器
-      timer: null
+      // 防重复点击
+      disabled: false
     }
     }
   },
   },
   onLoad(e) {
   onLoad(e) {
@@ -42,7 +42,9 @@ export default {
   methods: {
   methods: {
     // 返回
     // 返回
     getBack() {
     getBack() {
-      uni.navigateBack()
+      uni.navigateTo({
+        url: `/pages/lottery/index`
+      })
     },
     },
 
 
     // 确定
     // 确定
@@ -63,16 +65,15 @@ export default {
           title: '请输入收货地址'
           title: '请输入收货地址'
         })
         })
       } else {
       } else {
+        this.disabled = true
         receive(this.form).then(res => {
         receive(this.form).then(res => {
           if (res.data.code === 0) {
           if (res.data.code === 0) {
             uni.showToast({
             uni.showToast({
               title: '提交成功!',
               title: '提交成功!',
               duration: 3000
               duration: 3000
             })
             })
-            this.timer = setTimeout(() => {
-              uni.navigateTo({
-                url: `/pages/lottery/index`
-              })
+            setTimeout(() => {
+              this.getBack()
             }, 3000)
             }, 3000)
           }
           }
         })
         })

+ 49 - 40
src/pages/lottery/index.vue

@@ -28,23 +28,12 @@
 
 
     <!-- 弹窗 -->
     <!-- 弹窗 -->
     <uni-popup ref="popup" type="center">
     <uni-popup ref="popup" type="center">
-      <view class="popup" v-if="form.resultGoodType === 5">
-        <view>谢谢参与</view>
-        <view style="color: #999999; font-size: 28rpx">别灰心,再来一次~</view>
-        <img src="@/static/lottery/thankYou.png" />
-        <button @click="getAgain">再抽一次</button>
-      </view>
-      <view class="popup" v-if="form.resultGoodType === 4">
-        <view>恭喜您中奖啦!</view>
-        <img src="@/static/lottery/point.png" />
-        <view style="color: #1A5509; font-size: 32rpx">+ {{ form.resultGoodName }}</view>
-        <button @click="getSubmit">领取</button>
-      </view>
-      <view class="popup" v-if="form.resultGoodType === 3">
-        <view>恭喜您中奖啦!</view>
-        <img :src="form.resultGoodPic" />
+      <view class="popup">
         <view>{{ form.resultGoodName }}</view>
         <view>{{ form.resultGoodName }}</view>
-        <button @click="getDetail">填写收货信息</button>
+        <img :src="form.resultGoodPic" />
+        <button v-if="form.resultGoodType === 4" @click="getSubmit">领取</button>
+        <button v-if="form.resultGoodType === 5" @click="getAgain">再抽一次</button>
+        <button v-if="form.resultGoodType === 3" @click="getDetail">填写收货信息</button>
       </view>
       </view>
     </uni-popup>
     </uni-popup>
   </view>
   </view>
@@ -86,7 +75,9 @@ export default {
       // 活动规则
       // 活动规则
       ruleList: [],
       ruleList: [],
       // 表单
       // 表单
-      form: {}
+      form: {},
+      // 防止连点
+      disabled: true
     }
     }
   },
   },
   onLoad(e) {
   onLoad(e) {
@@ -101,6 +92,7 @@ export default {
 
 
     // 获取页面信息
     // 获取页面信息
     getList() {
     getList() {
+      this.prizes = []
       page({
       page({
         userId: this.userId
         userId: this.userId
       }).then(res => {
       }).then(res => {
@@ -140,16 +132,25 @@ export default {
       if (this.hasLotteryCount > 0) {
       if (this.hasLotteryCount > 0) {
         if (this.maySignPoint > this.lotteryConsumePoint) {
         if (this.maySignPoint > this.lotteryConsumePoint) {
           this.$refs.lucky.play()
           this.$refs.lucky.play()
-          result({
-            userId: this.userId
-          }).then(res => {
-            if (res.data.code === 0) {
-              setTimeout(() => {
-                this.$refs.lucky.stop(res.data.data.resultGoodSort - 1)
-                this.form = res.data.data
-              }, 3000)
-            }
-          })
+          if (this.disabled) {
+            this.disabled = false
+            result({
+              userId: this.userId
+            }).then(res => {
+              if (res.data.code === 0) {
+                setTimeout(() => {
+                  this.$refs.lucky.stop(res.data.data.resultGoodSort - 1)
+                  this.form = res.data.data
+                }, 3000)
+              } else {
+                this.$refs.lucky.stop()
+                uni.showToast({
+                  icon: 'error',
+                  title: res.data.message
+                })
+              }
+            })
+          }
         } else {
         } else {
           uni.showToast({
           uni.showToast({
             icon: 'error',
             icon: 'error',
@@ -164,9 +165,11 @@ export default {
       }
       }
     },
     },
     // 抽奖结束触发回调
     // 抽奖结束触发回调
-    endCallBack(prize) {
+    endCallBack() {
       this.$nextTick(() => {
       this.$nextTick(() => {
         this.$refs.popup.open()
         this.$refs.popup.open()
+        this.disabled = true
+        this.getList()
       })
       })
     },
     },
 
 
@@ -178,18 +181,24 @@ export default {
 
 
     // 领取
     // 领取
     getSubmit() {
     getSubmit() {
-      receive({
-        prizeId: this.form.resultGoodId,
-        userId: this.form.userId,
-        lotteryCode: this.form.lotteryCode
-      }).then(res => {
-        if (res.data.code === 0) {
-          uni.showToast({
-            title: '领取成功!'
-          })
-          this.$refs.popup.close()
-        }
-      })
+      if (this.disabled) {
+        this.disabled = false
+        receive({
+          prizeId: this.form.resultGoodId,
+          userId: this.form.userId,
+          lotteryCode: this.form.lotteryCode
+        }).then(res => {
+          if (res.data.code === 0) {
+            this.$refs.popup.close()
+            uni.showToast({
+              title: '领取成功!'
+            })
+            setTimeout(() => {
+              this.disabled = true
+            }, 2000)
+          }
+        })
+      }
     },
     },
 
 
     // 填写收货信息
     // 填写收货信息