活动:成长基金添加购买记录

This commit is contained in:
qiaoxin
2021-04-30 16:01:49 +08:00
parent 73e3836a54
commit a29b88d91d
6 changed files with 101 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
import { TASK_TYPE, ACTIVITY_RESOURCES_TYPE } from '../../consts';
import { TASK_TYPE, ACTIVITY_RESOURCES_TYPE, ACTIVITY_TYPE } from '../../consts';
import { ActivityModelType } from '../../db/Activity';
import { ActivityBuyRecordsModelType } from '../../db/ActivityBuyRecords';
import { ActivityGrowthFundModelType } from '../../db/ActivityGrowthFund';
import { RewardInter } from '../../pubUtils/interface';
import { parseGoodStrWithType, parseHeroStrWithType, splitString } from '../../pubUtils/util';
@@ -21,6 +22,7 @@ export class GrowthFundItem {
isComplete: boolean = false; //是否完成任务
isReceive: boolean = false; //是否领取过奖励
constructor(data: any) {
this.pageIndex = data.pageIndex;
this.cellIndex = data.cellIndex;
@@ -61,6 +63,21 @@ export class GrowthFundItem {
// 成长基金活动数据
export class GrowthFundData extends ActivityBase {
list: Array<GrowthFundItem> = [];
price: number = 0;//高阶价格
buyRecords: Array<number> = [];//高阶购买记录
//是否是高阶,需要购买
public isVipActivity() {
return this.type == ACTIVITY_TYPE.GROWTH_FUND_MAIN_VIP
|| this.type == ACTIVITY_TYPE.GROWTH_FUND_TOWER_VIP
|| this.type == ACTIVITY_TYPE.GROWTH_FUND_MAIN_ELITE_VIP
}
//是否购买page
public isBuy(pageIndex: number) {
let index = this.buyRecords.findIndex(obj => { return obj == pageIndex });
return index != -1;
}
//全部领取完成
public isComplete() {
@@ -88,8 +105,17 @@ export class GrowthFundData extends ActivityBase {
}
}
//高阶版购买记录
public initBuyRecords(buyRecords: ActivityBuyRecordsModelType[]) {
for (let obj of buyRecords) {
this.buyRecords.push(obj.pageIndex);
}
}
public initData(data: string) {
let arr = JSON.parse(data);
let dataObj = JSON.parse(data);
this.price = dataObj.price;
let arr = dataObj.data;
for (let obj of arr) {
this.list.push(new GrowthFundItem(obj))
}