Pārlūkot izejas kodu

大转盘功能,未完

yfape 2 gadi atpakaļ
vecāks
revīzija
5fa0da34cb
6 mainītis faili ar 173 papildinājumiem un 28 dzēšanām
  1. 29 0
      api/draw/index.js
  2. 4 2
      api/index.js
  3. 1 1
      manifest.json
  4. 126 18
      pages/goods/goods-lucky/index.vue
  5. 10 4
      pages/index/index.vue
  6. 3 3
      setting.js

+ 29 - 0
api/draw/index.js

xqd
@@ -0,0 +1,29 @@
+const request = uni.$u.http
+
+// 酒店列表
+export function drawRecord(data){
+	return request.post(
+		`v1/draw/drawRecord`,
+		data
+	)
+}
+// 酒店分类列表
+export function luckyDraw(data){
+	return request.post(
+		`v1/draw/luckyDraw`,
+		data
+	)
+}
+// 酒店详情
+export function drawInfo(data){
+	return request.post(
+		`v1/draw/drawInfo`,
+		data
+	)
+}
+
+export default {
+  drawRecord,
+  luckyDraw,
+  drawInfo
+}

+ 4 - 2
api/index.js

xqd xqd
@@ -13,7 +13,8 @@ import category from './category/category.js'
 import integral from './integral/integral.js'
 import product from './product/product.js'
 import lottery from './lottery/lottery.js'
-import orders from './orders/orders.js'
+import orders from './orders/orders.js'
+import draw from './draw'
 
 const api = {
 	user,
@@ -31,7 +32,8 @@ const api = {
 	integral,
 	product,
 	lottery,
-	orders
+	orders,
+	draw
 }
 
 export default api

+ 1 - 1
manifest.json

xqd
@@ -1,6 +1,6 @@
 {
     "name" : "hotel_uni",
-    "appid" : "__UNI__807A871",
+    "appid" : "__UNI__9140D70",
     "description" : "",
     "versionName" : "1.0.0",
     "versionCode" : "100",

+ 126 - 18
pages/goods/goods-lucky/index.vue

xqd xqd xqd xqd xqd
@@ -3,7 +3,7 @@
 		<!-- 转盘 -->
 		<view class="spinning" :style="{backgroundImage:'url('+backImageUrl+')'}">
 			<view class="spinning-title">
-				<text>幸运大转盘</text>
+				<text>{{drawInfo.draw_template.name?drawInfo.draw_template.name:"幸运大轮盘"}}</text>
 			</view>
 			<q-turntable ref="turntable" :areaNumber='9' @start="turntableStart" @success="turntableSuccess">
 			</q-turntable>
@@ -35,7 +35,7 @@
 						<text class="introduce-top-rule2"></text>
 					</view>
 					<view class="introduce-text">
-						<text>活动奖品分为线上和线下两种类型活动奖品分为线上和线下两种类型奖品活动奖品分为线上和线下两种类型奖品奖品,线上活动奖品分为线上和线下两种类型奖品,线上活动奖品分为线上和线下两种类型奖品,线上</text>
+						<text>{{drawInfo.draw_template.rule}}</text>
 					</view>
 				</view>
 			</view>
@@ -45,14 +45,14 @@
 				<view class="prize-title">
 					我的奖品
 				</view>
-				<view class="prize-main" v-for="item in 3">
+				<view class="prize-main" v-for="item in drawRecord" :key="item.id">
 					<view class="prize-main-left">
-						<text class="prize-main-left-top">HUAWEI MateBook X Pro</text>
-						<text class="prize-main-left-bom">2022-02-10</text>
+						<text class="prize-main-left-top">{{item.remark}}</text>
+						<text class="prize-main-left-bom">{{item.created_at}}</text>
 					</view>
-					<view :class="isexchange ? 'prize-main-rightSelect' : 'prize-main-right' ">
-						<text v-if="isexchange">立即兑换</text>
-						<text v-if="!isexchange">已兑换</text>
+					<view :class="item.status==1 ? 'prize-main-rightSelect' : 'prize-main-right' ">
+						<text v-if="item.status==1">立即兑换</text>
+						<text v-if="item.status==2">已兑换</text>
 					</view>
 				</view>
 			</view>
@@ -65,7 +65,7 @@
 				<view class="img">
 					<image style="width: 80rpx;height: 82rpx" src="/static/icon/gift01.png"></image>
 					<view class="text">
-						<text>恭喜您抽中了<text>{{prizeLevel}}</text></text>
+						<text>恭喜您抽中了<text>{{drawResult.name}}</text></text>
 						<text>请尽快去奖品中心兑奖</text>
 					</view>
 				</view>
@@ -136,30 +136,138 @@
 					{
 						title: '一等奖'
 					}
-				] // 顺时针对应每个奖项 
+				], // 顺时针对应每个奖项 
+				drawInfo:{
+					draw_no: ''
+				},
+				drawRecord:[],
+				drawResult:{}
 			}
+		},
+		onLoad(params){
+			const {draw_no} = params
+			this.drawInfo.draw_no = draw_no;
+			
+		},
+		onReady(){
+			// this.judageIsDraw(); //判断是否有权限访问
+			this.getDrawInfo();  //获取抽奖信息
+			this.getDrawRecord();	//获取获奖记录
+		},
+		computed:{
+			recordMsg:(status)=>{
+				const di = ['未中奖','未兑换','已兑换'];
+				return di[status];
+			}
 		},
