Fix(抽奖):[#972]抽奖抽中优惠券,优惠券直接自动领取并保存在优惠券卡包,不需要再通过抽奖记录进行领取

This commit is contained in:
lifizer
2024-03-02 12:52:11 +08:00
parent 427cc7053b
commit 882296007b
2 changed files with 62 additions and 28 deletions
+50 -26
View File
@@ -1,35 +1,48 @@
<template> <template>
<view class="pkg-lottery-log" v-if="ready"> <view class="pkg-lottery-log">
<image style="width: 734rpx;height: 1418rpx" :src="webUrl+'/20240125215943273915.png'" mode="scaleToFill"/> <image
:src="webUrl+'/20240125215943273915.png'"
mode="scaleToFill"
style="width: 734rpx;height: 1418rpx"
/>
<view class="th flex"> <view class="th flex">
<view>日期</view> <view>日期</view>
<view style="margin-left: 168rpx;">抽奖结果</view> <view style="margin-left: 168rpx;">抽奖结果</view>
</view> </view>
<scroll-view
<scroll-view class="list-box" scroll-y @scrolltolower="onBottom"> scroll-y
<view class="item flex jc-between ai-center" v-for="(item,index) in list" :key="index"> class="list-box"
@scrolltolower="onBottom"
>
<view
v-for="(item, index) in list"
:key="index"
class="item flex jc-between ai-center"
>
<view class="flex ai-center"> <view class="flex ai-center">
<view style="width: 288rpx;color:#BD2323;font-size: 28rpx">{{ item['drawTime'] }}</view> <view style="width: 288rpx;color:#BD2323;font-size: 28rpx">{{ item['drawTime'] }}</view>
<view class="more-t">{{ item['prizeName'] }}</view> <view class="more-t">{{ item['prizeName'] }}</view>
</view> </view>
<image
<image class="flex-0" style="width: 111rpx;height: 64rpx" :src="webUrl+'/20240124232010456109.png'" v-if="item['isHit'] === 1 && item['status'] === 1"
mode="scaleToFill" v-if="item['isHit']===1 && item['status']===1" @click="takeItem(item)"/> :src="webUrl+'/20240124232010456109.png'"
class="flex-0"
style="width: 111rpx;height: 64rpx"
mode="scaleToFill"
@click="takeItem(item, index)"
/>
</view> </view>
</scroll-view> </scroll-view>
</view> </view>
</template> </template>
<script> <script>
import {getLogs, takePrize} from "@/api/lottery"; import {getLogs, takePrize} from "@/api/lottery";
export default { export default {
data() { data() {
return { return {
webUrl: this.$VUE_APP_RESOURCES_URL, webUrl: this.$VUE_APP_RESOURCES_URL,
ready: false, loading: false,
page: 1, page: 1,
list: [] list: []
} }
@@ -40,30 +53,44 @@ export default {
this.fetchList() this.fetchList()
}, },
methods: { methods: {
async fetchList() { fetchList() {
const res = await getLogs(this.page, 20) this.loading = true
if (res.success) { getLogs(this.page, 20).then(res => {
res.data['records']?.forEach(item => this.list.push(item)) const { success, data } = res
this.ready = true if (success) {
} if (data) {
if (data.records) {
data.records.map(item => {
this.list.push(item)
})
}
}
}
this.loading = false
}).catch(() => {
this.loading = false
}).finally(() => {
this.loading = false
})
}, },
onBottom() { onBottom() {
if (this.loading) {
return
}
this.page++ this.page++
this.fetchList() this.fetchList()
}, },
async takeItem(item) {
async takeItem (item) { // 领取商品
if (item['prizeType'] === 1 && item['status'] === 1) { if (item['prizeType'] === 1 && item['status'] === 1) {
uni.navigateTo({ uni.navigateTo({
url: '/pages/order/OrderSubmission/index?lotteryRecordId=' + item['id'] url: '/pages/order/OrderSubmission/index?lotteryRecordId=' + item['id']
}) })
return return
} }
const res = await takePrize(item.id) const res = await takePrize(item.id)
if (res.success) { if (res.success) {
item['status'] = 2 this.$set(this.list[index], 'status', 2)
uni.showModal({ uni.showModal({
title: '领取成功', title: '领取成功',
content: '您的奖品已经领取成功,请前往我的订单查看奖品发货信息', content: '您的奖品已经领取成功,请前往我的订单查看奖品发货信息',
@@ -84,9 +111,6 @@ export default {
} }
} }
} }
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
+12 -2
View File
@@ -25,8 +25,15 @@
获得{{ diceResult['prizeName'] }}一份 获得{{ diceResult['prizeName'] }}一份
</view> </view>
</view> </view>
<image class="btn-result" style="width: 240rpx;height: 68rpx" :src="webUrl+'/20240125205521152611.png'" <!-- fix bug#972: 抽奖抽中优惠券优惠券直接自动领取并保存在优惠券卡包不需要再通过抽奖记录进行领取 -->
mode="scaleToFill" @click="closeResultModel" v-if="diceResult['isHit']!==0"/> <image
v-if="diceResult['isHit'] === 1 && diceResult.prizeType !== 3"
:src="webUrl+'/20240125205521152611.png'"
class="btn-result"
style="width: 240rpx;height: 68rpx"
mode="scaleToFill"
@click="closeResultModel"
/>
</view> </view>
<view class="dialog-take flex jc-center" :style="{'backgroundImage':`url(${webUrl}/20240124210904824337.png)`}" <view class="dialog-take flex jc-center" :style="{'backgroundImage':`url(${webUrl}/20240124210904824337.png)`}"
@@ -90,6 +97,7 @@ export default {
}, },
diceImg: '', diceImg: '',
diceResult: { diceResult: {
prizeType: '', // 1-商城商品,2-积分,3-优惠券,4-谢谢参与
prizeName: '', prizeName: '',
prizeImage: '', prizeImage: '',
diceImage: '', diceImage: '',
@@ -174,11 +182,13 @@ export default {
}, },
closeResultModel() { closeResultModel() {
// 谢谢参与
if (this.diceResult['prizeType'] === 4) { if (this.diceResult['prizeType'] === 4) {
this.showResult = false this.showResult = false
this.showDialog = false this.showDialog = false
return return
} }
// 领取商品
if (this.diceResult['prizeType'] === 1) { if (this.diceResult['prizeType'] === 1) {
this.showResult = false this.showResult = false
this.showDialog = false this.showDialog = false