style(春节活动页面): 调整接口,设置数据持久化和每日弹窗

This commit is contained in:
hzj 2026-02-10 15:10:15 +08:00
parent 4cf65bb119
commit 14d33b15b8
6 changed files with 203 additions and 57 deletions

View File

@ -38,7 +38,7 @@ export const withdrawApply = async (data) => {
export const ranklist = async (data) => {
try {
const response = await get(
`/activity/lottery/recharge-rank?activityId=${data.activityId}&pageNo=${data.pageNo}&pageSize=${data.pageSize}`
`/activity/lottery/recharge-rank?activityId=${data.activityId}&pageNo=${data.pageNo}&pageSize=${data.pageSize}`,
)
return response
} catch (error) {
@ -88,7 +88,7 @@ export const myRecharge = async (activityId) => {
export const activityRewardConfigs = async (data) => {
try {
const response = await get(
`/activity/lottery/reward-configs?activityType=${data.activityType}&activityId=${data.activityId}`
`/activity/lottery/reward-configs?activityType=${data.activityType}&activityId=${data.activityId}`,
)
return response
} catch (error) {
@ -99,10 +99,15 @@ export const activityRewardConfigs = async (data) => {
}
// 获取剩余中奖券
export const myTickets = async () => {
export const myTickets = async (activityId) => {
try {
const response = await get(`/activity/lottery/my-ticket-count`)
return response
if (!activityId) {
const response = await get(`/activity/lottery/my-ticket-count`)
return response
} else {
const response = await get(`/activity/lottery/my-ticket-count?activityId=${activityId}`)
return response
}
} catch (error) {
console.error('Failed to fetch get my tickets:', error)
console.error('error:' + error.response.errorMsg)
@ -145,9 +150,11 @@ export const multiDraw = async (data) => {
}
// 获取我的中奖记录(默认最新100条)
export const drawRecords = async () => {
export const drawRecords = async (activityCode) => {
try {
const response = await get(`/activity/lottery/my-records?pageSize=100`)
const response = await get(
`/activity/lottery/my-records?pageSize=100&activityCode=${activityCode}`,
)
return response
} catch (error) {
console.error('Failed to fetch get draw records:', error)
@ -172,7 +179,7 @@ export const winnerHistory = async () => {
export const rewardConfigsBadge = async (data) => {
try {
const response = await get(
`/activity/lottery/reward-configs-badge?activityType=${data.activityType}&activityId=${data.activityId}`
`/activity/lottery/reward-configs-badge?activityType=${data.activityType}&activityId=${data.activityId}`,
)
return response
} catch (error) {

View File

@ -13,7 +13,7 @@ export const useSpringFestival = defineStore('springFestival', {
taskList: [], // 任务列表
// 抽奖排名模块
lotteryPageNo: 1, // 抽奖排名页码
lotteryPageNo: 0, // 抽奖排名页码
lotteryRanking: [], // 抽奖排名
addLotteryRanking: [], // 补充的抽奖排名
myLotteryRanking: {}, // 我的抽奖排名
@ -22,7 +22,7 @@ export const useSpringFestival = defineStore('springFestival', {
rankingRewards: {}, // 排名奖池
// 充值排名模块
rechargePageNo: 1, // 充值排名页码
rechargePageNo: 0, // 充值排名页码
rechargeRanking: [], // 充值排名
addRechargeRanking: [], // 补充的充值排名
myRechargeRanking: {}, // 我的充值排名
@ -40,8 +40,35 @@ export const useSpringFestival = defineStore('springFestival', {
receiveRecord: [], // 领取抽奖券记录
taskListShow: false,
checkDate: '', // 对应几号
checkStatus: false, // 是否已看过
helpShow: false, // 帮助展示
}),
actions: {},
actions: {
// 重置除了checkDate和checkStatus的属性
clear() {
const excludedFields = ['checkDate', 'checkStatus'] // 不重置的字段
for (const key in this.$state) {
if (!excludedFields.includes(key)) {
if (typeof this.$state[key] === 'string') {
this.$state[key] = ''
} else if (Array.isArray(this.$state[key])) {
this.$state[key] = []
} else if (typeof this.$state[key] === 'object') {
this.$state[key] = {}
} else if (typeof this.$state[key] === 'number') {
this.$state[key] = 0
} else if (typeof this.$state[key] === 'boolean') {
this.$state[key] = false
} else {
console.log('未知类型:', key, this.$state[key])
}
}
}
},
},
persist: true,
})

View File

@ -196,24 +196,6 @@ import { useThrottle } from '@/utils/useDebounce'
import {
ranklist, //
validActivity, //
activityDetail, //
myRecharge, //
activityRewardConfigs, //
myTickets, //
myTotalDrawCount, //
onceDraw, //
multiDraw, //
drawRecords, //
ActTaskList, //
rewardConfigsBadge, // -
receiveTickets, //
receiveRechargeReward, //
receiveRewardBadge, // -
winnerHistory, //
withdrawableAmount, //
transferActivityDollar, //
exchangeCoin, //
} from '@/api/lottery'
import BackgroundLayer from '@/components/BackgroundLayer.vue'
@ -321,8 +303,15 @@ const rankingPageNo = ref(1) //分页页码
//
const getRanking = async () => {
if (lotteryPageNo.value == 0) {
lotteryPageNo.value = 1
}
if (rechargePageNo.value == 0) {
rechargePageNo.value = 1
}
let data = {
activityId: props.rankingType == 'lottery' ? '2005571533988298753' : '2005571533988298753',
activityId: props.rankingType == 'lottery' ? '2007771533988204877' : '2005571533988298753',
pageNo: props.rankingType == 'lottery' ? lotteryPageNo.value : rechargePageNo.value,
pageSize: 20,
}

View File

@ -108,6 +108,11 @@ import { formatRewardDisplay } from '@/utils/rewardFormatter.js'
import { useSpringFestival } from '@/stores/springFestival'
import { storeToRefs } from 'pinia'
import {
receiveRechargeReward, //
activityRewardConfigs, //
} from '@/api/lottery'
import BackgroundLayer from '@/components/BackgroundLayer.vue'
import itemCenter from '@/components/itemCenter.vue'
import maskLayer from '@/components/MaskLayer.vue'
@ -195,6 +200,90 @@ const rewardContentLayer = (index) => {
}
}
//
const receiveReward = async (rewards) => {
let data = {
activityType: rewards.activityType,
activityId: '2007771533988204877',
ruleId: rewards.ruleId,
}
try {
const resReceive = await receiveRechargeReward(data)
if (resReceive.status && resReceive.body) {
getRechargeReward() //
}
} catch (error) {
showError(error.errorMsg)
}
}
//
const getRechargeReward = async () => {
let data = {
activityType: 'CONSUMPTION_ACTIVITY',
activityId: '2005571533988298753',
}
const resActivityReward = await activityRewardConfigs(data)
if (resActivityReward.status && resActivityReward.body) {
RechargeRewards.value = resActivityReward.body.map((rewards) => {
let jsonData = JSON.parse(rewards.jsonData)
let addReward = []
if (rewards.sort == 1) {
addReward = []
} else if (rewards.sort == 2) {
addReward = []
} else if (rewards.sort == 3) {
addReward = []
} else if (rewards.sort == 4) {
addReward = [
{
type: 'TICKET',
cover: imageUrl('ticket'),
content: 30,
},
]
} else if (rewards.sort == 5) {
addReward = [
{
type: 'TICKET',
cover: imageUrl('ticket'),
content: 40,
},
]
} else if (rewards.sort == 6) {
addReward = [
{
type: 'TICKET',
cover: imageUrl('ticket'),
content: 50,
},
{
type: 'TICKET',
cover: imageUrl('ticket'),
content: 50,
},
{
type: 'TICKET',
cover: imageUrl('ticket'),
content: 50,
},
]
}
rewards.rewardProps.push(...addReward) //
rewards = {
...rewards,
...jsonData,
}
return rewards
})
} else {
RechargeRewards.value = []
}
}
onMounted(() => {})
onUnmounted(() => {})

View File

@ -671,15 +671,10 @@ import { useSpringFestival } from '@/stores/springFestival'
import { storeToRefs } from 'pinia'
import {
activityDetail, //
onceDraw, //
multiDraw, //
drawRecords, //
apiGetMyLotteryTicketCount, //
apiGetUserFragmentBackpack, //
} from '@/api/couple.js'
import {
myTickets, //
withdrawableAmount, //
transferActivityDollar, //
exchangeCoin, //
@ -775,6 +770,10 @@ const scrollWrapper = ref(null) //滚动模块
watch(luckyUsers, async () => {
await nextTick()
let retryCount = 0 //
const maxRetries = 50 //
let timerId = null // setTimeout ID
const calculateWidth = () => {
const wrapper = scrollWrapper.value
if (!wrapper) return
@ -783,13 +782,22 @@ watch(luckyUsers, async () => {
console.log('luckyUsers 更新后的宽度:', contentWidth)
if (contentWidth === 0) {
console.warn('宽度为 0稍后重试...')
setTimeout(calculateWidth, 100) //
retryCount++
if (retryCount <= maxRetries) {
console.warn(`宽度为 0${retryCount} 次重试...`)
//
if (timerId) clearTimeout(timerId)
timerId = setTimeout(calculateWidth, 500) //
} else {
console.error('重试次数已达上限,未能获取有效宽度')
}
} else {
//
const speed = 80
duration.value = contentWidth / speed
console.log('计算总时长(秒):', duration.value)
//
if (timerId) clearTimeout(timerId)
}
}
@ -910,7 +918,7 @@ const sweepstakes = async (consecutive = 1) => {
let activity = props.activity
let data = {
activityId: '2004471533988167125',
activityId: '2007771533988204877',
drawCount: consecutive,
needCoins: consecutive > tickets.value,
}
@ -957,7 +965,7 @@ const sweepstakes = async (consecutive = 1) => {
//
const getDrawRecords = async () => {
const resDrawRecords = await drawRecords('67125')
const resDrawRecords = await drawRecords('04877')
if (resDrawRecords.status && resDrawRecords.body) {
myRecords.value = resDrawRecords.body?.records || []
openPopup('history') //
@ -1073,7 +1081,7 @@ const exchangeCoinBt = async () => {
//
const getDrawableAmount = async () => {
const resDrawableAmount = await withdrawableAmount('2004471533988167125')
const resDrawableAmount = await withdrawableAmount('2007771533988204877')
if (resDrawableAmount.status && resDrawableAmount.body) {
currentEarnings.value = resDrawableAmount.body?.availableAmount || 0
}
@ -1082,7 +1090,7 @@ const getDrawableAmount = async () => {
//
const getMyLotteryTicketCount = async () => {
try {
const response = await apiGetMyLotteryTicketCount('2004471533988167125')
const response = await myTickets('2007771533988204877')
if (response.status) {
tickets.value = response.body || 0
}

View File

@ -624,14 +624,8 @@ import { gotoAppPage } from '@/utils/appBridge.js'
import { getMemberProfile, getUserIdentity } from '@/api/wallet'
import {
myTickets, //
activityDetail, //
onceDraw, //
multiDraw, //
drawRecords, //
apiGetMyLotteryTicketCount, //
apiGetUserFragmentBackpack, //
} from '@/api/couple.js'
import {
ranklist, //
activityRewardConfigs, //
winnerHistory, //
@ -690,6 +684,8 @@ const {
receiveRecord, //
taskListShow, //
checkDate, //
checkStatus, //
helpShow, //
} = storeToRefs(springFestivalStore)
@ -790,9 +786,9 @@ const Minutes = ref(0)
const Seconds = ref(0)
let countdownTimer = null
// 20262165
// 20263145
const getTargetTime = () => {
const target = new Date(2026, 1, 16, 5, 0, 0) // 01011
const target = new Date(2026, 2, 14, 5, 0, 0) // 01011
return target.getTime()
}
@ -854,6 +850,20 @@ const centerPopupShow = computed(() => {
)
})
//
const checkShow = () => {
const now = new Date()
const dailyDate = now.getMonth() + '-' + now.getDate()
if (dailyDate != checkDate.value) {
checkDate.value = dailyDate //
checkStatus.value = false //
showPopup('taskList')
} else if (!checkStatus.value) {
showPopup('taskList')
}
}
//
const showPopup = (type) => {
switch (type) {
@ -886,6 +896,10 @@ const showPopup = (type) => {
//
const closedPopup = () => {
if (taskListShow.value) {
checkStatus.value = true
}
resultShow.value = false
drawRecordShow.value = false
receiveRecordShow.value = false
@ -913,7 +927,7 @@ const gotoRecharge = () => {
//
const getActivityDetail = async () => {
const resDetail = await activityDetail('67125')
const resDetail = await activityDetail('04877')
if (resDetail.status && resDetail.body) {
lotteryRewards.value = resDetail.body
} else {
@ -924,7 +938,7 @@ const getActivityDetail = async () => {
//
const getMyLotteryTicketCount = async () => {
try {
const response = await apiGetMyLotteryTicketCount('2004471533988167125')
const response = await myTickets('2007771533988204877')
if (response.status) {
tickets.value = response.body || 0
}
@ -998,7 +1012,7 @@ const getUserInfo = async () => {
//
const getDrawableAmount = async () => {
const resDrawableAmount = await withdrawableAmount('2004471533988167125')
const resDrawableAmount = await withdrawableAmount('2007771533988204877')
if (resDrawableAmount.status && resDrawableAmount.body) {
currentEarnings.value = resDrawableAmount.body?.availableAmount || 0
}
@ -1029,8 +1043,14 @@ const clearPayee = () => {
//
const getRanking = async (rankingType = 'lottery') => {
if (lotteryPageNo.value == 0) {
lotteryPageNo.value = 1
}
if (rechargePageNo.value == 0) {
rechargePageNo.value = 1
}
let data = {
activityId: rankingType == 'lottery' ? '2005571533988298753' : '2005571533988298753',
activityId: rankingType == 'lottery' ? '2007771533988204877' : '2007771533988204888',
pageNo: rankingType == 'lottery' ? lotteryPageNo.value : rechargePageNo.value,
pageSize: 20,
}
@ -1080,7 +1100,7 @@ const getRanking = async (rankingType = 'lottery') => {
const getGameReward = async () => {
let data = {
activityType: 'CONSUMPTION_ACTIVITY',
activityId: '2005571533988298753',
activityId: '2007771533988204877',
}
const resActivityReward = await activityRewardConfigs(data)
if (resActivityReward.status && resActivityReward.body) {
@ -1126,7 +1146,7 @@ const getGameReward = async () => {
const getRechargeReward = async () => {
let data = {
activityType: 'CONSUMPTION_ACTIVITY',
activityId: '2005571533988298753',
activityId: '2007771533988204877',
}
const resActivityReward = await activityRewardConfigs(data)
if (resActivityReward.status && resActivityReward.body) {
@ -1255,6 +1275,10 @@ const connectToAppHandler = async () => {
//
onMounted(() => {
springFestivalStore.clear()
checkShow() //
console.log('route.query.activeAction:', route.query.activeAction)
if (route.query.activeAction == 'TaskShow') {
changeTag('gamePlay')
@ -1269,6 +1293,8 @@ onMounted(() => {
})
onUnmounted(() => {
springFestivalStore.clear()
if (countdownTimer) {
clearInterval(countdownTimer)
countdownTimer = null