update
This commit is contained in:
+71
-14
@@ -59,12 +59,12 @@
|
||||
set_modal_title('登录');
|
||||
})
|
||||
|
||||
// 设置窗口名称
|
||||
/** 设置窗口名称 */
|
||||
function set_modal_title(title) {
|
||||
$('#exampleModal .modal-title').html(title);
|
||||
}
|
||||
|
||||
// 注册
|
||||
/** 注册按钮 */
|
||||
$('#register_button').click(function () {
|
||||
const userName = $('#userName').val();
|
||||
const inputPassword = $('#inputPassword').val();
|
||||
@@ -91,16 +91,30 @@
|
||||
success: function (data) {
|
||||
// 注册成功
|
||||
if (data.code === 0) {
|
||||
|
||||
clear_reg_info()
|
||||
reg_alert(data.msg, 'alert-primary')
|
||||
setTimeout(function () {
|
||||
$('#p_login_a').click()
|
||||
}, 1500)
|
||||
} else {
|
||||
// 注册失败
|
||||
reg_alert(data.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
}
|
||||
//
|
||||
|
||||
// validate end
|
||||
});
|
||||
|
||||
/** 清除注册时输入内容 */
|
||||
function clear_reg_info() {
|
||||
$('#userName').val('');
|
||||
$('#inputPassword').val('');
|
||||
$('#inputPassword_').val('');
|
||||
}
|
||||
|
||||
/**校验密码是否输入一致*/
|
||||
function validate_pw_eq(obj, inputPassword, inputPassword_) {
|
||||
if (inputPassword !== inputPassword_) {
|
||||
reg_alert('两次密码输入不一样,请确认!')
|
||||
@@ -109,22 +123,60 @@
|
||||
return true
|
||||
}
|
||||
|
||||
function reg_alert(text) {
|
||||
/** 注册提示 */
|
||||
function reg_alert(text, class_str) {
|
||||
common_alert('register_button', text, class_str)
|
||||
}
|
||||
|
||||
/** 登录提示 */
|
||||
function login_alert(text, class_str) {
|
||||
common_alert('login_button', text, class_str)
|
||||
}
|
||||
|
||||
function common_alert(button_id, text, class_str) {
|
||||
// 清除之前的弹窗
|
||||
$('.alert').alert('close')
|
||||
//
|
||||
const uuid = '' + (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16)
|
||||
const class_name = class_str ? class_str : 'alert-danger'
|
||||
|
||||
const alert_component = `
|
||||
<div class="alert alert-danger .alert-dismissible fade show" role="alert" id="${uuid}" style="margin-top: 3px;margin-bottom: 3px;height: 30px;padding-top: 2px;padding-bottom: 2px;">
|
||||
<div class="alert ${class_name} .alert-dismissible fade show" role="alert" id="${uuid}" style="clear: both;margin-top: 3px;margin-bottom: 3px;height: 30px;padding-top: 2px;padding-bottom: 2px;">
|
||||
${text}
|
||||
</div>
|
||||
`
|
||||
$('#register_button').after(alert_component)
|
||||
$('#' + button_id).parent().after(alert_component)
|
||||
setTimeout(function () {
|
||||
$('#' + uuid).fadeOut(1200)
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
/**登录按钮*/
|
||||
$('#login_button').click(function () {
|
||||
const userName_login = $('#userName_login').val();
|
||||
const inputPassword_login = $('#inputPassword_login').val();
|
||||
if (!userName_login || !inputPassword_login) {
|
||||
login_alert('请输入用户名和密码')
|
||||
return
|
||||
}
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "login",
|
||||
data: {username: userName_login, password: inputPassword_login},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
// 注册成功
|
||||
if (data.code === 0) {
|
||||
login_alert(data.msg, 'alert-primary')
|
||||
} else {
|
||||
// 注册失败
|
||||
login_alert(data.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
})
|
||||
|
||||
// js end
|
||||
})
|
||||
</script>
|
||||
@@ -161,19 +213,24 @@
|
||||
<label for="inputPassword_" class="sr-only"></label>
|
||||
<input type="password" id="inputPassword_" class="form-control" placeholder="密码" required>
|
||||
|
||||
<button class="btn btn-lg btn-primary btn-block" type="submit" id="register_button">注册</button>
|
||||
<div style="margin-bottom: 10px; text-align:right;">
|
||||
<button class="btn btn-sm btn-primary" type="submit" id="register_button">注册</button>
|
||||
</div>
|
||||
</div>
|
||||
<!--register end-->
|
||||
|
||||
<!--pw_login start-->
|
||||
<div class="modal-body pw_login_group" style="display: none;height: 360px;">
|
||||
<h1 class="h3 mb-3 font-weight-normal">请输入用户名和密码</h1>
|
||||
<label for="userName" class="sr-only">Email address</label>
|
||||
<input type="text" id="userName" class="form-control" placeholder="Email address" required autofocus>
|
||||
<label for="userName_login" class="sr-only">用户名</label>
|
||||
<input type="text" id="userName_login" name="userName_login" class="form-control" placeholder="用户名" required autofocus>
|
||||
|
||||
<label for="inputPassword" class="sr-only">Password</label>
|
||||
<input type="password" id="inputPassword" class="form-control" placeholder="Password" required>
|
||||
<button class="btn btn-lg btn-primary btn-block" type="submit">登录</button>
|
||||
<label for="inputPassword_login" class="sr-only">密码</label>
|
||||
<input type="password" id="inputPassword_login" name="inputPassword_login" class="form-control" placeholder="密码" required>
|
||||
|
||||
<div style="margin-bottom: 10px; text-align:right;">
|
||||
<button class="btn btn-sm btn-primary" id="login_button">登录</button>
|
||||
</div>
|
||||
</div>
|
||||
<!--pw_login end-->
|
||||
|
||||
|
||||
Reference in New Issue
Block a user