mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 03:14:47 +00:00
46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
|
import { app } from "../App";
|
||
|
import { API, GiftDayRecord, GiftRecord } from "../consts/API";
|
||
|
import BaseData from "./BaseData";
|
||
|
|
||
|
export enum GiftDataEnum{
|
||
|
BUY = "GiftDataEnum_Buy", //礼包购买
|
||
|
}
|
||
|
|
||
|
//礼包数据
|
||
|
export default class GiftData extends BaseData{
|
||
|
|
||
|
records:GiftRecord[] = [];
|
||
|
dayRecords:GiftDayRecord[] = [];
|
||
|
|
||
|
onInit() {
|
||
|
|
||
|
}
|
||
|
|
||
|
//查询充值记录
|
||
|
async UpdateGiftRecord(){
|
||
|
return this.records = await API.GetGiftRecord();
|
||
|
}
|
||
|
//查询当天充值记录
|
||
|
async UpdateGiftDayRecord(){
|
||
|
return this.dayRecords = await API.GetGiftDayRecord();
|
||
|
}
|
||
|
|
||
|
//查询指定礼包每天的购买次数
|
||
|
getGiftDayRecordCount(giftId:number){
|
||
|
return this.dayRecords.filter(item => item.giftCfgId == giftId).length;
|
||
|
}
|
||
|
|
||
|
//查询礼包购买次数
|
||
|
getGiftRecordCount(giftId:number){
|
||
|
return this.records.filter(item => item.giftCfgId == giftId).length;
|
||
|
}
|
||
|
|
||
|
//购买礼包
|
||
|
async buy(giftId:number){
|
||
|
await API.BuyGift(giftId);
|
||
|
app.event.emit(GiftDataEnum.BUY);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|