添加排名奖励

This commit is contained in:
xiaoaojiao
2025-09-23 19:33:14 +08:00
parent 1a8a9d9fd4
commit 2ee6172498
3 changed files with 47 additions and 8 deletions

View File

@@ -22,6 +22,7 @@ const videoLoaded = ref(false);
const videoError = ref(false); const videoError = ref(false);
const lotteryShow = ref(false) const lotteryShow = ref(false)
const lotteryType = ref("draw") const lotteryType = ref("draw")
const lotteryNoticeData = ref(null)
// 初始化全局音频实例 // 初始化全局音频实例
const initGlobalAudio = () => { const initGlobalAudio = () => {
@@ -228,6 +229,8 @@ const handleLottery = () => {
if (globalStore.draw_chances <= 0) { if (globalStore.draw_chances <= 0) {
return weui.alert("还没有抽奖机会,快去参加活动吧") return weui.alert("还没有抽奖机会,快去参加活动吧")
}; };
lotteryType.value = 'draw'
lotteryNoticeData.value = null
globalToastEvent.emit(ToastType.SHOW_LOTTERY) globalToastEvent.emit(ToastType.SHOW_LOTTERY)
} }
@@ -307,12 +310,20 @@ const initUserGameInfos = async (refresh_official, refresh_cap_scan) => {
globalToastEvent.emit(ToastType.MOUNTED) globalToastEvent.emit(ToastType.MOUNTED)
} }
} }
const getNotice = async () => {
const result = await Request('notice/latest', {}, "GET")
if (result.json.notification) {
lotteryType.value = 'notice'
lotteryNoticeData.value = result.json.notification
lotteryShow.value = true
}
}
const handleLoginSuccess = async () => { const handleLoginSuccess = async () => {
console.log("已登录") console.log("已登录")
loginShow.value = false loginShow.value = false
await initUserGameInfos(true, true) await initUserGameInfos(true, true)
await getNotice()
} }
if (isLogin()) { if (isLogin()) {
@@ -413,7 +424,7 @@ globalToastEvent.on(ToastType.SHOW_LOTTERY, async() => {
<MyPhoto @go-photo-square="showPhotoSquare" v-model:show="isMyPhotoVisible" /> <MyPhoto @go-photo-square="showPhotoSquare" v-model:show="isMyPhotoVisible" />
<PhotoSquare @go-my-photo="showMyPhoto" v-model:show="isPhotoSquareVisible" /> <PhotoSquare @go-my-photo="showMyPhoto" v-model:show="isPhotoSquareVisible" />
<Login :show="loginShow" @login-success="handleLoginSuccess" /> <Login :show="loginShow" @login-success="handleLoginSuccess" />
<Lottery :show="lotteryShow" @close="lotteryShow = false" :type="lotteryType"></Lottery> <Lottery :show="lotteryShow" @close="lotteryShow = false" :type="lotteryType" :data="lotteryNoticeData"></Lottery>
</template> </template>
<style scoped> <style scoped>

View File

@@ -8,9 +8,12 @@
<div class="lottery-prize"> <div class="lottery-prize">
<div class="lottery-title" :class="props.type === 'notice' && 'notice'" ref="titleRef" <div class="lottery-title" :class="props.type === 'notice' && 'notice'" ref="titleRef"
v-show="activePrizeData.prize_code !== 'NO'"></div> v-show="activePrizeData.prize_code !== 'NO'"></div>
<div class="lottery-desc" v-show="props.type === 'notice'">在刚刚结束的打榜活动中成功斩获<br /><strong>[30]</strong></div> <div class="lottery-desc" v-show="props.type === 'notice'">
在刚刚结束的打榜活动中成功斩获<br /><strong>[{{ activePrizeData.rank }}]</strong>
</div>
<div class="lottery-image" :class="'USER_' + activePrizeData.prize_code" ref="lotteryImageRef"></div> <div class="lottery-image" :class="'USER_' + activePrizeData.prize_code" ref="lotteryImageRef"></div>
<div class="lottery-name" v-show="activePrizeData.prize_code !== 'NO'">{{ activePrizeData.prize_name }}</div> <div class="lottery-name" v-show="activePrizeData.prize_code !== 'NO'">{{ activePrizeData.prize_name }}
</div>
<div class="lottery-btngroup" v-show="btngroupShow"> <div class="lottery-btngroup" v-show="btngroupShow">
<div class="btn-more" @click="handleBtnMore"></div> <div class="btn-more" @click="handleBtnMore"></div>
<div class="btn-kaixin" @click="handleLotteryAction" v-if="activePrizeData.prize_code !== 'NO'"></div> <div class="btn-kaixin" @click="handleLotteryAction" v-if="activePrizeData.prize_code !== 'NO'"></div>
@@ -46,7 +49,8 @@ const btngroupShow = ref(false)
gsap.registerPlugin() gsap.registerPlugin()
const props = defineProps({ const props = defineProps({
show: false, show: false,
type: "draw" type: "draw",
data: null
}) })
const emit = defineEmits(['close']) const emit = defineEmits(['close'])
@@ -63,9 +67,15 @@ const handleBtnMore = () => {
closeThis() closeThis()
globalToastEvent.emit(ToastType.SHOW_AD) globalToastEvent.emit(ToastType.SHOW_AD)
} }
const handleLotteryAction = () => { const readNotice = async () => {
await Request(`notice/read`, { id: activePrizeData.value.noticeId })
}
const handleLotteryAction = async () => {
//实物 //实物
closeThis() closeThis()
if (props.type !== 'draw') {
await readNotice()
}
if (activePrizeData.value.coupon_type === 'scene') { if (activePrizeData.value.coupon_type === 'scene') {
globalToastEvent.emit(ToastType.SHOW_ADDRESS, activePrizeData.value.id) globalToastEvent.emit(ToastType.SHOW_ADDRESS, activePrizeData.value.id)
} }
@@ -110,6 +120,24 @@ watch(() => props.show, async (newVal) => {
let lottteryResult = null let lottteryResult = null
if (props.type === 'draw') { if (props.type === 'draw') {
lottteryResult = await Request("lottery/draw", { pool: 'game', consume_type: 'points' }) lottteryResult = await Request("lottery/draw", { pool: 'game', consume_type: 'points' })
} else {
if (!props.data) {
weui.alert("获取排名奖励出错,请刷新页面重试")
emit('close')
return
}
lottteryResult = {
res: { status: 200 },
json: {
noticeId: props.data.id,
id: props.data.data.prize.id,
prize_code: props.data.data.prize.prize_code,
prize_name: props.data.data.prize.name,
coupon_type: props.data.data.prize.scene,
rank: props.data.data.rank
}
}
} }
// const userPicture = await getUserPicture() // const userPicture = await getUserPicture()

View File

@@ -153,7 +153,7 @@ const handleBtnMore = () => {
</div> </div>
<Popup v-model:show="isPopupVisible" /> <Popup v-model:show="isPopupVisible" />
<Lottery :show="lotteryShow" @close="lotteryShow = false"></Lottery> <Lottery :show="lotteryShow" @close="lotteryShow = false" data="null" type="draw"></Lottery>
</template> </template>
<style scoped> <style scoped>