🐞 fix(商店): 限时商店添加时间永久类型

This commit is contained in:
luying
2022-11-22 17:19:53 +08:00
parent b94c64cd1a
commit 854cceb1bb
5 changed files with 15 additions and 7 deletions

View File

@@ -93,6 +93,7 @@ export class ShopDicData {
chosen: number;
indirectId: number;
createTime: number = 0;
isForever: boolean = false;
beginTime: number = 0;
endTime: number = 0;
@@ -117,6 +118,7 @@ export class ShopDicData {
}
setTime(obj: ShopItemInDb, roleTime: number, serverTime: number) {
this.isForever = obj.timeType == ACTIVITY_TIME_TYPE.FOREVER;
switch (obj.timeType) {
case ACTIVITY_TIME_TYPE.SERVER_OPEN_TIME: {
this.beginTime = moment(serverTime * 1000).startOf('d').add(REFRESH_TIME, 'h').unix();
@@ -139,6 +141,11 @@ export class ShopDicData {
}
}
canShow() {
if(this.isForever) return true;
return this.beginTime <= moment().unix() && this.endTime >= moment().unix();
}
public setReadRecord(record: UserShopTypeType) {
let now = nowSeconds();
if(this.beginTime <= now && this.endTime >= now) {
@@ -169,7 +176,7 @@ export class ShopReturnData {
if(!activityData || activityData.shop != this.shop || activityData.type != this.type) return;
this.activityId = activityData.activityId;
for(let obj of activityData.list) {
this.dic.push(obj);
if(obj) this.dic.push(obj);
}
}