diff --git a/App.vue b/App.vue index 82fce54..a031b98 100644 --- a/App.vue +++ b/App.vue @@ -274,30 +274,32 @@ + - - setInterval(d => { //定时器,定时去调取聊天未读消息 - let userId = uni.getStorageSync('userId') - if (userId) { - this.$Request.getT('/app/message/selectMessageCount').then(res => { - if (res.code === 0) { - let num = res.data - uni.setStorageSync('numCount', num) - if (num == 0) { - uni.removeTabBarBadge({ - index: 3 - }) - } else { - uni.setTabBarBadge({ - index: 3, - text: num + '' - }) - } - } - }); - } - }, 3000); + // setInterval(d => { //定时器,定时去调取聊天未读消息 + // let userId = uni.getStorageSync('userId') + // if (userId) { + // this.$Request.getT('/app/message/selectMessageCount').then(res => { + // if (res.code === 0) { + // let num = res.data + // uni.setStorageSync('numCount', num) + // if (num == 0) { + // uni.removeTabBarBadge({ + // index: 3 + // }) + // } else { + // uni.setTabBarBadge({ + // index: 3, + // text: num + '' + // }) + // } + // } + // }); + // } + // }, 3000); + + //#ifdef H5 this.$u.get('/app/common/type/108').then(res => { //// 是否开启公众号自动登陆 108 diff --git a/me/choujiang/choujiang.vue b/me/choujiang/choujiang.vue index 66d96e3..6ca0d41 100644 --- a/me/choujiang/choujiang.vue +++ b/me/choujiang/choujiang.vue @@ -2,16 +2,10 @@ - - - - 红包余额:{{ goldCoin }} + 红包{{ totalMoney }} @@ -96,9 +90,13 @@ }, data() { return { + //红包余额 + totalMoney:0, + //抽奖结果 + result:'', // 开启调试模式 isDev: true, - option:{}, + option: {}, // 以下是转盘配置相关数据 lotteryConfig: { // 抽奖转盘的整体尺寸,单位rpx @@ -221,6 +219,7 @@ ok: true, data: res.data.records.map(v => { return { + ...v, prizeId: v.id, prizeName: v.name, prizeStock: 10, @@ -300,7 +299,7 @@ }, // 抽奖开始之前 async handleDrawBefore(callback) { - + console.log('抽奖开始之前') let flag = false @@ -312,7 +311,7 @@ flag = false uni.showModal({ title: '抽奖次数不足', - icon:'none' + icon: 'none' }) } @@ -411,62 +410,74 @@ // 远程请求接口获取中奖下标 // 大哥,这里只是模拟,别告诉我你不会对接自己的接口 async remoteGetPrizeIndex() { + this.result='' console.warn('###当前处于模拟的请求接口,并返回了中奖信息###') const res = await this.$Request.getT('app/discSpinning/draw', { orderId: this.option.orderId }) - if (res.code == 0) {} - return - // 模拟请求接口获取中奖信息 - let stoTimer = setTimeout(() => { - stoTimer = null + console.log(res); + if (res.code != 0) { + return uni.showToast({ + title: res.msg + }) + } + 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 - let prizeId = Math.floor(Math.random() * list.length + 1) - - // 拿到后端返回的 prizeId 后,开始循环比对得出那个中奖的数据 - for (let i = 0; i < list.length; i++) { - let item = list[i] - if (item.prizeId === prizeId) { - // 中奖下标 - this.prizeIndex = i - break - } + // 拿到后端返回的 prizeId 后,开始循环比对得出那个中奖的数据 + for (let i = 0; i < list.length; i++) { + let item = list[i] + if (item.prizeId === prizeId) { + // 中奖下标 + this.prizeIndex = i + break } - - console.log('本次抽中奖品 =>', this.prizeList[this.prizeIndex].prizeName) - - // 如果奖品设有库存 - if (this.onStock) { - console.log('本次奖品库存 =>', this.prizeList[this.prizeIndex].prizeStock) - } - }, 200) + } + console.log('本次抽中奖品 =>', this.prizeList[this.prizeIndex].prizeName) }, // 本次抽奖结束 handleDrawEnd() { console.log('旋转结束,执行拿到结果后到逻辑') - // 旋转结束后,开始处理拿到结果后的逻辑 - let prizeName = this.prizeList[this.prizeIndex].prizeName + // const prize = this.prizeList[this.prizeIndex] + const prize = this.result + let {name} = prize let tipContent = '' - if (prizeName === '谢谢参与') { + if (name.type ==1) { tipContent = '很遗憾,没有中奖,请再接再厉!' } else { - // 如果奖品设有库存 - if (this.onStock) { - let prizeStock = this.prizeList[this.prizeIndex].prizeStock - tipContent = prizeStock ? `恭喜您,获得 ${prizeName}` : `很抱歉,您来晚了,当前奖品 ${prizeName} 已无库存` - } else { - tipContent = `恭喜您,获得 ${prizeName} !` - } + tipContent = `恭喜您,获得 ${name}${this.result.type==2?(this.result.number+'元'):''} !` } - + const _this=this; uni.showModal({ content: tipContent, 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: () => { this.prizeing = false } @@ -487,17 +498,24 @@ stoTimer = null uni.hideLoading() - uni.showToast({ - title: res.msg, - mask: true, - icon: 'none' - }) + // uni.showToast({ + // title: res.msg, + // mask: true, + // icon: 'none' + // }) }, 50) + }, + async getRedPack(){ + const res=await this.$Request.getT('app/moneyDetails/selectUserMoney') + if(res.code==0){ + this.totalMoney=res.data.amount + } } }, onLoad(opt) { - this.option=opt + this.option = opt this.prizeList = [] + this.getRedPack() this.getPrizeList() }, onUnload() { diff --git a/me/gift/gift.vue b/me/gift/gift.vue index 6a7fd82..06c9307 100644 --- a/me/gift/gift.vue +++ b/me/gift/gift.vue @@ -4,7 +4,7 @@ - + 中奖时间 2024-09-11 10:20:11 @@ -20,10 +20,13 @@ + + + - - - + @@ -34,7 +37,9 @@ background: { backgroundColor: 'transparent' }, - status: 'nomore' + status: 'nomore', + hasAjax:true, + list:[] } }, methods: { @@ -42,7 +47,14 @@ uni.navigateTo({ url:'/me/gift/duihuan' }) + }, + init(){ + this.$Request.getT('app/discSpinningRecord/selectDiscSpinningRecord') } + }, + onShow() { + console.log('onShow'); + this.init() } }