Browse Source

抽奖活动

huangb 7 years ago
parent
commit
74d287701b
3 changed files with 102 additions and 35 deletions
  1. 93 30
      components/lotteryDraw/lottery.vue
  2. 1 1
      nuxt.config.js
  3. 8 4
      store/lottery.js

+ 93 - 30
components/lotteryDraw/lottery.vue

@@ -15,16 +15,40 @@
         <div class="high_level">
           <img :src="nextLevel.nextItem.name === '黄金' ? '/images/lottery/level-020.png' : nextLevel.nextItem.name === '钻石' ? '/images/lottery/level-030.png' : '/images/lottery/level-040.png'" alt=""/>
         </div>
-        <div class="progress_bar">
+        <div class="progress_bar" v-show="this.user.itemName === '青铜'">
           <div class="buyer_inquiry inquiry">
             <el-progress :text-inside="true" :stroke-width="15" :percentage="inquiryRate"></el-progress>
             <span class="all_count"><span v-text="buyerInquiryCount"></span>条询价</span>
-            <div class="tip_text"><img src="/images/lottery/update.png" alt=""/>买家再增加<span v-text="activityInquiryCount"></span>条报价,便可升级黄金用户</div>
+            <div class="tip_text"><img src="/images/lottery/update.png" alt=""/>买家再增加<span v-text="activityInquiryCount"></span>条报价,便可升级{{this.nextLevel.nextItem.name}}用户</div>
           </div>
           <div class="vendor_inquiry inquiry">
             <el-progress :text-inside="true" :stroke-width="15" :percentage="replyRate"></el-progress>
             <span class="all_count"><span v-text="vendorInquiryCount"></span>条询价</span>
-            <div class="tip_text"><img src="/images/lottery/update.png" alt=""/>卖家再增加<span v-text="activityReplyCount"></span>条报价,便可升级黄金用户</div>
+            <div class="tip_text"><img src="/images/lottery/update.png" alt=""/>卖家再增加<span v-text="activityReplyCount"></span>条报价,便可升级{{this.nextLevel.nextItem.name}}用户</div>
+          </div>
+        </div>
+        <div class="progress_bar" v-show="this.user.itemName === '黄金'">
+          <div class="buyer_inquiry inquiry" v-if="this.user.role === 'CUSTOMER'">
+            <el-progress :text-inside="true" :stroke-width="15" :percentage="inquiryRate"></el-progress>
+            <span class="all_count"><span v-text="buyerInquiryCount"></span>条询价</span>
+            <div class="tip_text"><img src="/images/lottery/update.png" alt=""/>买家再增加<span v-text="activityInquiryCount"></span>条报价,便可升级{{this.nextLevel.nextItem.name}}用户</div>
+          </div>
+          <div class="vendor_inquiry inquiry" v-if="this.user.role === 'SELLER'">
+            <el-progress :text-inside="true" :stroke-width="15" :percentage="replyRate"></el-progress>
+            <span class="all_count"><span v-text="vendorInquiryCount"></span>条询价</span>
+            <div class="tip_text"><img src="/images/lottery/update.png" alt=""/>卖家再增加<span v-text="activityReplyCount"></span>条报价,便可升级{{this.nextLevel.nextItem.name}}用户</div>
+          </div>
+        </div>
+        <div class="progress_bar" v-show="this.user.itemName === '钻石' && this.user.role === 'CUSTOMER'">
+          <div class="buyer_inquiry inquiry">
+            <el-progress :text-inside="true" :stroke-width="15" :percentage="inquiryRate"></el-progress>
+            <span class="all_count"><span v-text="buyerInquiryCount"></span>条询价</span>
+            <div class="tip_text"><img src="/images/lottery/update.png" alt=""/>买家再增加<span v-text="activityInquiryCount"></span>条报价,便可升级{{this.nextLevel.nextItem.name}}用户</div>
+          </div>
+          <div class="buyer_trad inquiry">
+            <el-progress :text-inside="true" :stroke-width="15" :percentage="tradeRate"></el-progress>
+            <span class="all_count"><span v-text="buyerTradeCount"></span>元</span>
+            <div class="tip_text"><img src="/images/lottery/update.png" alt=""/>买家再增加<span v-text="activityTradeCount"></span>元交易额,便可升级{{this.nextLevel.nextItem.name}}用户</div>
           </div>
         </div>
       </div>
@@ -237,16 +261,20 @@
         scrollTimerIndex: 0,
         isTop: false,
         selectLevelIndex: 0,
-        // 青铜询价
+        // 询价
         buyerInquiryCount: 0,
         activityInquiryCount: 0,
         inquiryRate: 0,
