lilei před 4 roky
rodič
revize
7178dcf535
3 změnil soubory, kde provedl 47 přidání a 17 odebrání
  1. 15 1
      api/luckyDraw.js
  2. 10 5
      pages/index/index.vue
  3. 22 11
      pagesA/luckDraw/luckDraw.vue

+ 15 - 1
api/luckyDraw.js

@@ -1,8 +1,22 @@
 import axios from '@/libs/axios.js';
-// 获取网点下的服务项目
+// 获取是否有转盘
 export const findEnable = params => {
   return axios.request({
     url: `luckyDraw/findEnable`,
     method: 'get',
   })
+};
+// 获取免费抽奖次数
+export const findCustomerTimes = params => {
+  return axios.request({
+    url: `luckyDrawCust/findCustomerTimes/${params.id}`,
+    method: 'get',
+  })
+};
+// 获取任务列表
+export const findCustomerTask = params => {
+  return axios.request({
+    url: `luckyDrawCust/findCustomerTask/${params.id}`,
+    method: 'get',
+  })
 };

+ 10 - 5
pages/index/index.vue

@@ -83,7 +83,7 @@
 		deleteGoodsFormCart,
 		updateGoodsBuyQty
 	} from '@/api/shoppingCart.js'
-	import {findEnable} from '@/api/luckyDraw.js'
+	import {findEnable,findCustomerTimes} from '@/api/luckyDraw.js'
 	import {bannerList} from '@/api/banner.js'
 	import {getLookUpDatas,openDevice} from '@/api/data.js'
 	import {stationList} from '@/api/station.js'
@@ -103,6 +103,8 @@
 		onLoad() {
 			// 检查更新
 			this.checkUpdate()
+			// 判断是否有抽奖活动
+			this.getLuckDraw()
 			// 查询购物车列表
 			this.getCartList()
 			// 刷新购物车列表
@@ -139,8 +141,6 @@
 		onShow() {
 			// 获取订单状态数据字典
 			// this.getCodeList('RUBBISH_TYPE','vuex_rubbishType')
-			// 判断是否有抽奖活动
-			this.getLuckDraw()
 			// 获取顶部轮播图
 			this.getbannerList()
 			//  获取经纬度
@@ -188,10 +188,15 @@
 				findEnable().then(res => {
 					if(res.status == 200 && res.data){
 						this.$u.vuex('vuex_LuckDraw',res.data)
-						this.showLottery = true
+						findCustomerTimes({id:this.luckDraw.luckyDrawNo}).then(res => {
+							let reTimes = 0
+							if(res.status == 200){
+								reTimes = res.data.timesSurplus || 0
+							}
+							this.showLottery = reTimes > 0
+						})
 					}else{
 						this.$u.vuex('vuex_LuckDraw',null)
-						this.showLottery = false
 					}
 				})
 			},

+ 22 - 11
pagesA/luckDraw/luckDraw.vue

@@ -55,7 +55,7 @@
 				<view class="guize">
 					<view>
 						<text>1.活动时间:</text>
-						<text>{{luckDraw.activeStartTime}} 至 {{luckDraw.activeEndTime}}</text>
+						<text>{{startDate}} 至 {{endDate}}</text>
 					</view>
 					<view>
 						<text>2.奖品:</text>
@@ -66,13 +66,13 @@
 						</view>
 					</view>
 					<view><text>3.抽奖条件:</text></view>
-					<view>
+					<view style="flex-direction: column;">
 						<view v-for="(item,index) in activeLimitDesc" :key="index">
 							{{item}}
 						</view>
 					</view>
 					<view><text>4.抽奖说明:</text></view>
-					<view>
+					<view style="flex-direction: column;">
 						<view v-for="(item,index) in activeDesc" :key="index">
 							{{item}}
 						</view>
@@ -136,20 +136,27 @@
 <script>
 import AlmostLottery from '@/components/almost-lottery/almost-lottery.vue';
 import { clearCacheFile } from '@/almost-utils/almost-utils.js';
+import { findCustomerTimes } from '@/api/luckyDraw.js'
 export default {
 	name: 'Home',
 	components: {
 		AlmostLottery,
 	},
 	computed: {
+		startDate(){
+			return this.luckDraw?this.luckDraw.activeStartTime.split(' ')[0]:'-'
+		},
+		endDate(){
+			return this.luckDraw?this.luckDraw.activeEndTime.split(' ')[0]:'-'
+		},
 		prizeDesc() {
-			return this.luckDraw.prizeDesc.split('\n')
+			return this.luckDraw?this.luckDraw.prizeDesc.split('\n'):''
 		},
 		activeLimitDesc() {
-			return this.luckDraw.activeLimitDesc.split('\n')
+			return this.luckDraw?this.luckDraw.activeLimitDesc.split('\n'):''
 		},
 		activeDesc() {
-			return this.luckDraw.activeDesc.split('\n')
+			return this.luckDraw?this.luckDraw.activeDesc.split('\n'):''
 		}
 	},
 	data() {
@@ -247,8 +254,6 @@ export default {
 			});
 			
 			let res = await this.requestPrizeList();
-			console.log('获取奖品列表', res);
-
 			if (res.ok) {
 				let data = res.data;
 				if (data.length) {
@@ -290,9 +295,13 @@ export default {
 				}, 500);
 			});
 		},
-		// 获取配置
+		// 获取免费抽奖次数
 		getPrizeSetting(){
-			this.reTimes = 3
+			findCustomerTimes({id:this.luckDraw.luckyDrawNo}).then(res => {
+				if(res.status == 200){
+					this.reTimes = res.data.timesSurplus || 0
+				}
+			})
 		},
 		// 抽奖次数用完了
 		showPayWin(winTypes){
@@ -317,8 +326,9 @@ export default {
 				stoTimer = null;
 				// 这里随机产生的 prizeId 是模拟后端返回的 prizeId
 				let prizeId = Math.floor(Math.random() * list.length + 1);
+				console.log(prizeId)
 				list.forEach((item, index) => {
-					if (item.prizeId === prizeId) {
+					if (item.prizeId === ['210509167852392448','210509167852392449','210509167852392450'][prizeId]) {
 						// 中奖下标
 						this.prizeIndex = index;
 					}
@@ -333,6 +343,7 @@ export default {
 		// 本次抽奖结束
 		handleDrawEnd() {
 			let curPrize = this.prizeList[this.prizeIndex]
+			console.log(curPrize,'curPrize')
 			this.targetPrize = curPrize
 			// 旋转结束后,可以执行拿到结果后的逻辑
 			let prizeName = curPrize.name;