活动:添加隐藏时间
This commit is contained in:
@@ -13,6 +13,7 @@ export abstract class ActivityBase {
|
||||
type: number = 0;
|
||||
todayIndex: number = 0;//从1开始
|
||||
delayDay: number = 0;//延迟多少天开启,0表示按照原计划开启
|
||||
effectDay: number = 0;// 活动生效天数
|
||||
hideDayByServer: number = 0;
|
||||
isEnable: boolean = false;
|
||||
|
||||
@@ -27,8 +28,10 @@ export abstract class ActivityBase {
|
||||
}
|
||||
|
||||
public canShow() {
|
||||
console.log('#### canShow', this.beginTime <= Date.now(), this.endTime >= Date.now())
|
||||
return this.isEnable && this.beginTime <= Date.now() && this.endTime >= Date.now()
|
||||
if(!this.isEnable) return false;
|
||||
if(this.beginTime > Date.now() || this.endTime < Date.now()) return false;
|
||||
if(this.nextRefreshTime && this.nextRefreshTime < Date.now()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +66,7 @@ export abstract class ActivityBase {
|
||||
|
||||
this.type = activityData.type;
|
||||
console.log('今天是活动第几天', activityData.beginTime, new Date, this.todayIndex)
|
||||
console.log('***** activityData', activityData.timeType)
|
||||
console.log('***** activityData', activityData.timeType, this.beginTime, this.endTime, this.todayIndex, this.roundIndex, this.nextRefreshTime, this.effectDay)
|
||||
switch (activityData.timeType) {
|
||||
case ACTIVITY_TIME_TYPE.SERVER_OPEN_TIME: {
|
||||
this.beginTime = moment(serverTime * 1000).add(this.delayDay, 'd').startOf('d').add(REFRESH_TIME, 'h').valueOf();
|
||||
@@ -73,7 +76,6 @@ export abstract class ActivityBase {
|
||||
this.endTime = moment(this.beginTime).add(1, 'd').valueOf();
|
||||
}
|
||||
this.todayIndex = deltaDays(moment(this.beginTime).toDate(), new Date) + 1;
|
||||
console.log('活动时间数据11...', activityData.timeType, this.beginTime, this.endTime, this.todayIndex, this.roundIndex, this.nextRefreshTime)
|
||||
break;
|
||||
}
|
||||
case ACTIVITY_TIME_TYPE.ROLE_REGISTER_TIME: {
|
||||
@@ -85,11 +87,9 @@ export abstract class ActivityBase {
|
||||
}
|
||||
this.todayIndex = deltaDays(moment(this.beginTime).toDate(), new Date) + 1;
|
||||
|
||||
console.log('活动时间数据22...', activityData.timeType, this.beginTime, this.endTime, this.todayIndex, this.roundIndex, this.nextRefreshTime)
|
||||
break;
|
||||
}
|
||||
case ACTIVITY_TIME_TYPE.DATE_TIME: {
|
||||
console.log('活动时间数据33...', activityData.timeType, this.beginTime, this.endTime, this.todayIndex, this.roundIndex, this.nextRefreshTime)
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -97,8 +97,8 @@ 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.roundIndex = Math.ceil((moment(new Date).valueOf() - this.beginTime) / (activityData.interval * 86400000));
|
||||
this.nextRefreshTime = moment(this.beginTime).add(activityData.interval * (this.roundIndex - 1), 'day').add(activityData.effectDay, 'd').valueOf();
|
||||
this.todayIndex = Math.ceil(((moment(new Date).valueOf() - this.beginTime) / (24 * 60 * 60 * 1000)));
|
||||
}
|
||||
if(activityData.hideDayByServer > 0) {
|
||||
@@ -125,6 +125,7 @@ export class ActivityInRemote {
|
||||
timeType: number; // 活动时间类型 ACTIVITY_TIME_TYPE 1.服务器开启时间 2.角色创建时间 3.指定开启时间(beginTime,endTime)
|
||||
days: number; // 活动持续天数 timeType=1、2
|
||||
delayDay: number; // 迟几天开启活动,0表示按照规定时间开启
|
||||
effectDay: number; // 生效天数
|
||||
interval: number; // 周期性活动时间间隔,秒
|
||||
hideDayByServer: number;
|
||||
isEnable: boolean;
|
||||
@@ -144,6 +145,7 @@ export class ActivityInRemote {
|
||||
this.hideDayByServer = activity.hideDayByServer;
|
||||
this.isEnable = activity.isEnable;
|
||||
this.name = activity.name;
|
||||
this.effectDay = activity.effectDay;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user