style(春节活动页面): 调整接口,设置数据持久化和每日弹窗
This commit is contained in:
parent
4cf65bb119
commit
14d33b15b8
@ -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) {
|
||||
|
||||
@ -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,
|
||||
})
|
||||
|
||||
@ -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,
|
||||
}
|
||||
|
||||
@ -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(() => {})
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
// 获取目标时间(2026年2月16日上午5点,北京时间)
|
||||
// 获取目标时间(2026年3月14日上午5点,北京时间)
|
||||
const getTargetTime = () => {
|
||||
const target = new Date(2026, 1, 16, 5, 0, 0) // 月份从0开始,10代表11月
|
||||
const target = new Date(2026, 2, 14, 5, 0, 0) // 月份从0开始,10代表11月
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user