活动:糜家商队

This commit is contained in:
qiaoxin
2021-06-08 17:36:44 +08:00
parent c51997299c
commit cc218151e4
12 changed files with 659 additions and 361 deletions

View File

@@ -1,5 +1,8 @@
import moment = require('moment');
import { SERVER_OPEN_TIME } from '../../consts';
import { ActivityModelType } from '../../db/Activity';
import { ActivitySelfServiceShopModelType } from '../../db/ActivitySelfServiceShop';
import { deltaDays } from '../../pubUtils/util';
import { ActivityBase } from './activityField';
// 自助商店数据坑位数据
@@ -21,7 +24,9 @@ export class SelfServiceShopItem {
name: string; //名称
countMax: number = 0; // 最大可购买次数 0表示无限
price: number; //价格
priceType: number; //价格类型 ACTIVITY_RESOURCES_TYPE 2.物品表 3.RMB
productID: string; //商品id
consume: string; //消耗其他资源
data: Array<SelfServiceShopItemInfo> = [];
buyCount: number = 0; //已经购买次数
@@ -31,7 +36,8 @@ export class SelfServiceShopItem {
this.name = cellData.name;
this.countMax = cellData.countMax;
this.price = cellData.price;
this.priceType = cellData.priceType;
this.productID = cellData.productID;
this.consume = cellData.consume;
this.data = [];
for (let obj of cellData.data) {
this.data.push(new SelfServiceShopItemInfo(obj))
@@ -43,8 +49,22 @@ export class SelfServiceShopItem {
export class SelfServiceShopData extends ActivityBase {
list: Array<SelfServiceShopItem> = [];//货架
days: number = 20;//刷新周期天数
name: string = '';
count: number = 1;//每天可挑战次数胜利,才会统计
warid: string = '';//可挑战关卡
unitPrice: string = '';//元宝购买代币价格
unitCountMax: number = 0;//元宝购买代币最大次数
unitReward: string = '';//购买获得代币资源
unitBuyCount: number = 0;//元宝购买代币次数
roundIndex: number = 0; //第几周期 从1开始
public getItemByProductID(productID: string): SelfServiceShopItem {
let listIndex = this.list.findIndex(obj => { return obj.productID == productID });
return (listIndex != -1) ? this.list[listIndex] : null;
}
public getItem(index: number) {
let listIndex = this.list.findIndex(obj => { return obj.index == index });
return (listIndex != -1) ? this.list[listIndex] : null;
@@ -59,14 +79,21 @@ export class SelfServiceShopData extends ActivityBase {
}
public initData(data: string) {
console.log('ddddddd', data)
let dataObj = JSON.parse(data);
this.days = dataObj.days;
this.name = dataObj.name;
this.count = dataObj.count;
this.warid = dataObj.warid;
this.unitPrice = dataObj.unitPrice;
this.unitCountMax = dataObj.unitCountMax;
this.unitReward = dataObj.unitReward;
let arr = dataObj.data;
for (let obj of arr) {
this.list.push(new SelfServiceShopItem(obj))
}
this.todayIndex = deltaDays(moment(SERVER_OPEN_TIME).startOf('d').toDate(), new Date) + 1;
this.roundIndex = Math.ceil(this.todayIndex / this.days);
}