import { APP_SEASON_PASS_INFO, APP_SEASON_PASS_PRIZE_CLAIM, APP_SEASON_PASS_TASKS_CLAIM, APP_WEEKLY_PASS_CLAIM, APP_WEEKLY_PASS_INFO, } from '../../api'; import { success } from '@scripts/api/ApiHelper'; import { ApiEnvelope, Http } from '../../request'; import { AppKernel } from '@scripts/app/AppKernel'; class WeeklyPassStore { private _weeklyPassData = {} as any; public get data() { return this._weeklyPassData; } async reqWeeklyPassInfo() { const res = await Http.call(APP_WEEKLY_PASS_INFO); if (success(res)) { this._weeklyPassData = res.data; AppKernel.events.emit('weeklyPass:update'); return true; } return false; } async reqWeeklyPassClaim(payload: any) { const params = { ...payload } const res = await Http.call(APP_WEEKLY_PASS_CLAIM, params); if (success(res)) { this.reqWeeklyPassInfo(); return res?.data; } return false; } clear() { this._weeklyPassData = null; } } export const weeklyPassStore = new WeeklyPassStore();