活动:成长活动、今日挑战奖励接口返回数据添加字段
This commit is contained in:
@@ -1,77 +1,45 @@
|
||||
import { DAILYRMBGIFTS_DAYS } from '../../consts';
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityPopUpShopModelType } from '../../db/ActivityPopUpShop';
|
||||
import { deltaDays } from '../../pubUtils/util';
|
||||
import { ActivityBase } from './activityField';
|
||||
|
||||
// 商品数据
|
||||
export class PopUpShopItem {
|
||||
// 弹框商店
|
||||
export class PopUpShopData {
|
||||
|
||||
id: number; // 第几个,从1开始
|
||||
name: string; //名字
|
||||
consume: string; //消耗资源(这里优先rmb的price价格,其次资源消耗)
|
||||
price: number; // 商品价格
|
||||
productID: string; // 商品id支付时使用
|
||||
reward: string; //任务奖励,格式:1&3&1(类型&id&数量) 类型定义:1.英雄,2.物品
|
||||
countMax: number = 0; //可购买的最大次数,0表示不限制
|
||||
name: string; //名字
|
||||
rebate: number; // 折扣用于显示
|
||||
duration: number; // 持续时间,单位小时
|
||||
taskType: number; // 任务类型
|
||||
taskParam: number; // 任务参数
|
||||
condition: number; // 任务条件
|
||||
isBuy: boolean = false; //购买过
|
||||
|
||||
buyCount: number = 0; //购买过的次数
|
||||
// //解析玩家购买记录
|
||||
// public setPlayerRecords(data: ActivityPopUpShopModelType) {
|
||||
// if (!data) {
|
||||
// return;
|
||||
// }
|
||||
// for (let item of this.list) {
|
||||
// let buyRecords = data.records.filter(obj => { return obj && obj.id === item.id });
|
||||
// item.buyCount = buyRecords.length;
|
||||
// }
|
||||
// }
|
||||
|
||||
constructor(data: any) {
|
||||
|
||||
public initData(data: any) {
|
||||
this.id = data.id;
|
||||
this.reward = data.reward;
|
||||
this.countMax = data.countMax;
|
||||
this.consume = data.consume ? data.consume : '';
|
||||
this.price = data.price ? data.price : 0;
|
||||
this.productID = data.productID ? data.productID : '';
|
||||
this.name = data.name;
|
||||
}
|
||||
}
|
||||
|
||||
// 弹框商店
|
||||
export class PopUpShopData {
|
||||
name: string = '';//活动名称
|
||||
taskId: number = 0;//id
|
||||
list: Array<PopUpShopItem> = [];//每件商品信息
|
||||
|
||||
public findItemByProductID(productID: string) {
|
||||
let index = this.list.findIndex(obj => { return obj && obj.productID === productID });
|
||||
return (index != -1) ? this.list[index] : null
|
||||
}
|
||||
|
||||
public findItem(id: number) {
|
||||
let index = this.list.findIndex(obj => { return obj && obj.id === id });
|
||||
return (index != -1) ? this.list[index] : null
|
||||
}
|
||||
|
||||
//全部领取完成
|
||||
public isComplete() {
|
||||
for (let item of this.list) {
|
||||
if (item.countMax == 0 ||
|
||||
(item.countMax > 0 && item.buyCount < item.countMax)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//解析玩家购买记录
|
||||
public setPlayerRecords(data: ActivityPopUpShopModelType) {
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
for (let item of this.list) {
|
||||
let buyRecords = data.records.filter(obj => { return obj && obj.id === item.id });
|
||||
item.buyCount = buyRecords.length;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public initData(data: any) {
|
||||
this.taskId = data.taskId;
|
||||
let arr = data.data;
|
||||
for (let obj of arr) {
|
||||
this.list.push(new PopUpShopItem(obj))
|
||||
}
|
||||
this.rebate = data.rebate;
|
||||
this.duration = data.duration;
|
||||
this.taskType = data.taskType;
|
||||
this.taskParam = data.taskParam;
|
||||
this.condition = data.condition;
|
||||
this.isBuy = false;
|
||||
}
|
||||
|
||||
constructor(activityData: any) {
|
||||
|
||||
Reference in New Issue
Block a user