30 lines
947 B
TypeScript
30 lines
947 B
TypeScript
import { ActivityModelType } from '../../db/Activity';
|
|
import { deltaDays } from '../../pubUtils/util';
|
|
|
|
// 活动数据
|
|
export abstract class ActivityBase {
|
|
activityId: number = 0;
|
|
beginTime: Date = null;
|
|
endTime: Date = null;
|
|
type: number = 0;
|
|
todayIndex: number = 0;//从1开始
|
|
|
|
abstract initData(data: string): void;
|
|
|
|
//今天是活动第几天
|
|
public today(): number {
|
|
return this.todayIndex;
|
|
}
|
|
|
|
constructor(activityData: ActivityModelType) {
|
|
this.activityId = activityData.acvitityId;
|
|
this.beginTime = activityData.beginTime;
|
|
this.endTime = activityData.endTime;
|
|
this.type = activityData.type;
|
|
// this.data = activityData.data;
|
|
this.initData(activityData.data);
|
|
this.todayIndex = deltaDays(activityData.beginTime, new Date) + 1;
|
|
console.log('今天是活动第几天', activityData.beginTime, new Date, this.todayIndex)
|
|
}
|
|
}
|