抽奖增加领取
This commit is contained in:
44
App.vue
44
App.vue
@@ -277,27 +277,29 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
setInterval(d => { //定时器,定时去调取聊天未读消息
|
// setInterval(d => { //定时器,定时去调取聊天未读消息
|
||||||
let userId = uni.getStorageSync('userId')
|
// let userId = uni.getStorageSync('userId')
|
||||||
if (userId) {
|
// if (userId) {
|
||||||
this.$Request.getT('/app/message/selectMessageCount').then(res => {
|
// this.$Request.getT('/app/message/selectMessageCount').then(res => {
|
||||||
if (res.code === 0) {
|
// if (res.code === 0) {
|
||||||
let num = res.data
|
// let num = res.data
|
||||||
uni.setStorageSync('numCount', num)
|
// uni.setStorageSync('numCount', num)
|
||||||
if (num == 0) {
|
// if (num == 0) {
|
||||||
uni.removeTabBarBadge({
|
// uni.removeTabBarBadge({
|
||||||
index: 3
|
// index: 3
|
||||||
})
|
// })
|
||||||
} else {
|
// } else {
|
||||||
uni.setTabBarBadge({
|
// uni.setTabBarBadge({
|
||||||
index: 3,
|
// index: 3,
|
||||||
text: num + ''
|
// text: num + ''
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}, 3000);
|
// }, 3000);
|
||||||
|
|
||||||
|
|
||||||
//#ifdef H5
|
//#ifdef H5
|
||||||
|
|
||||||
this.$u.get('/app/common/type/108').then(res => { //// 是否开启公众号自动登陆 108
|
this.$u.get('/app/common/type/108').then(res => { //// 是否开启公众号自动登陆 108
|
||||||
|
|||||||
@@ -2,16 +2,10 @@
|
|||||||
<view class="almost-lottery">
|
<view class="almost-lottery">
|
||||||
<!-- head -->
|
<!-- head -->
|
||||||
<view class="almost-lottery__head">
|
<view class="almost-lottery__head">
|
||||||
|
|
||||||
|
|
||||||
<!-- <view :class="['action', isApple && 'action-shadow']">
|
|
||||||
<text class="gold"></text>
|
|
||||||
<text class="content">红包余额:<text class="num">{{ goldCoin }}</text></text>
|
|
||||||
</view> -->
|
|
||||||
<view class="btn-group u-flex u-row-between">
|
<view class="btn-group u-flex u-row-between">
|
||||||
<view :class="['action', isApple && 'action-shadow']">
|
<view :class="['action', isApple && 'action-shadow']">
|
||||||
<text class="pack"></text>
|
<text class="pack"></text>
|
||||||
<text class="content">红包余额:<text class="num">{{ goldCoin }}</text></text>
|
<text class="content">红包<text class="num">{{ totalMoney }}</text></text>
|
||||||
</view>
|
</view>
|
||||||
<view :class="['action', isApple && 'action-shadow']" @click="toGift">
|
<view :class="['action', isApple && 'action-shadow']" @click="toGift">
|
||||||
<text class="gift"></text>
|
<text class="gift"></text>
|
||||||
@@ -96,9 +90,13 @@
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
//红包余额
|
||||||
|
totalMoney:0,
|
||||||
|
//抽奖结果
|
||||||
|
result:'',
|
||||||
// 开启调试模式
|
// 开启调试模式
|
||||||
isDev: true,
|
isDev: true,
|
||||||
option:{},
|
option: {},
|
||||||
// 以下是转盘配置相关数据
|
// 以下是转盘配置相关数据
|
||||||
lotteryConfig: {
|
lotteryConfig: {
|
||||||
// 抽奖转盘的整体尺寸,单位rpx
|
// 抽奖转盘的整体尺寸,单位rpx
|
||||||
@@ -221,6 +219,7 @@
|
|||||||
ok: true,
|
ok: true,
|
||||||
data: res.data.records.map(v => {
|
data: res.data.records.map(v => {
|
||||||
return {
|
return {
|
||||||
|
...v,
|
||||||
prizeId: v.id,
|
prizeId: v.id,
|
||||||
prizeName: v.name,
|
prizeName: v.name,
|
||||||
prizeStock: 10,
|
prizeStock: 10,
|
||||||
@@ -312,7 +311,7 @@
|
|||||||
flag = false
|
flag = false
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '抽奖次数不足',
|
title: '抽奖次数不足',
|
||||||
icon:'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -411,62 +410,74 @@
|
|||||||
// 远程请求接口获取中奖下标
|
// 远程请求接口获取中奖下标
|
||||||
// 大哥,这里只是模拟,别告诉我你不会对接自己的接口
|
// 大哥,这里只是模拟,别告诉我你不会对接自己的接口
|
||||||
async remoteGetPrizeIndex() {
|
async remoteGetPrizeIndex() {
|
||||||
|
this.result=''
|
||||||
console.warn('###当前处于模拟的请求接口,并返回了中奖信息###')
|
console.warn('###当前处于模拟的请求接口,并返回了中奖信息###')
|
||||||
const res = await this.$Request.getT('app/discSpinning/draw', {
|
const res = await this.$Request.getT('app/discSpinning/draw', {
|
||||||
orderId: this.option.orderId
|
orderId: this.option.orderId
|
||||||
})
|
})
|
||||||
if (res.code == 0) {}
|
console.log(res);
|
||||||
return
|
if (res.code != 0) {
|
||||||
// 模拟请求接口获取中奖信息
|
return uni.showToast({
|
||||||
let stoTimer = setTimeout(() => {
|
title: res.msg
|
||||||
stoTimer = null
|
})
|
||||||
|
}
|
||||||
|
this.result=res.data
|
||||||
|
|
||||||
let list = [...this.prizeList]
|
let list = [...this.prizeList]
|
||||||
|
// 这里随机产生的 prizeId 是模拟后端返回的 prizeId
|
||||||
|
const arr=list.filter(v=>v.type==res.data.type)
|
||||||
|
let prizeId = arr[0].prizeId
|
||||||
|
|
||||||
// 这里随机产生的 prizeId 是模拟后端返回的 prizeId
|
// 拿到后端返回的 prizeId 后,开始循环比对得出那个中奖的数据
|
||||||
let prizeId = Math.floor(Math.random() * list.length + 1)
|
for (let i = 0; i < list.length; i++) {
|
||||||
|
let item = list[i]
|
||||||
// 拿到后端返回的 prizeId 后,开始循环比对得出那个中奖的数据
|
if (item.prizeId === prizeId) {
|
||||||
for (let i = 0; i < list.length; i++) {
|
// 中奖下标
|
||||||
let item = list[i]
|
this.prizeIndex = i
|
||||||
if (item.prizeId === prizeId) {
|
break
|
||||||
// 中奖下标
|
|
||||||
this.prizeIndex = i
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
console.log('本次抽中奖品 =>', this.prizeList[this.prizeIndex].prizeName)
|
console.log('本次抽中奖品 =>', this.prizeList[this.prizeIndex].prizeName)
|
||||||
|
|
||||||
// 如果奖品设有库存
|
|
||||||
if (this.onStock) {
|
|
||||||
console.log('本次奖品库存 =>', this.prizeList[this.prizeIndex].prizeStock)
|
|
||||||
}
|
|
||||||
}, 200)
|
|
||||||
},
|
},
|
||||||
// 本次抽奖结束
|
// 本次抽奖结束
|
||||||
handleDrawEnd() {
|
handleDrawEnd() {
|
||||||
console.log('旋转结束,执行拿到结果后到逻辑')
|
console.log('旋转结束,执行拿到结果后到逻辑')
|
||||||
|
|
||||||
// 旋转结束后,开始处理拿到结果后的逻辑
|
// 旋转结束后,开始处理拿到结果后的逻辑
|
||||||
let prizeName = this.prizeList[this.prizeIndex].prizeName
|
// const prize = this.prizeList[this.prizeIndex]
|
||||||
|
const prize = this.result
|
||||||
|
let {name} = prize
|
||||||
let tipContent = ''
|
let tipContent = ''
|
||||||
|
|
||||||
if (prizeName === '谢谢参与') {
|
if (name.type ==1) {
|
||||||
tipContent = '很遗憾,没有中奖,请再接再厉!'
|
tipContent = '很遗憾,没有中奖,请再接再厉!'
|
||||||
} else {
|
} else {
|
||||||
// 如果奖品设有库存
|
tipContent = `恭喜您,获得 ${name}${this.result.type==2?(this.result.number+'元'):''} !`
|
||||||
if (this.onStock) {
|
|
||||||
let prizeStock = this.prizeList[this.prizeIndex].prizeStock
|
|
||||||
tipContent = prizeStock ? `恭喜您,获得 ${prizeName}` : `很抱歉,您来晚了,当前奖品 ${prizeName} 已无库存`
|
|
||||||
} else {
|
|
||||||
tipContent = `恭喜您,获得 ${prizeName} !`
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
const _this=this;
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
content: tipContent,
|
content: tipContent,
|
||||||
showCancel: false,
|
showCancel: false,
|
||||||
|
success() {
|
||||||
|
const {
|
||||||
|
orderId,id
|
||||||
|
}=_this.result
|
||||||
|
_this.$Request.postJson('app/discSpinning/receive',_this.result).then(res=>{
|
||||||
|
_this.result=''
|
||||||
|
console.log(res)
|
||||||
|
if(res.code==0){
|
||||||
|
uni.showToast({
|
||||||
|
title: '领取成功',
|
||||||
|
icon:'none'
|
||||||
|
})
|
||||||
|
_this.getRedPack()
|
||||||
|
}else{
|
||||||
|
uni.showToast({
|
||||||
|
title: '领取失败',
|
||||||
|
icon:'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
complete: () => {
|
complete: () => {
|
||||||
this.prizeing = false
|
this.prizeing = false
|
||||||
}
|
}
|
||||||
@@ -487,17 +498,24 @@
|
|||||||
stoTimer = null
|
stoTimer = null
|
||||||
|
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
uni.showToast({
|
// uni.showToast({
|
||||||
title: res.msg,
|
// title: res.msg,
|
||||||
mask: true,
|
// mask: true,
|
||||||
icon: 'none'
|
// icon: 'none'
|
||||||
})
|
// })
|
||||||
}, 50)
|
}, 50)
|
||||||
|
},
|
||||||
|
async getRedPack(){
|
||||||
|
const res=await this.$Request.getT('app/moneyDetails/selectUserMoney')
|
||||||
|
if(res.code==0){
|
||||||
|
this.totalMoney=res.data.amount
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(opt) {
|
onLoad(opt) {
|
||||||
this.option=opt
|
this.option = opt
|
||||||
this.prizeList = []
|
this.prizeList = []
|
||||||
|
this.getRedPack()
|
||||||
this.getPrizeList()
|
this.getPrizeList()
|
||||||
},
|
},
|
||||||
onUnload() {
|
onUnload() {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<view class="gift-bg">
|
<view class="gift-bg">
|
||||||
</view>
|
</view>
|
||||||
<view class="list">
|
<view class="list">
|
||||||
<view class="item" v-for="(item,index) in 10" :key="index">
|
<view class="item" v-for="(item,index) in list" :key="index">
|
||||||
<view class="color-666 u-font-24">中奖时间 2024-09-11 10:20:11</view>
|
<view class="color-666 u-font-24">中奖时间 2024-09-11 10:20:11</view>
|
||||||
<view class="u-m-t-24 u-flex u-row-between">
|
<view class="u-m-t-24 u-flex u-row-between">
|
||||||
<view class="u-flex-1 u-flex u-col-top">
|
<view class="u-flex-1 u-flex u-col-top">
|
||||||
@@ -20,10 +20,13 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="u-p-t-30 u-p-b-30" v-if="hasAjax&&!list.length">
|
||||||
|
<u-empty text="暂无奖品"></u-empty>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="u-p-30">
|
<!-- <view class="u-p-30">
|
||||||
<u-loadmore :font-size="24" color="#999" :status="status" />
|
<u-loadmore font-size="24" color="#999" :status="status" />
|
||||||
</view>
|
</view> -->
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -34,7 +37,9 @@
|
|||||||
background: {
|
background: {
|
||||||
backgroundColor: 'transparent'
|
backgroundColor: 'transparent'
|
||||||
},
|
},
|
||||||
status: 'nomore'
|
status: 'nomore',
|
||||||
|
hasAjax:true,
|
||||||
|
list:[]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -42,7 +47,14 @@
|
|||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url:'/me/gift/duihuan'
|
url:'/me/gift/duihuan'
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
init(){
|
||||||
|
this.$Request.getT('app/discSpinningRecord/selectDiscSpinningRecord')
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
onShow() {
|
||||||
|
console.log('onShow');
|
||||||
|
this.init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user