diff --git a/shared/domain/activityField/activityField.ts b/shared/domain/activityField/activityField.ts index c545edcc5..d6ae0c91b 100644 --- a/shared/domain/activityField/activityField.ts +++ b/shared/domain/activityField/activityField.ts @@ -28,6 +28,8 @@ export abstract class ActivityBase { this.beginTime = moment(activityData.beginTime).add(this.delayDay, 'd').valueOf(); this.endTime = moment(activityData.endTime).add(this.delayDay, 'd').valueOf(); this.todayIndex = deltaDays(moment(this.beginTime).toDate(), new Date) + 1; + this.roundIndex = 1; + this.nextRefreshTime = this.endTime; this.type = activityData.type; // console.log('今天是活动第几天', activityData.beginTime, new Date, this.todayIndex) @@ -66,7 +68,7 @@ export abstract class ActivityBase { if (activityData.interval > 0) { this.roundIndex = Math.ceil((moment(new Date).valueOf() - this.beginTime) / (activityData.interval * 1000)); this.nextRefreshTime = moment(this.beginTime).add(activityData.interval * this.roundIndex, 'second').valueOf(); - this.todayIndex = Math.ceil(((moment(new Date).valueOf() - this.beginTime) % (activityData.interval * 1000)) / 24 * 60 * 60 * 1000); + this.todayIndex = Math.ceil(((moment(new Date).valueOf() - this.beginTime) % (activityData.interval * 1000)) / (24 * 60 * 60 * 1000)); } console.log('活动时间数据...', '活动id:', activityData.activityId, '类型:', activityData.timeType, '开始时间:', this.beginTime, moment(this.beginTime).toDate(), '结束:', this.endTime, moment(this.endTime).toDate(), diff --git a/shared/domain/activityField/refreshShopField.ts b/shared/domain/activityField/refreshShopField.ts index b63340202..47ea3ae11 100644 --- a/shared/domain/activityField/refreshShopField.ts +++ b/shared/domain/activityField/refreshShopField.ts @@ -61,8 +61,6 @@ export class RefreshShopData extends ActivityBase { name: string = '';//活动名称 interval: number = 0;//周期间隔(秒) list: Array = [];//商品列表 - nextRefreshTime: number;//下次刷新时间 - roundIndex: number = 1;//周期数从1开始 //随机出商店可购买的商品数据 public randomGoodsItems(playerLevel: number) { @@ -71,7 +69,10 @@ export class RefreshShopData extends ActivityBase { let pageIndex = pageData.pageIndex; let randomCount = pageData.viewCount; pageData.items = pageData.items.filter(obj => { return (obj.levelLimitMin == 0 && obj.levelLimitMax == 0) || (obj.levelLimitMin <= playerLevel && obj.levelLimitMax >= playerLevel) }); - pageData.items = this.randomGoods(pageData.items, randomCount); + + if (pageData.items.length > randomCount) { + pageData.items = this.randomGoods(pageData.items, randomCount); + } for (let item of pageData.items) { goods.push({ pageIndex: pageIndex, @@ -161,7 +162,7 @@ export class RefreshShopData extends ActivityBase { // this.roundIndex = Math.ceil((moment(new Date).valueOf() - this.beginTime) / (this.interval * 1000)); // this.nextRefreshTime = moment(this.beginTime).add(this.interval * this.roundIndex, 'second').valueOf(); // } - // console.log('ddddddddddddbbbbbbb', moment(new Date).valueOf(), moment(this.beginTime).valueOf(), this.roundIndex,) + // console.log('cccccccccccccccccccccccc', this.beginTime, this.roundIndex,) let arr = dataObj.data; for (let obj of arr) { this.list.push(new RefreshShopPage(obj))