活动:随机商店不需要随机的情况判断

This commit is contained in:
qiaoxin
2021-06-30 20:46:15 +08:00
parent 5532d53419
commit 1c330fea03
2 changed files with 8 additions and 5 deletions

View File

@@ -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(),

View File

@@ -61,8 +61,6 @@ export class RefreshShopData extends ActivityBase {
name: string = '';//活动名称
interval: number = 0;//周期间隔(秒)
list: Array<RefreshShopPage> = [];//商品列表
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))