-		methods: {
-			
+		methods: {
+			judageIsDraw(){
+				if(!this.drawInfo.draw_no){
+					uni.showToast({
+						icon: 'error',
+						title: "暂无权限",
+						success:()=>{
+							uni.reLaunch({
+								url:'/pages/index/index'
+							})
+						}
+					})
+				}
+			},
+			getDrawInfo(){
+				this.drawInfo.draw_no = "9HzqlNVBMRZo";
+				this.$api.draw.drawInfo({
+					draw_no: this.drawInfo.draw_no
+				}).then(res=>{
+					if(res.code == 0){
+						this.drawInfo = res.data;
+					}else{
+						uni.showToast({
+							icon: 'error',
+							title: res.msg ? res.msg : "暂无权限"
+						})
+					}
+				}).catch(err=>{
+					uni.showToast({
+						icon: 'error',
+						title: "网络繁忙"
+					})
+				})
+			},
+			getDrawRecord(page = 1){
+				if(page == 1){
+					this.drawRecord = []
+				}
+				this.$api.draw.drawRecord({
+					page:page
+				}).then(res=>{
+					if(res.code == 0){
+						res.data.data.forEach(item => {
+							if(item.source == 2){
+								this.drawRecord.push(item);	
+							}
+						})
+						if(res.data.length >= 15){
+							this.getDrawRecord(page + 1);
+						}
+					}
+				})
+			},
 			//中奖去兑换按钮
 			dialogConfirm() {
-				console.log('确认');
+				this.$utils.jump({
+					jump_type: 4,
+					jump_config: '/pages/my/prize/prize'
+				})
 			},
 			//中奖待会按钮
-			dialogClose() {
-				console.log('取消');
+			dialogClose() {
+				this.drawResult = {};
+				this.$refs.codePurchaseNone.close();
+				this.$refs.codePurchase.close();
 			},
 
 			// 用户点击开始抽奖
-			turntableStart() {
+			turntableStart() {
+				if(this.isDrawing) return;
+				this.isDrawing = true
 				let index = Math.floor(Math.random() * 6 + 1) //前端随机数,这里应该后台返回中奖结果
 				// this.award = index
 				this.award = 2
-				this.$refs.turntable.begin(this.award);
+				this.$refs.turntable.begin(this.award);
+				this.$api.draw.luckyDraw({
+					draw_no: this.drawInfo.draw_no,
+				}).then(res => {
+					if(res.data.code != 0){
+						uni.showToast({
+							icon: 'error',
+							title: res.msg?res.msg:"网络繁忙",
+						})
+						return;
+					}
+					this.drawResult = res.data;
+					setTimeout(()=>{
+						this.isDrawing = false
+					}, 1000)
+				});
 			},
 
 			// 抽奖完成后操作
-			turntableSuccess() {
+			turntableSuccess() {
+				let timer = setInterval(()=>{
+					if(this.isDrawing){
+						return;
+					}
+					
+					if(this.drawResult.status == 1){
+						this.$refs.codePurchase.open()
+					}else{
+						this.$refs.codePurchaseNone.open()
+					}
+					clearInterval(timer);
+				}, 50)
+				return;
+				
 				const index = this.award - 1;
 				console.log('bind:success', this.awardList[index]);
 				if(this.awardList[index].title == '谢谢参与'){

+ 10 - 4
pages/index/index.vue

xqd xqd
@@ -76,8 +76,8 @@
 			<view class="home-banner-img" v-if="in_page==1 && type == 1 ">
 				<image style="width: 100%; height: 576rpx; border-radius: 12rpx;" :src="advData.img" mode="" 
 				@click="$utils.jump({
-					jump_type: item.jump_type,
-					jump_config: item.jump_config
+					jump_type: advData.jump_type,
+					jump_config: advData.jump_config
 				})"></image>
 				<image @click="cleanCoverImg" class="img-clean" style="width: 20rpx; height: 20rpx; "
 					src="/static/icon/clean.png" mode="">
@@ -318,9 +318,15 @@
 		onLoad() {
 			this.getGoodsList()
 			this.getAllSet()
-			this.isDevelopment = process.env.NODE_ENV === 'development';
+			// this.isDevelopment = process.env.NODE_ENV === 'development';
+			this.isDevelopment = true;
 			//用户访问
-			this.getUserVisits()
+			this.getUserVisits()
+			
+			uni.navigateTo({
+				url: "/pages/goods/goods-lucky/index"
+			})
+			
 		},
 		methods: {
 			// **************** Data ***************//

+ 3 - 3
setting.js

xqd
@@ -1,9 +1,9 @@
 /**
  * Created by JianJia.Zhou<jianjia.zhou> on 2022/3/18.
  */
-const IS_DEV = process.env.NODE_ENV === 'development1'
-// const URL = 'https://t9.9026.com'
-const URL = 'https://ihg.9026.com'
+const IS_DEV = process.env.NODE_ENV === 'development'
+const URL = 'https://t9.9026.com'
+// const URL = 'https://ihg.9026.com'
 
 module.exports = {
   // 版本