活动:新手签到活动
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import moment = require('moment');
|
||||
import { ACTIVITY_RESOURCES_TYPE, SIGNIN_CLOSE, SIGNIN_OPEN } from '../../consts';
|
||||
import { ACTIVITY_RESOURCES_TYPE, ACTIVITY_TYPE, SERVER_OPEN_TIME, SIGNIN_CLOSE, SIGNIN_OPEN } from '../../consts';
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
import { ActivitySignInModelType } from '../../db/ActivitySignIn';
|
||||
import { deltaDays } from '../../pubUtils/util';
|
||||
import { ActivityBase } from './activityField';
|
||||
|
||||
|
||||
@@ -57,25 +58,37 @@ export class SignInData extends ActivityBase {
|
||||
this.isVip = true
|
||||
}
|
||||
|
||||
//设置新手签到时间
|
||||
public setNewPlayerDate(beginTime: Date, endTime: Date) {
|
||||
this.beginTime = moment(beginTime).valueOf();
|
||||
this.endTime = moment(endTime).valueOf();
|
||||
this.roundIndex = 1;
|
||||
this.todayIndex = deltaDays(moment(beginTime).startOf('d').toDate(), new Date) + 1;
|
||||
}
|
||||
|
||||
public initData(data: string) {
|
||||
let dataObj = JSON.parse(data);
|
||||
this.price = dataObj.price;
|
||||
this.productID = dataObj.productID;
|
||||
this.consume = dataObj.consume;
|
||||
|
||||
this.startDate = dataObj.startDate ? dataObj.startDate : SIGNIN_OPEN;
|
||||
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.price = dataObj.price;
|
||||
this.productID = dataObj.productID;
|
||||
this.consume = dataObj.consume;
|
||||
this.roundIndex = moment().diff(moment(this.beginTime).startOf('months'), 'months') + 1;
|
||||
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;
|
||||
|
||||
let arr = dataObj.data
|
||||
for (let obj of arr) {
|
||||
this.list.push(new SignInItem(obj))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
constructor(activityData: ActivityModelType) {
|
||||
|
||||
@@ -66,7 +66,7 @@ export class ThirtyDaysItem {
|
||||
reward: string; //任务奖励,格式:1&3&1(类型&id&数量) 类型定义:1.英雄,2.物品
|
||||
point: number; // 任务达成获得的奖励点,只在当前活动中有用,虚拟
|
||||
|
||||
|
||||
totalCount: number = 0; //任务完成次数
|
||||
isComplete: boolean = false; //是否完成任务
|
||||
isReceive: boolean = false; //是否领取过奖励
|
||||
|
||||
@@ -81,6 +81,10 @@ export class ThirtyDaysItem {
|
||||
this.reward = data.reward;
|
||||
this.point = data.point;
|
||||
|
||||
this.totalCount = 0;
|
||||
this.isComplete = false;
|
||||
this.isReceive = false;
|
||||
|
||||
this.taskParamArray = splitString(data.taskParam, '&')
|
||||
}
|
||||
|
||||
@@ -229,6 +233,7 @@ export class ThirtyDaysData extends ActivityBase {
|
||||
let itemData = this.findThirtyDaysItem(record.pageIndex, record.cellIndex, record.tab)
|
||||
if (itemData) {
|
||||
itemData.isReceive = record.isReceive === true;
|
||||
itemData.totalCount = record.totalCount ? record.totalCount : 0;
|
||||
itemData.isComplete = record.totalCount >= itemData.condition;
|
||||
if (itemData.isReceive) {
|
||||
this.totalPoint += itemData.point;
|
||||
|
||||
Reference in New Issue
Block a user