登录:显示防沉迷类型

This commit is contained in:
luying
2021-03-13 15:07:41 +08:00
parent fef762747f
commit 482d4fa628
4 changed files with 29 additions and 17 deletions

View File

@@ -4,7 +4,7 @@ import { DEFAULT_HEROES } from '@consts';
import { HeroModel } from '@db/Hero';
import { RoleModel } from '@db/Role';
import { UserModel, UserType } from '@db/User';
import { STATUS, GET_SMS_TYPE } from '@consts';
import { STATUS, GET_SMS_TYPE, ADDICTION_PREVENTION_CODE } from '@consts';
import { smsModel } from '@db/Sms';
import { Service } from 'egg';
import Counter from '@db/Counter';
@@ -95,9 +95,15 @@ export default class Auth extends Service {
let age = getAge(user.birthday);
let isAdult = age >= ADULT_AGE;
let todayPlayTime = user.todayPlayTime;
let type = user.todayPlayType;
if(shouldRefresh(user.reportTime, new Date(), 0)) {
todayPlayTime = 0;
type = 0;
}
if((user.isGuest || !user.hasAuthenticated) && user.guestTime > GUEST_MAX_TIME) {
type = ADDICTION_PREVENTION_CODE.GUEST;
}
return {
tel: user.tel,
isGuest: !!user.isGuest,
@@ -105,7 +111,7 @@ export default class Auth extends Service {
hasAuthenticated: !!user.hasAuthenticated, // 是否进行过实名认证
isAdult, // 是否已成年
todayPlayTime, // 今天已游戏时长
type, // 防沉迷类型
hasSetPw: user.hasSetPw, // 是否设置了密码
token: user.token, // 用户token
userCode: user.userCode // 用户标识

View File

@@ -40,7 +40,7 @@ export default (appInfo: EggAppInfo) => {
},
};
config.decodeParm = false;
config.decodeParm = true;
config.static = {
prefix: '/',