Files
ZYZ/shared/domain/activityField/popUpShopField.ts
2021-06-02 11:20:18 +08:00

67 lines
2.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import moment = require("moment");
import { ACTIVITY_TYPE } from "../../consts";
import { ActivityPopUpShopModelType } from "../../db/ActivityPopUpShop";
// 弹框商店
export class PopUpShopData {
type: number//活动类型
activityId: number; // 活动id
id: number; // 第几个从1开始
name: string; //名字
consume: string; //消耗资源(这里优先rmb的price价格其次资源消耗)
price: number; // 商品价格
productID: string; // 商品id支付时使用
reward: string; //任务奖励,格式:1&3&1(类型&id&数量) 类型定义:1.英雄2.物品
rebate: number; // 折扣用于显示
duration: number; // 持续时间,单位小时
taskType: number; // 任务类型
taskParam: number; // 任务参数
condition: number; // 任务条件
totalCount: number; //一共完成次数
count: number; //最大可购买次数
buyCount: number = 0; //已经购买过次数
beginTime: Date = null;//开始时间
endTime: Date = null;//结束时间
beginTimeStamp: number = 0;//开始时间
endTimeStamp: number = 0;//结束时间
//解析玩家开启的商店记录
public setPlayerRecords(data: ActivityPopUpShopModelType) {
if (!data) {
return;
}
this.buyCount = data.buyCount ? data.buyCount : 0;
this.beginTime = data.beginTime;
this.endTime = data.endTime;
this.beginTimeStamp = moment(data.beginTime).valueOf();
this.endTimeStamp = moment(data.endTime).valueOf();
this.totalCount = data.totalCount;
}
public initData(data: any) {
this.type = ACTIVITY_TYPE.POP_UP_SHOP;
this.id = data.id;
this.reward = data.reward;
this.consume = data.consume ? data.consume : '';
this.price = data.price ? data.price : 0;
this.productID = data.productID ? data.productID : '';
this.name = data.name;
this.rebate = data.rebate;
this.duration = data.duration;
this.taskType = data.taskType;
this.taskParam = data.taskParam;
this.condition = data.condition;
this.buyCount = 0;
this.beginTime = null;
this.endTime = null;
this.totalCount = 0;
this.count = data.count;
}
constructor(activityData: any, activityId: number) {
this.activityId = activityId;
this.initData(activityData)
}
}