话不多说,直接上代码
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="user-scalable=yes" />
<meta name="description" content="<?php echo $setting->description?>">
<meta name="keywords" content="<?php echo $setting->keywords?>">
<title>登陆</title>
<?php include YILU_DIR.'/app/view/page/cssPath.php'?>
<style>
.login input{
padding-left: 10px;
}
.form{
width: 330px;
}
.form .tabs .tab{
color: #888888;
}
</style>
</head>
<body>
<div class="wrapper">
<?php include YILU_DIR.'/app/view/page/head.php'?>
<div class="top clearfix">
<div class="container">
<img class="pointer" src="<?php echo DOMAIN.$setting->logo; ?>" onclick="window.location.href='<?php echo yilu_site_url() ?>'"/>
</div>
</div><!--top-->
<div class="login">
<div class="container">
<img src="<?php echo DOMAIN.$setting->login_banner; ?>" style="margin-left: -362px"/>
<div class="form form-change" id="login">
<div class="tabs">
<div class="tab on" data-target="loginForm">密码登陆</div>
<div class="tab" data-target="codeLoginForm">验证码登陆</div>
</div>
<div class="tab-contents" id="loginForm">
<div class="content">
<input type="text" class="input" name="mobile" value="<?php echo $nickname; ?>" placeholder="手机号"/>
<input type="password" name="password" class="input" value="<?php echo $token; ?>" placeholder="密码"/>
<div class="input-group">
<input type="text" name="code" class="input input-change" placeholder="验证码"/>
<img class="btn pointer" src="<?php echo yilu_site_url('web_code') ?>" align="absbottom" onclick="this.src='<?php echo yilu_site_url('web_code') ?>&t='+Math.random();" />
</div>
<div class="tip-both">
<a name="forgetPassword">忘记密码</a>
<input type="checkbox" name="holdPas" <?php if($holdPass){echo 'checked="checked"';} ?> value="autoLogin"/>7天内自动登陆
</div>
<button type="button" class="primary" name="login">登陆</button>
<div class="tip-center">没有账号?<a href="<?php echo yilu_site_url();?>">免费注册</a></div>
</div>
</div>
<div class="tab-contents" id="codeLoginForm" style="display: none">
<div class="content">
<input type="text" class="input" name="mobile" value="<?php echo $mobile; ?>" placeholder="手机号"/>
<div class="input-group" style="display: flex">
<input style="width: 60%;height: 34px" type="text" name="mobileCode" class="input" placeholder="请输入短信验证码" data-pattern="\S+" data-error="短信验证码不能为空"/>
<button style="width: 40%" class="btn" name="sendCode">发送验证码</button>
</div>
<!-- <div class="tip-both">-->
<!-- <a href="--><?php //echo yilu_site_url('edit'); ?><!--">忘记密码</a>-->
<!-- <input type="checkbox" name="holdPas" --><?php //if($holdPass){echo 'checked="checked"';} ?><!-- value="autoLogin"/>7天内自动登陆-->
<!-- </div>-->
<button type="button" class="primary" name="login">登陆</button>
<div class="tip-center">没有账号?<a href="<?php echo yilu_site_url('register');?>">免费注册</a></div>
</div>
</div>
</div>
<div class="form" id="forgetPas" style="display: none">
<div class="tabs">
<div>找回密码</div>
</div>
<div class="tab-contents">
<div class="tab-contents">
<div class="content">
<input type="text" class="input" name="mobile" placeholder="请输入手机号" data-pattern="\d+" data-error="手机号不能为空"/>
<div class="input-group">
<input type="text" class="input" name="mobileCode" placeholder="输入短信验证码" data-pattern="\S+" data-error="短信验证码不能为空"/>
<button class="btn" name="sendCode">获取</button>
</div>
<div class="input-group">
<input type="password" style="width: 100%" class="input" name="password" placeholder="输入新密码"/>
</div>
<div class="input-group">
<input type="password" style="width: 100%" class="input" name="checkPassword" placeholder="请再输入一次新密码"/>
</div>
<button type="button" class="primary" name="resetPassword">重置密码</button>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include YILU_DIR.'/app/view/page/foot.php'?>
</div>
<?php include YILU_DIR.'/app/view/page/bottomScript.php'?>
<!-- jQuery -->
<script type="text/javascript">
(function() {
$(".tab").click(function () {
$(".tab").removeClass('on');
$(this).addClass("on");
var target = $(this).attr("data-target");
$(".tab-contents").hide();
$("#" + target).show();
});
var form = $("#loginForm");
form.find("input").keydown(function(e){
e = e || window.event;
if (e.keyCode == 13){
login();
}
});
form.find("button[name='login']").click(function(){
login()
});
function login(){
var params = Util.parseForm(form);
console.log(params)
params['password'] = hex_md5(params['password']);
var urlString = "<?php echo yilu_site_url('check_login'); ?>";
Util.post(urlString,params,function(){
if(document.referrer.indexOf('f=register') != -1){
window.location.href = 'http://www.tuilala.com/index.php';
} else{
//window.history.back();
window.location.href = 'http://www.tuilala.com/index.php';
}
//location.href = "<?php echo yilu_site_url()?>";
});
}
var codeLoginForm = $("#codeLoginForm");
codeLoginForm.find("input").keydown(function(e){
e = e || window.event;
if (e.keyCode == 13){
mobileLogin();
}
});
codeLoginForm.find("button[name='login']").click(function(){
mobileLogin()
});
function mobileLogin(){
var params = Util.parseForm(codeLoginForm);
var urlString = "<?php echo yilu_site_url('check_mobile_login'); ?>";
Util.post(urlString,params,function(){
if(document.referrer.indexOf('f=register') != -1){
window.location.href = 'http://www.tuilala.com/index.php';
} else{
//window.history.back();
window.location.href = 'http://www.tuilala.com/index.php';
}
// showFail('登陆成功',function () {
//
// location.href = "<?php //echo yilu_site_url()?>//";
// });
});
}
var forgetPassForm = $("#forgetPas");
$("a[name='forgetPassword']").click(function () {
$(".form").hide();
forgetPassForm.find(".tab-contents").show();
forgetPassForm.show();
});
forgetPassForm.find("button[name='resetPassword']").click(function(){
if(!Util.checkValidity(forgetPassForm)){
return;
}
var params = Util.parseForm(forgetPassForm);
if(params['password'] != params['checkPassword']){
showFail('密码输入不一致');
return;
}
params.password = hex_md5(params.password);
var urlString = "<?php echo yilu_site_url('reset_password'); ?>";
Util.post(urlString,params,function (data) {
showFail("设置成功",function () {
window.location.reload();
});
});
});
$("button[name='sendCode']").click(function () {
var sendCodeButton = $(this);
var mobile = sendCodeButton.closest(".tab-contents").find("input[name='mobile']").val();
if(!Util.checkMobile(mobile)){
return;
}
var params = {mobile:mobile};
var urlString = "<?php echo yilu_site_url('send_mobile_code'); ?>";
Util.post(urlString,params,function () {
showFail("验证码已发送");
codeTime(sendCodeButton[0]);
});
});
})();
</script>
</body>
</html>