Ver código fonte

抽奖活动

huangb 7 anos atrás
pai
commit
8794057c9a
2 arquivos alterados com 42 adições e 17 exclusões
  1. 26 9
      components/lotteryDraw/lottery.vue
  2. 16 8
      store/lottery.js

+ 26 - 9
components/lotteryDraw/lottery.vue

@@ -163,7 +163,7 @@
           <p>您未获得抽奖机会,请您先发布询价</p>
         </div>
         <span slot="footer" class="dialog-footer">
-          <a type="button" @click="showNoPriseBox = false">确认</a>
+          <a type="button" @click="sureInquiry(false)">确认</a>
         </span>
       </el-dialog>
     </div>
@@ -184,7 +184,15 @@
     <div class="no-prise get-prise" v-if="winningInfo.data">
       <el-dialog
         :visible.sync="showGetPriseBox">
-        <div class="dialog-content">
+        <div class="dialog-content" v-if="winningInfo.data.name === ''">
+          <!--<div class="close" @click="showGetPriseBox = false">&times;</div>-->
+          <img src="/images/lottery/hua.png" class="hua" alt=""/>
+          <p>很遗憾,您没有中奖,下次还有机会!</p>
+          <span slot="footer" class="dialog-footer">
+          <a type="button" @click="closeGotPriseInfo(false)">确认</a>
+        </span>
+        </div>
+        <div class="dialog-content" v-else>
           <!--<div class="close" @click="showGetPriseBox = false">&times;</div>-->
           <img src="/images/lottery/hua.png" class="hua" alt=""/>
           <p>恭喜您抽中<span v-text="winningInfo.data.name"></span>,请添加客服微信使用兑换码兑换</p>
@@ -323,6 +331,11 @@
       })
     },
     methods: {
+      // 去询价
+      sureInquiry (type) {
+        this.showNoPriseBox = type
+        this.$router.push('/applyPurchase')
+      },
       // 获取第3和第7奖品详情
       getDetail () {
         this.currentPrizes.forEach((item, index) => {
@@ -429,14 +442,18 @@
       // 开始抽奖
       startLottery () {
         if (this.$store.state.option.user.logged) {
-          if (!this.click) {
-            return
+          if (this.restCount < 1) {
+            this.showNoPriseBox = true
+          } else {
+            if (!this.click) {
+              return
+            }
+            this.getOwnWiningInfo()
+            this.closeToast()
+            this.speed = 200
+            this.click = false
+            this.startRoll()
           }
-          this.getOwnWiningInfo()
-          this.closeToast()
-          this.speed = 200
-          this.click = false
-          this.startRoll()
         } else {
           this.showLoginBox = true
         }

+ 16 - 8
store/lottery.js

@@ -47,15 +47,23 @@ export const actions = {
     commit('lotteryInfo/REQUEST_CURRENT_GRADE_PRIZES')
     return axios.get('/lottery/user/prizes', {params})
       .then(res => {
-        if (res.data.data) {
-          resItems = res.data
-          for (let i = 0; i < resItems.data.length; i++) {
-            resItems.data[i].$index = i
-            resItems.code = 200
-            resItems.success = true
-          }
-          commit('lotteryInfo/GET_CURRENT_GRADE_PRIZES_SUCCESS', resItems)
+        // if (res.data.data) {
+        //   resItems = res.data
+        //   for (let i = 0; i < resItems.data.length; i++) {
+        //     resItems.data[i].$index = i
+        //     resItems.code = 200
+        //     resItems.success = true
+        //   }
+        //   console.log(resItems, 'resItems')
+        //   commit('lotteryInfo/GET_CURRENT_GRADE_PRIZES_SUCCESS', resItems)
+        // }
+        resItems = res.data
+        for (let i = 0; i < resItems.data.length; i++) {
+          resItems.data[i].$index = i
+          resItems.code = 200
+          resItems.success = true
         }
+        commit('lotteryInfo/GET_CURRENT_GRADE_PRIZES_SUCCESS', resItems)
       }, err => {
         commit('lotteryInfo/GET_CURRENT_GRADE_PRIZES_FAILURE', err)
       })