2023-02-11 13:21:06 +08:00
|
|
|
import './index.less';
|
|
|
|
import { RegUtil } from '@backset/util';
|
2023-02-22 17:59:35 +08:00
|
|
|
import $ from 'cash-dom';
|
2023-02-11 13:21:06 +08:00
|
|
|
|
2023-02-17 17:59:41 +08:00
|
|
|
$(() => {
|
2023-02-11 13:21:06 +08:00
|
|
|
$('#page-signup')
|
|
|
|
.on('click', '#btn-switch-login-type', handleSwitchLoginType)
|
|
|
|
.on('click', '#btn-signup-password', handlePasswordLogin)
|
|
|
|
.on('click', '#btn-signup-verify', handleVerifyLogin)
|
|
|
|
.on('click', '#btn-verify-code', handleGetVerifyCode);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取验证码
|
|
|
|
*/
|
|
|
|
function handleGetVerifyCode() {
|
2023-02-17 17:59:41 +08:00
|
|
|
const params = { phone: '' + $('#tel').val() };
|
2023-02-11 13:21:06 +08:00
|
|
|
if (!RegUtil.PHONE.test(params.phone)) return;
|
|
|
|
// return message.error({ text: '手机号格式错误' });
|
|
|
|
$('#btn-verify-code').addClass('loading');
|
2023-02-22 17:59:35 +08:00
|
|
|
// $.post('/sms/verify', params, res => {
|
|
|
|
// console.log(res);
|
|
|
|
// if (res) {
|
|
|
|
// $('#btn-verify-code').removeClass('loading');
|
|
|
|
// }
|
|
|
|
// });
|
2023-02-11 13:21:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 验证码登录
|
|
|
|
*/
|
|
|
|
function handleVerifyLogin() {
|
2023-02-17 17:59:41 +08:00
|
|
|
const params = {
|
2023-02-11 13:21:06 +08:00
|
|
|
login_type: 'verifycode',
|
|
|
|
user_login: '' + $('#tel').val(),
|
|
|
|
verify_code: '' + $('#verify-code').val(),
|
|
|
|
};
|
2023-02-22 17:59:35 +08:00
|
|
|
// $.post('/auth/user/login', params, res => {
|
|
|
|
// console.log(res);
|
|
|
|
// });
|
2023-02-11 13:21:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 密码登录
|
|
|
|
*/
|
|
|
|
function handlePasswordLogin() {
|
2023-02-17 17:59:41 +08:00
|
|
|
const params = {
|
2023-02-11 13:21:06 +08:00
|
|
|
login_type: 'password',
|
|
|
|
user_login: '' + $('#username').val(),
|
|
|
|
user_pass: '' + $('#password').val(),
|
|
|
|
};
|
2023-02-22 17:59:35 +08:00
|
|
|
// $.post('/auth/user/login', params, res => {
|
|
|
|
// console.log(res);
|
|
|
|
// });
|
2023-02-11 13:21:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 点击登录方式切换
|
|
|
|
*/
|
2023-02-17 17:59:41 +08:00
|
|
|
function handleSwitchLoginType(this: any) {
|
2023-02-11 13:21:06 +08:00
|
|
|
const switchVerify = $(this).attr('data-login-type') === 'password';
|
|
|
|
if (switchVerify) {
|
|
|
|
$('#verify-form').removeClass('d-none');
|
|
|
|
$('#password-form').addClass('d-none');
|
|
|
|
$(this).attr('data-login-type', 'verify').html('密码登陆');
|
|
|
|
} else {
|
|
|
|
$('#verify-form').addClass('d-none');
|
|
|
|
$('#password-form').removeClass('d-none');
|
|
|
|
$(this).attr('data-login-type', 'password').html('验证码登陆');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|