From 039360bb9736cf6b40c5fcca9a829e0fd5b454b9 Mon Sep 17 00:00:00 2001 From: qiaoxin Date: Thu, 3 Jun 2021 17:06:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B4=BB=E5=8A=A8=EF=BC=9A=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=AD=BE=E5=88=B0=E6=97=B6=E9=97=B4=E6=8C=89=E7=85=A75?= =?UTF-8?q?=E7=82=B9=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shared/domain/activityField/signInField.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/shared/domain/activityField/signInField.ts b/shared/domain/activityField/signInField.ts index 51999ed40..a24c02962 100644 --- a/shared/domain/activityField/signInField.ts +++ b/shared/domain/activityField/signInField.ts @@ -1,5 +1,5 @@ import moment = require('moment'); -import { ACTIVITY_TYPE, SERVER_OPEN_TIME, SIGNIN_CLOSE, SIGNIN_OPEN } from '../../consts'; +import { ACTIVITY_TYPE, REFRESH_TIME, SERVER_OPEN_TIME, SIGNIN_CLOSE, SIGNIN_OPEN } from '../../consts'; import { ActivityModelType } from '../../db/Activity'; import { ActivitySignInModelType } from '../../db/ActivitySignIn'; import { deltaDays } from '../../pubUtils/util'; @@ -63,7 +63,8 @@ export class SignInData extends ActivityBase { this.beginTime = moment(beginTime).valueOf(); this.endTime = moment(endTime).valueOf(); this.roundIndex = 1; - this.todayIndex = deltaDays(moment(beginTime).startOf('d').toDate(), new Date) + 1; + let date = new Date(); + this.todayIndex = Math.ceil((moment(date).valueOf() - this.beginTime) / 24 * 60 * 60 * 1000); } public initData(data: string) { @@ -76,13 +77,13 @@ export class SignInData extends ActivityBase { this.endDate = dataObj.endDate ? dataObj.endDate : SIGNIN_CLOSE; let date = new Date(); - this.beginTime = moment(date.setDate(this.startDate)).startOf('day').valueOf(); - this.endTime = moment(date.setDate(this.endDate)).endOf('day').valueOf(); + this.beginTime = moment(date.setDate(this.startDate)).startOf('day').add(REFRESH_TIME, 'h').valueOf(); + this.endTime = moment(date.setDate(this.endDate)).endOf('day').add(REFRESH_TIME, 'h').valueOf(); this.roundIndex = moment().diff(moment(SERVER_OPEN_TIME).startOf('months'), 'months') + 1; if (this.type === ACTIVITY_TYPE.NEW_PLAYER_SIGN_IN) { this.roundIndex = 1; } - this.todayIndex = moment(Date.now()).date() - this.startDate + 1; + this.todayIndex = Math.ceil((moment(date).valueOf() - this.beginTime) / 24 * 60 * 60 * 1000); let arr = dataObj.data for (let obj of arr) {