first commit
This commit is contained in:
137
陈海波/投标平台/qiyeduan/src/application/logic/page/Login.logic.ts
Normal file
137
陈海波/投标平台/qiyeduan/src/application/logic/page/Login.logic.ts
Normal file
@@ -0,0 +1,137 @@
|
||||
import { BaseLogic, KeyParams, Methods } from "@logic/Base.logic";
|
||||
import { Inject } from "@ann/Ioc.annotation";
|
||||
import { UserServiceImpl } from "@impl/User.service.impl";
|
||||
import { PublicServiceImpl } from '@/core/service/impl/Public.Service.impl';
|
||||
|
||||
export class LoginLogic extends BaseLogic implements Methods {
|
||||
|
||||
@Inject()
|
||||
public readonly UserServiceImpl!: UserServiceImpl;
|
||||
|
||||
@Inject()
|
||||
public readonly PublicServiceImpl!: PublicServiceImpl;
|
||||
|
||||
// 用户登录需要的参数
|
||||
public UserLogin: KeyParams = {
|
||||
username: '',
|
||||
password: ''
|
||||
}
|
||||
|
||||
// 注册用户需要的参数
|
||||
public UserReg: KeyParams = {
|
||||
cellphone: '',
|
||||
password: '',
|
||||
verify_code: '',
|
||||
true_name: ''
|
||||
}
|
||||
|
||||
// 忘记密码接口需要的参数
|
||||
public UserForget: KeyParams = {
|
||||
cellphone: '',
|
||||
verify_code: '',
|
||||
password: ''
|
||||
}
|
||||
|
||||
// 注册的时候是否同意协议
|
||||
public isAgreeReg: boolean = false
|
||||
|
||||
// 短信验证码
|
||||
public SmsStatus: KeyParams = {
|
||||
NoStartText: '发送验证码',
|
||||
ButtonDisabled: false,
|
||||
StartText: 60,
|
||||
timer: null,
|
||||
}
|
||||
|
||||
// 1 登录 2 注册 3 忘记密码
|
||||
public ShowAction: number = 1;
|
||||
|
||||
constructor(point: any) {
|
||||
super();
|
||||
this.VueApp = point;
|
||||
}
|
||||
|
||||
public async StartUp(): Promise<void> {
|
||||
console.log(111)
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除发送验证码的定时器
|
||||
*/
|
||||
public clearSendCode() {
|
||||
clearInterval(this.SmsStatus.timer);
|
||||
this.SmsStatus.NoStartText = "发送验证码";
|
||||
this.SmsStatus.ButtonDisabled = false;
|
||||
this.SmsStatus.StartText = 60
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击发送验证码
|
||||
* @constructor
|
||||
*/
|
||||
public SendCode(): void {
|
||||
//倒计时
|
||||
let time = 60;
|
||||
this.SmsStatus.timer = setInterval(() => {
|
||||
if (time == 0) {
|
||||
clearInterval(this.SmsStatus.timer);
|
||||
this.SmsStatus.ButtonDisabled = false;
|
||||
this.SmsStatus.NoStartText = "获取验证码";
|
||||
} else {
|
||||
this.SmsStatus.NoStartText = time + '秒后重试';
|
||||
this.SmsStatus.ButtonDisabled = true;
|
||||
time--
|
||||
}
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
* @constructor
|
||||
*/
|
||||
public async ResetPassword(): Promise<void> {
|
||||
let res = await this.UserServiceImpl.ForgetPassword(this.UserForget)
|
||||
this.ShowAction = 1
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户登录
|
||||
* @constructor
|
||||
*/
|
||||
public async UserLoginRequest(): Promise<void> {
|
||||
let res = await this.UserServiceImpl.LoginIndex(this.UserLogin);
|
||||
localStorage.setItem("token", res.token);
|
||||
setTimeout(() => {
|
||||
this.VueApp.$router.replace("/Logrc/Index")
|
||||
}, 500);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户注册
|
||||
* @constructor
|
||||
*/
|
||||
public async UserRegRequest(): Promise<void> {
|
||||
if (this.isAgreeReg) {
|
||||
let res = await this.UserServiceImpl.BidderLoginReg(this.UserReg);
|
||||
this.ShowAction = 1;
|
||||
} else {
|
||||
this.VueApp.$notify.error({
|
||||
title: '提示',
|
||||
message: '请先勾选《用户协议》!!'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取手机验证码
|
||||
* @param scene
|
||||
*/
|
||||
public async getSmsCode(scene: string) {
|
||||
let cellphone = scene !== 'reg' ? this.UserForget.cellphone : this.UserReg.cellphone
|
||||
let res = await this.PublicServiceImpl.getSmsCode({
|
||||
cellphone: cellphone || '',
|
||||
scene: scene
|
||||
})
|
||||
Promise.resolve()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user