🐞 fix(活动): 修复活动多时间刷新问题
This commit is contained in:
@@ -98,10 +98,12 @@ export abstract class ActivityBase {
|
|||||||
case ACTIVITY_TIME_TYPE.MULT_DATE_TIME: {
|
case ACTIVITY_TIME_TYPE.MULT_DATE_TIME: {
|
||||||
let now = new Date();
|
let now = new Date();
|
||||||
let multiTime = activityData.multiTime||[];
|
let multiTime = activityData.multiTime||[];
|
||||||
|
|
||||||
for(let { id, beginTime, endTime } of multiTime) {
|
for(let { id, beginTime, endTime } of multiTime) {
|
||||||
if(beginTime <= now && endTime > now) {
|
if(beginTime <= now && endTime > now) {
|
||||||
this.beginTime = beginTime.valueOf();
|
this.beginTime = beginTime.valueOf();
|
||||||
this.endTime = endTime.valueOf();
|
this.endTime = endTime.valueOf();
|
||||||
|
this.nextRefreshTime = this.endTime;
|
||||||
this.roundIndex = id;
|
this.roundIndex = id;
|
||||||
let startOfBeginDay = moment(this.beginTime).startOf('d').add(REFRESH_TIME, 'h');
|
let startOfBeginDay = moment(this.beginTime).startOf('d').add(REFRESH_TIME, 'h');
|
||||||
this.todayIndex = deltaDays(startOfBeginDay.toDate(), new Date) + 1;
|
this.todayIndex = deltaDays(startOfBeginDay.toDate(), new Date) + 1;
|
||||||
@@ -114,12 +116,14 @@ export abstract class ActivityBase {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (activityData.interval > 0) {
|
if(activityData.timeType != ACTIVITY_TIME_TYPE.MULT_DATE_TIME) {
|
||||||
this.roundIndex = Math.ceil((moment(new Date).valueOf() - this.beginTime) / (activityData.interval * 86400000));
|
if (activityData.interval > 0) {
|
||||||
this.nextRefreshTime = moment(this.beginTime).add(activityData.interval * (this.roundIndex - 1), 'day').add(activityData.effectDay, 'd').valueOf();
|
this.roundIndex = Math.ceil((moment(new Date).valueOf() - this.beginTime) / (activityData.interval * 86400000));
|
||||||
this.todayIndex = Math.ceil(((moment(new Date).valueOf() - this.beginTime) / (24 * 60 * 60 * 1000)));
|
this.nextRefreshTime = moment(this.beginTime).add(activityData.interval * (this.roundIndex - 1), 'day').add(activityData.effectDay, 'd').valueOf();
|
||||||
} else {
|
this.todayIndex = Math.ceil(((moment(new Date).valueOf() - this.beginTime) / (24 * 60 * 60 * 1000)));
|
||||||
this.nextRefreshTime = this.endTime;
|
} else {
|
||||||
|
this.nextRefreshTime = this.endTime;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(activityData.hideDayByServer > 0) {
|
if(activityData.hideDayByServer > 0) {
|
||||||
let hidOverTime = moment(serverTime * 1000).add(activityData.hideDayByServer, 'd').startOf('d').add(REFRESH_TIME, 'h').valueOf();
|
let hidOverTime = moment(serverTime * 1000).add(activityData.hideDayByServer, 'd').startOf('d').add(REFRESH_TIME, 'h').valueOf();
|
||||||
@@ -128,6 +132,7 @@ export abstract class ActivityBase {
|
|||||||
// console.log('活动时间数据...', '活动id:', activityData.activityId, '类型:', activityData.timeType, '开始时间:', this.beginTime, moment(this.beginTime).toDate(),
|
// console.log('活动时间数据...', '活动id:', activityData.activityId, '类型:', activityData.timeType, '开始时间:', this.beginTime, moment(this.beginTime).toDate(),
|
||||||
// '结束:', this.endTime, moment(this.endTime).toDate(),
|
// '结束:', this.endTime, moment(this.endTime).toDate(),
|
||||||
// '今天第几天:', this.todayIndex, '回合:', this.roundIndex, '下次刷新:', this.nextRefreshTime, moment(this.nextRefreshTime).toDate())
|
// '今天第几天:', this.todayIndex, '回合:', this.roundIndex, '下次刷新:', this.nextRefreshTime, moment(this.nextRefreshTime).toDate())
|
||||||
|
console.log('###### roundIndex 1', this.roundIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user