import { APP_CHECK_IN, APP_CHECK_IN_INFO, } from '../../api'; import { success } from '@scripts/api/ApiHelper'; import { ApiEnvelope, Http } from '../../request'; import { ICheckInData, ICheckInResponseData } from './data'; import { AppKernel } from '@scripts/app/AppKernel'; class CheckInStore { private _checkInData = {}; public get checkInData() { return this._checkInData; } async reqCheckInInfo() { const res = await Http.call(APP_CHECK_IN_INFO); if (success(res)) { this._checkInData = res.data; AppKernel.events.emit('checkIn:update'); return true; } return false; } async reqCheckIn(day: number) { const params = { day }; const res = await Http.call(APP_CHECK_IN, params); if (success(res)) { this.reqCheckInInfo(); return true; } return false; } clear() { this._checkInData = null; } } export const checkInStore = new CheckInStore();