aslan-h5/src/stores/springFestival.js

77 lines
2.3 KiB
JavaScript

import { defineStore } from 'pinia'
export const useSpringFestival = defineStore('springFestival', {
state: () => ({
// 抽奖模块
lotteryRewards: {}, // 抽奖奖池
tickets: 0, // 抽奖券数量
luckyUsers: [], //中奖用户列表
userInfo: {}, // 用户信息
userIdentity: {}, // 用户身份
currentEarnings: 0, // 当前收益
selectedPayee: {}, // 选中的收款人
taskList: [], // 任务列表
// 抽奖排名模块
lotteryPageNo: 0, // 抽奖排名页码
lotteryRanking: [], // 抽奖排名
addLotteryRanking: [], // 补充的抽奖排名
myLotteryRanking: {}, // 我的抽奖排名
// 排行榜奖励模块
rankingRewards: {}, // 排名奖池
// 充值排名模块
rechargePageNo: 0, // 充值排名页码
rechargeRanking: [], // 充值排名
addRechargeRanking: [], // 补充的充值排名
myRechargeRanking: {}, // 我的充值排名
// 充值奖池模块
myRechargeRecode: {}, // 我的充值记录
RechargeRewards: {}, // 充值奖池
resultShow: false,
result: [], // 抽奖结果
drawRecordShow: false,
myRecords: [], // 我的抽奖记录
receiveRecordShow: false,
receiveRecord: [], // 领取抽奖券记录
taskListShow: false,
checkDate: '', // 对应几号
checkStatus: false, // 是否已看过
earningsHelpShow: false, // 收益help展示
rechargeHelpShow: false, // 充值help展示
}),
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,
})