mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-10-09 00:26:11 +00:00
提交
This commit is contained in:
45
JisolGameCocos/assets/script/data/GiftData.ts
Normal file
45
JisolGameCocos/assets/script/data/GiftData.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user