palc-newyear2024/src/store/index.js
2025-04-18 16:50:47 +08:00

42 lines
1.0 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: "",
posterId: 1, //测试结果
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;
},
updatePosterId(id) {
this.posterId = id;
},
updateDrawKey(data) {
console.log("保存结果:", data);
this.drawKey = data.subKey;
this.hasDraw = data.drawFlag;
},
updateDraw(value) {
this.hasDraw = false;
},
},
});