-        // 青铜回复
+        // 回复
         vendorInquiryCount: 0,
         activityReplyCount: 0,
         replyRate: 0,
         thirdPrize: {},
         sevenPrize: {},
+        // 钻石交易
+        buyerTradeCount: 0,
+        activityTradeCount: 0,
+        tradeRate: 0,
         restCount: 0,
         pCode: '',
         gotIndexItem: 0
@@ -263,20 +291,22 @@
     },
     computed: {
       user () {
+        console.log(this.$store.state.lottery.lotteryInfo.userInfo.data.data, 'user')
         return this.$store.state.lottery.lotteryInfo.userInfo.data ? this.$store.state.lottery.lotteryInfo.userInfo.data.data : []
       },
       nextLevel () {
+        console.log(this.$store.state.lottery.lotteryInfo.nextLevel.data.data, 'next')
         return this.$store.state.lottery.lotteryInfo.nextLevel.data ? this.$store.state.lottery.lotteryInfo.nextLevel.data.data : []
       },
       recordData () {
-        console.log(this.$store.state.lottery.lotteryInfo.record.data.data, 'recordData')
         return this.$store.state.lottery.lotteryInfo.record.data ? this.$store.state.lottery.lotteryInfo.record.data.data : []
       },
       ownRecordData () {
         return this.$store.state.lottery.lotteryInfo.ownRecord.data ? this.$store.state.lottery.lotteryInfo.ownRecord.data : []
       },
       currentPrizes () {
-        return this.$store.state.lottery.lotteryInfo.prizes.data ? this.$store.state.lottery.lotteryInfo.prizes.data : []
+        console.log(this.$store.state.lottery.lotteryInfo.prizes.data, 'current')
+        return this.$store.state.lottery.lotteryInfo.prizes.data ? this.$store.state.lottery.lotteryInfo.prizes.data.data : []
       },
       currentPrize () {
         return this.currentPrizes.slice(4,7).reverse()
@@ -308,15 +338,41 @@
       getLevel () {
         this.nextLevel.currentItem.activityItemDetails.forEach(item => {
           let percent = Number(100)
-          if (item.type === 'CUSTOMER_UPGRADE') {
+          if (item.type === 'CUSTOMER_UPGRADE' && this.user.itemName === '青铜') {
+            this.buyerInquiryCount = item.amount
+            this.activityInquiryCount =  this.buyerInquiryCount - this.user.activityInquiryCount
+            let inquiry = (percent - ((this.activityInquiryCount / this.buyerInquiryCount) * 100)).toFixed(0)
+            this.inquiryRate = Number(inquiry)
+          }
+          if (item.type === 'SELLER_UPGRADE' && this.user.itemName === '青铜') {
+            this.vendorInquiryCount = item.amount
+            this.activityReplyCount =  this.vendorInquiryCount - this.user.activityReplyCount
+            let replay = (percent - ((this.activityReplyCount / this.vendorInquiryCount) * 100)).toFixed(0)
+            this.replyRate = Number(replay)
+          }
+          if (this.user.role === 'CUSTOMER' && item.type === 'CUSTOMER_UPGRADE' && this.user.itemName === '黄金') {
             this.buyerInquiryCount = item.amount
-            this.activityInquiryCount =  (this.buyerInquiryCount - this.user.activityInquiryCount)
-            this.inquiryRate = percent - (this.activityInquiryCount / this.buyerInquiryCount) * 100
+            this.activityInquiryCount =  this.buyerInquiryCount - this.user.itemCount
+            let inquiry = (percent - ((this.activityInquiryCount / this.buyerInquiryCount) * 100)).toFixed(0)
+            this.inquiryRate = Number(inquiry)
           }
-          if (item.type === 'SELLER_UPGRADE') {
+          if (this.user.role === 'SELLER' && item.type === 'SELLER_UPGRADE' && this.user.itemName === '黄金') {
             this.vendorInquiryCount = item.amount
-            this.activityReplyCount =  (this.vendorInquiryCount - this.user.activityReplyCount)
-            this.replyRate = percent - (this.activityReplyCount / this.vendorInquiryCount) * 100
+            this.activityReplyCount =  this.vendorInquiryCount - this.user.itemCount
+            let replay = (percent - ((this.activityReplyCount / this.vendorInquiryCount) * 100)).toFixed(0)
+            this.replyRate = Number(replay)
+          }
+          if (this.user.role === 'CUSTOMER' && item.type === 'CUSTOMER_UPGRADE' && item.resource === 'INQUIRY' && this.user.itemName === '钻石') {
+            this.buyerInquiryCount = item.amount
+            this.activityInquiryCount =  this.buyerInquiryCount - this.user.itemCount
+            let inquiry = (percent - ((this.activityInquiryCount / this.buyerInquiryCount) * 100)).toFixed(0)
+            this.inquiryRate = Number(inquiry)
+          }
+          if (this.user.role === 'CUSTOMER' && item.type === 'CUSTOMER_UPGRADE' && item.resource === 'TRADE_AMOUNT' && this.user.itemName === '钻石') {
+            this.buyerTradeCount = item.amount
+            this.activityTradeCount =  this.buyerTradeCount - this.user.activityTradeCount
+            let trad = (percent - ((this.activityTradeCount / this.buyerTradeCount) * 100)).toFixed(3)
+            this.tradeRate = Number(trad)
           }
         })
       },
@@ -343,19 +399,23 @@
       },
       // 切换等级
       toggleLevel (item) {
-        console.log(item)
-        this.pCode = item.itemCode
-        this.restCount = item.drawnCount
-        if (code) {
-          this.$http.get('/lottery//user/prizes', {params: {activityCode: '11wwwwwwww', itemCode: this.pCode}})
-            .then(res => {
-              this.$store.commit('lottery/lotteryInfo/GET_CURRENT_GRADE_PRIZES_SUCCESS', res.data)
-              setTimeout( () => {
-                this.getDetail()
-              }, 0)
-            }, err => {
-              this.$store.commit('lottery/lotteryInfo/GET_CURRENT_GRADE_PRIZES_FAILURE', err)
-            })
+        console.log(item, 'item')
+        if (item.itemName === '钻石') {
+          this.$message.info('钻石等级暂不能自主抽奖')
+        } else {
+          this.pCode = item.itemCode
+          this.restCount = item.lotteryCount
+          if (this.pCode) {
+            this.$http.get('/lottery//user/prizes', {params: {activityCode: '11wwwwwwww', itemCode: this.pCode}})
+              .then(res => {
+                this.$store.commit('lottery/lotteryInfo/GET_CURRENT_GRADE_PRIZES_SUCCESS', res.data)
+                setTimeout( () => {
+                  this.getDetail()
+                }, 0)
+              }, err => {
+                this.$store.commit('lottery/lotteryInfo/GET_CURRENT_GRADE_PRIZES_FAILURE', err)
+              })
+          }
         }
       },
       // 查看我的奖品
@@ -432,12 +492,17 @@
       },
       // 我的奖品
       scrollInterval (flag) {
+        // let _arr = {}
+        // _arr = this.recordData
         if (flag && this.recordData.length > 5) {
           this.scrollTimer = setInterval(() => {
             this.scrollTimerIndex ++
             this.isTop = (this.scrollTimerIndex % 45 === 0)
             if (this.isTop) {
               this.scrollTimerIndex = 0
+              // for (let i = 0; i < this.recordData; i++) {
+              //   _arr.push(this.recordData.pop())
+              // }
             }
           }, 3000)
         } else {
@@ -563,7 +628,7 @@
               text-align: left;
             }
           }
-          .vendor_inquiry{
+          .vendor_inquiry, .buyer_trad{
             margin-top: 60px;
           }
         }
@@ -600,9 +665,7 @@
               background-color: #fdd557;
               border-radius: 15px;
               cursor: pointer;
-              &:first-child{
-                margin-right: 16px;
-              }
+              margin-right: 16px;
               &:hover, &.active{
                 background-color: #ff9000;
               }

+ 1 - 1
nuxt.config.js

@@ -1,7 +1,7 @@
 const path = require('path')
 const isProdMode = Object.is(process.env.NODE_ENV, 'production')
 // b2c后台
-const baseUrl = process.env.BASE_URL || (isProdMode ? 'http://api.usoftmall.com/' : 'http://10.1.51.79:8080/')
+const baseUrl = process.env.BASE_URL || (isProdMode ? 'http://api.usoftmall.com/' : 'http://192.168.253.3:36006/')
 // 公共询价
 const commonUrl = process.env.COMMON_URL || (isProdMode ? 'https://api-inquiry.usoftmall.com/' : 'http://218.17.158.219:24000/')
 // 公共物料

+ 8 - 4
store/lottery.js

@@ -47,11 +47,15 @@ export const actions = {
     commit('lotteryInfo/REQUEST_CURRENT_GRADE_PRIZES')
     return axios.get('/lottery/user/prizes', {params})
       .then(res => {
-        resItems = res.data.data
-        for (let i = 0; i < resItems.length; i++) {
-          resItems[i].$index = i
+        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)
         }
-        commit('lotteryInfo/GET_CURRENT_GRADE_PRIZES_SUCCESS', resItems)
       }, err => {
         commit('lotteryInfo/GET_CURRENT_GRADE_PRIZES_FAILURE', err)
       })