// pinia仓库
import { defineStore } from "pinia"

export const useMainStore = defineStore("counter", {
    state: () => {
        return {
            hasDraw: true, //是否有抽奖机会
            token: 'INFJ',
            MBTI: 'ENFP',    //测试结果
            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(key) {
            this.drawKey = key
        },
        updateDraw(value) {
            this.hasDraw = false
        }
    },
})
