palc-newyear2024/src/store/index.js
XGL-THINKPAD-X1\rucky ec457dc86c update
2024-01-23 19:10:52 +08:00

43 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// pinia仓库
import { defineStore } from "pinia"
export const useMainStore = defineStore("counter", {
state: () => {
return {
hasDraw: true, //是否有抽奖机会
token: 'INFJ',
MBTI: 'INFJ', //测试结果
hasPrize: false, //是否有奖品
prizeCode: 'oggSVMbeLgSK', //兑换码
prizeMoney: '8.88', //金额
drawKey: '',
}
},
// 相当于computed属性对state进行二次加工
getters: {},
// 异步处理方法
actions: {
updateToken(data) {
this.token = data.authorization
this.hasDraw = data.drawNumber == 0 ? false : true
},
updatePrize(data) {
this.prizeCode = data.prizeCode
this.prizeMoney = data.prizeAmount
this.hasPrize = true
},
updateMBTI(type) {
this.MBTI = type
},
updateDrawKey(data) {
console.log('保存结果:',data);
this.drawKey = data.subKey
this.hasDraw = data.drawFlag
},
updateDraw(value) {
this.hasDraw = false
}
},
})