pbootcms会员中心登录页面模板核心代码及位置
时间 :
2022-07-29
编辑 :超级管理员

登录页面是login.html
核心代码是
<form class="my-4" onsubmit="return login(this);">
<div class="form-group">
<label for="username">账 号</label>
<div>
<input type="text" name="username" required id="username" class="form-control" placeholder="请输入登录用户名/邮箱/手机号码">
</div>
</div>
<div class="form-group">
<label for="password">密 码</label>
<div>
<input type="password" name="password" required id="password" class="form-control" placeholder="请输入登录密码">
</div>
</div>
{pboot@if({pboot:logincodestatus})}
<div class="form-group">
<label for="checkcode">验证码</label>
<div class="row">
<div class="col-6">
<input type="text" name="checkcode" required id="checkcode" class="form-control" placeholder="请输入验证码">
</div>
<div class="col-6">
<img title="点击刷新" style="height:33px;" id="codeimg" src="{pboot:checkcode}" onclick="this.src='{pboot:checkcode}?'+Math.round(Math.random()*10);" />
</div>
</div>
</div>
{/pboot@if}
<div class="form-group">
<button type="submit" class="btn btn-info mb-2">立即登录</button>
<span class="text-secondary ml-3">没有账号?<a href="{pboot:register}">马上注册</a></span>
</div>
</form>
<script>
//ajax登录
function login(obj){
var url='{pboot:login}';
var username=$(obj).find("#username").val();
var password=$(obj).find("#password").val();
var checkcode=$(obj).find("#checkcode").val();
$.ajax({
type: 'POST',
url: url,
dataType: 'json',
data: {
username: username,
password: password,
checkcode: checkcode
},
success: function (response, status) {
if(response.code){
alert("登录成功!");
location.href=response.tourl;
}else{
$('#codeimg').click();
alert(response.data);
}
},
error:function(xhr,status,error){
alert('返回数据异常!');
}
});
return false;
}
</script>
