更新忘记密码

master
chenzhi 5 years ago
parent 5f4dca0a77
commit ba4219dc64

@ -164,6 +164,33 @@ class SsgController extends BaseController {
$this -> set_message(1, "success", "添加成功");
}
//忘记密码
public function forgetPassword()
{
$user = $_POST;
if (empty($user)) {
$this -> set_message(1001, "fail", "基础信息不能为空");
}
$this -> sms_verify($user['account'], $user['code']);
//更新密码
$userApi = new MemberApi();
$userInfo = M("user","tab_")->where("account = '".$user['account']."'")->find();
if(empty($userInfo)){
$this -> set_message(1003, "fail", "用户不存在");
}
//更新用户
$upres = $userApi->updatePassword($userInfo['id'], $user['password']);
if($upres){
//自动登陆
$user_id = $userApi->login($user['account'], $user['password'],1);
$this -> set_message(0, "success", "修改成功");
}else{
$this -> set_message(1005, "fail", "密码更新错误,请刷新后再次尝试");
}
# code...
}
//普通注册
public function userRegister()
{

@ -17,7 +17,7 @@
<!---登陆弹框-->
<div id="alert_box" style="height: 100vh;background:rgba(41,41,41,.8);position:fixed;z-index:9999;top: 0px;width: 100%;display: none;">
<div style="top:50%;margin-top: -1.5rem;position: fixed;width: 6.3rem;left: 50%;margin-left: -3.2rem;background-color: #fff;border-radius:.2rem;">
<div style="line-height:1.4rem;font-size:.32rem;text-align: center;">
<div id="alert_content" style="line-height:1.4rem;font-size:.32rem;text-align: center;">
注册成功,三秒后将自动登陆。
</div>
<a onclick="hideAndLogin()" href="javascript:" style="line-height:1rem;font-size:.32rem;text-align: center;color: #21B1EB;width: 100%;display: block;border-top: 1px solid #f5f5f5;">
@ -68,9 +68,17 @@
</div>
</div>
<div class="login-footer">
<img src="__IMG__/ssg/login/kf.png">
<div class="chatqq">
联系客服
<div class="login-footer">
<img src="__IMG__/ssg/login/forget.png">
<div class="forget content">
忘记密码
</div>
</div>
<div class="login-footer">
<img src="__IMG__/ssg/login/kf.png">
<div class="chatqq content">
联系客服
</div>
</div>
</div>
</div>
@ -115,9 +123,7 @@
</div>
</div>
</div>
</div>
</div>
<div class="swiper-slide swiper-no-swiping">
<!--普通注册-->
@ -155,20 +161,115 @@
</div>
</div>
</div>
</div>
</div>
<div class="swiper-slide swiper-no-swiping">
<!--忘记密码-->
<div class="loginbox">
<div class="title">
<img class="gologin" src="__IMG__/ssg/login/back.png">
<div>忘记密码</div>
<div class="titleright"></div>
</div>
<div class="formitem" style="margin-top: 0px;">
<img src="__IMG__/ssg/login/phone.png">
<input id="forgetPhoneval" type="text" placeholder="请输入手机号" value="">
</div>
<div class="formitem">
<img src="__IMG__/ssg/login/password.png">
<input id="forgetPhonepassword" type="password" placeholder="请输入新密码" value="">
</div>
<div class="formitem" style="border: 0px;">
<div class="formitem" style="margin-right: .2rem;margin-top: 0px;width: 3.5rem;">
<img src="__IMG__/ssg/login/code.png">
<input id="forgetPhonecode" type="text" placeholder="请输入短信验证码" value="" style="width:2.5rem;">
</div>
<div id="forgetGetPhoneCode" class="phonecodebtn">
获取验证码
</div>
</div>
<!---按钮-->
<div id="forgetBtn" class="login-btn-group">
<div class="login-btn-big" style="background: url('__IMG__/ssg/login/bigbuttonbg.png') no-repeat top center/cover;">
确定
</div>
</div>
<div class="reg-footer">
<div style="max-width:3.2rem;font-size: .20rem;"><i style="color: red;margin-right: 5px;">*</i>未绑定手机号的用户请联系客服:<br/><span style="margin-left: 10px;">在线客服:{$app_qq}</span></div>
<div class="reg-change">
<img src="__IMG__/ssg/login/kf.png">
<div class="chatqq">
联系客服
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script src="__JS__/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="__JS__/swiper.min.js" type="text/javascript"></script>
<script>
var PhoneObj = {
i:60,
codeflag:true,
//验证手机
checkPhone:function(phone){
if(!(/^1[3456789]\d{9}$/.test(phone))){
alert("手机号码有误,请重填");
return false;
} else{
return true;
}
},
//倒计时
countDown:function(dom){
PhoneObj.codeflag = false;
PhoneObj.i = PhoneObj.i - 1;
dom.html(PhoneObj.i+"秒后重发").css("backgroundColor","#f5f5f5").css("color","#A9A9A9");
if (PhoneObj.i == 0) {
dom.html("重新发送").css("backgroundColor","#21B1EB").css("color","#fff");
PhoneObj.codeflag = true;
PhoneObj.i = 60;
return;
}
setTimeout(function(){
PhoneObj.countDown(dom)
},1000);
},
//获取验证码
sendPhoneCode:function(phone,fun){
if(PhoneObj.codeflag){
if(PhoneObj.checkPhone(phone)){
//获取验证码
$.ajax({
type: 'GET',
url: 'mobile.php?s=/Ssg/sendPhoneCode.html&phone='+phone,
dataType: 'JSON',
success: function (result) {
if (result.status != 1) {
alert(result.msg);
} else {
fun()
}
}
})
}
}else{
alert("发送验证码频率过高,请等待"+PhoneObj.i+"秒后再试")
}
}
}
</script>
<script type="text/javascript">
var mySwiper = new Swiper('.swiper-container', {
// autoplay: true,//可选选项,自动滑动
// initialSlide :2,
initialSlide :3,
// effect : 'fade',
noSwiping : true,
})
checkSafari()
@ -189,12 +290,14 @@
mySwiper.slideTo(0, 350, false);
})
$(".back").on("click",function(){
window.location.href='{:U("home")}';
window.location.href='{:U("home"),"&promote_id=".$promote_id}';
})
$(".chatqq").on("click",function(){
window.location.href = 'mqqwpa://im/chat?chat_type=wpa&uin={$app_qq}&version=1&src_type=web&web_src=oicqzone.com';
})
$(".forget").on("click",function(){
mySwiper.slideTo(3, 500, false);
})
//获取验证码
@ -245,15 +348,13 @@
}
});
})
//倒计时
var codeflag = true;
//手机注册按钮
$("#phonereg").on("click",function(){
var phone = $('#phoneval').val();
var phonepassword = $('#phonepassword').val();
var phonecode = $('#phonecode').val();
var promoteId = $("#promote_id").val();
if(!checkPhone(phone)){
if(!PhoneObj.checkPhone(phone)){
return false;
}
if(phonepassword.length < 6 || phonepassword.length > 15){
@ -261,7 +362,7 @@
return false;
}
var pwdRegex = new RegExp('(?=.*[0-9])(?=.*[a-zA-Z]).{8,30}');
var pwdRegex = new RegExp('(?=.*[0-9])(?=.*[a-zA-Z])');
if (!pwdRegex.test(phonepassword)) {
alert("您的密码复杂度太低(密码中必须包含字母、数字)!");
return false;
@ -288,9 +389,6 @@
} else {
$("#alert_box").show();
setTimeout(hideAndLogin,2500)
//成功
// alert("注册成功,三秒后将自动登陆");
// window.location.href = "mobile.php?s=/Ssg/index.html"
}
}
})
@ -303,42 +401,20 @@
//获取手机验证码
$("#getPhoneCode").on("click",function(){
//获取手机
var dom = $(this);
var phone = $('#phoneval').val();
if(codeflag){
if(checkPhone(phone)){
//获取验证码
$.ajax({
type: 'GET',
url: 'mobile.php?s=/Ssg/sendPhoneCode.html&phone='+phone,
dataType: 'JSON',
success: function (result) {
console.log(result)
if (result.status != 1) {
alert(result.msg);
} else {
countDown();
}
}
})
}
}
})
var i = 60;
function countDown() {
codeflag = false;
i = i - 1;
$("#getPhoneCode").html(i+"秒后重发").css("backgroundColor","#f5f5f5").css("color","#A9A9A9");
if (i == 0) {
$("#getPhoneCode").html("重新发送").css("backgroundColor","#21B1EB").css("color","#fff");
codeflag = true;
i = 60;
return;
}
setTimeout('countDown()',1000);
}
PhoneObj.sendPhoneCode(phone,function(){
PhoneObj.countDown(dom);
});
})
$("#forgetGetPhoneCode").on("click",function(){
//获取手机
var dom = $(this);
var phone = $('#forgetPhoneval').val();
PhoneObj.sendPhoneCode(phone,function(){
PhoneObj.countDown(dom);
});
})
//普通注册
$("#userreg").on("click",function(){
var account = $('#regaccount').val();
@ -391,15 +467,49 @@
})
})
//验证手机
function checkPhone(phone){
if(!(/^1[3456789]\d{9}$/.test(phone))){
alert("手机号码有误,请重填");
return false;
} else{
return true;
//忘记密码
$("#forgetBtn").on("click",function(){
var phone = $('#forgetPhoneval').val();
var phonepassword = $('#forgetPhonepassword').val();
var phonecode = $('#forgetPhonecode').val();
if(!PhoneObj.checkPhone(phone)){
return false;
}
}
if(phonepassword.length < 6 || phonepassword.length > 15){
alert('密码长度6-15个字符');
return false;
}
var pwdRegex = new RegExp('(?=.*[0-9])(?=.*[a-zA-Z])');
if (!pwdRegex.test(phonepassword)) {
alert("您的密码复杂度太低(密码中必须包含字母、数字)!");
return false;
}
if(phonecode == ''){
alert('请输入验证码');
return false;
}
$.ajax({
type: 'POST',
url: 'mobile.php?s=/Ssg/forgetPassword.html',
dataType: 'JSON',
data:{
account:phone,
password:phonepassword,
code:phonecode
},
success: function (result) {
console.log(result)
if (result.return_code == 'fail') {
alert(result.return_msg);
} else {
$("#alert_content").html("密码修改成功,系统将在三秒后自动登录");
$("#alert_box").show();
setTimeout(hideAndLogin,2500)
}
}
})
})
function checkSafari() {
var promoteId = $("#promote_id").val();
var ua = navigator.userAgent.toLowerCase();

@ -480,7 +480,7 @@ font-size: .16rem;
.login-page .loginbox .login-footer img{
width: .3rem;height: .3rem;
}
.login-page .loginbox .login-footer .chatqq{
.login-page .loginbox .login-footer .content{
font-size: .24rem;color:#21B1EB;margin-left: .1rem;
}
.login-page .loginbox .login-btn-group .login-btn-big{

Binary file not shown.

Before

Width:  |  Height:  |  Size: 963 KiB

After

Width:  |  Height:  |  Size: 956 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 654 KiB

After

Width:  |  Height:  |  Size: 649 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Loading…
Cancel
Save