1.0

parent ea23a175
...@@ -148,4 +148,5 @@ class ApiController extends Controller ...@@ -148,4 +148,5 @@ class ApiController extends Controller
} }
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Http\Requests; use App\Http\Requests;
use App\Model\SupplierAccountModel;
use Gregwar\Captcha\CaptchaBuilder; use Gregwar\Captcha\CaptchaBuilder;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Plugin\Session; use App\Plugin\Session;
...@@ -63,7 +64,19 @@ class HelperController extends Controller { ...@@ -63,7 +64,19 @@ class HelperController extends Controller {
$check2 = SendMsg(['code'=>$moblie_code],'login-code',[$mobile]);//发送验证码 $check2 = SendMsg(['code'=>$moblie_code],'login-code',[$mobile]);//发送验证码
$check1 == 'OK' ? Export([0,'成功']) : Export([1002,'生成手机验证码失败']); $check1 == 'OK' ? Export([0,'成功']) : Export([1002,'生成手机验证码失败']);
} }
/*
* 找回密码发送手机验证码
*/
private function forgetMobile($request){
(new SupplierAccountModel())->forgetMobileCode($request->input());
}
/*
* 判断手机验证码是否正确
*/
private function checkMobileCode($request){
$check = (new SupplierAccountModel())->checkMobileCode($request->input("mobile"),$request->input("code"));
$check ? Export(0,'存在') : Export(1001,'不存在');
}
} }
...@@ -50,6 +50,7 @@ class WebController extends Controller ...@@ -50,6 +50,7 @@ class WebController extends Controller
} }
//找回密码 //找回密码
private function ForgetPassword($request,$data,$id){ private function ForgetPassword($request,$data,$id){
$data['mobile'] = $request->mobile;
$data['title']='忘记密码'; $data['title']='忘记密码';
return view('pc.ForgetPassword',$data); return view('pc.ForgetPassword',$data);
} }
......
...@@ -22,6 +22,7 @@ class CheckLogin ...@@ -22,6 +22,7 @@ class CheckLogin
$isApi = false; $isApi = false;
if ($pos === 0) $isApi = true; if ($pos === 0) $isApi = true;
$request->supplier_name = ""; //登录用户名
if (empty($yunxin_token) || empty($userInfo) ){ //没有登录跳到登录页 if (empty($yunxin_token) || empty($userInfo) ){ //没有登录跳到登录页
if (strpos($nowUrl,'/api/ApiLogin') == false && strpos($nowUrl,'/api/ApiForgetPassword') == false && $isApi){ if (strpos($nowUrl,'/api/ApiLogin') == false && strpos($nowUrl,'/api/ApiForgetPassword') == false && $isApi){
Export([-1,'请登录']); Export([-1,'请登录']);
......
...@@ -1136,7 +1136,7 @@ function SendMsg($data, $key = '', $ToUser = 'INNER_PERSON'){ ...@@ -1136,7 +1136,7 @@ function SendMsg($data, $key = '', $ToUser = 'INNER_PERSON'){
$check['k2']=MD5(MD5($check['k1']).Config('website.UploadKey')); $check['k2']=MD5(MD5($check['k1']).Config('website.UploadKey'));
$return = curl(config("website.API_DOMAIN").'/msg/sendMessageByAuto', $check); $return = curl(config("website.API_DOMAIN").'/msg/sendMessageByAuto', $check);
\App\Model\LogOperationModel::log(["operation_type"=>"1","relevance_type"=>'send_msg',"content"=>$check,"extend1"=>$return]); //日志 \App\Model\OperationLogModel::log(["operation_type"=>"1","relevance_type"=>'send_msg',"content"=>$check,"extend1"=>$return]); //日志
$res = json_decode($return,true); $res = json_decode($return,true);
if(empty($res['err_code']) || $res['err_code']!=0) return false; if(empty($res['err_code']) || $res['err_code']!=0) return false;
......
...@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model; ...@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model;
use Request; use Request;
use DB; use DB;
class LogOperationModel extends Model class OperationLogModel extends Model
{ {
protected $connection='yunxin'; protected $connection='yunxin';
protected $table='operation_log'; protected $table='operation_log';
......
...@@ -8,6 +8,7 @@ use League\Flysystem\Exception; ...@@ -8,6 +8,7 @@ use League\Flysystem\Exception;
use Request; use Request;
use DB; use DB;
use Illuminate\Support\Facades\Redis; use Illuminate\Support\Facades\Redis;
use App\Plugin\Session;
class SupplierAccountModel extends Model class SupplierAccountModel extends Model
{ {
...@@ -146,5 +147,47 @@ class SupplierAccountModel extends Model ...@@ -146,5 +147,47 @@ class SupplierAccountModel extends Model
Redis::del("yunxin_login_".$request->yunxin_token);//删除登录信息 Redis::del("yunxin_login_".$request->yunxin_token);//删除登录信息
setcookie('yunxin_token','',time()-3600); //清除cookie setcookie('yunxin_token','',time()-3600); //清除cookie
} }
/*
* 找回密码发送手机验证码
*/
public function forgetMobileCode($input){
$mobile = $input['mobile']; //手机号码
$code = $input['code']; //图形验证码
if (Session::get('yunxin_code',true) != $code) {
//用户输入验证码错误
Export([1001,'验证码输入错误']);
}
$checkTime = Redis::ttl('yunxin_mobile_code_'.$mobile);
if ($checkTime > 0){
Export([1001,'同一手机号一分钟只能请求一次验证码!']);
}
$check = $this->where("mobile",$mobile)->first();
if (!$check){
Export([1001,'系统不存在此手机号']);
}
$moblie_code = mt_rand(9999, 99999); //手机随机码
$expire = 60;//60秒
$check1 = Redis::setex('yunxin_mobile_code_'.$mobile, $expire, $moblie_code);
$check2 = SendMsg(['code'=>$moblie_code],'login-code',[$mobile]);//发送验证码
if ($check1 == 'OK'){
$forget_password_token = md5(time().$moblie_code.$mobile);
Redis::setex('yunxin_forget_password_token_'.$mobile, $expire, $forget_password_token);
Export([0,'成功',$forget_password_token]);
}else{
Export([1002,'生成手机验证码失败']);
}
}
/*
* 判断是否存在手机验证码
*/
public function checkMobileCode($mobile,$code){
if (Redis::get('yunxin_mobile_code_'.$mobile) == $code ){
Redis::del('yunxin_mobile_code_'.$mobile);
return true;
}else{
return false;
}
}
} }
\ No newline at end of file

4.88 KB | W: | H:

6.29 KB | W: | H:

public/pc/images/b.png
public/pc/images/b.png
public/pc/images/b.png
public/pc/images/b.png
  • 2-up
  • Swipe
  • Onion skin
var yunxin_forget_password_token;
var yunxin_forget_mobile;
;!function () { ;!function () {
window.ForgetPassword = { window.ForgetPassword = {
'code': "#code",//验证码 'code': "#code",//验证码
...@@ -12,13 +14,6 @@ ...@@ -12,13 +14,6 @@
} }
return false; return false;
}, },
getCodes: function () {
var val = $("input[name='codes']").val();
if (val) {
return val;
}
return false;
},
getCode: function () { getCode: function () {
var val = $("input[name='code']").val(); var val = $("input[name='code']").val();
if (val) { if (val) {
...@@ -26,50 +21,17 @@ ...@@ -26,50 +21,17 @@
} }
return false; return false;
}, },
getData: function (params, callback, type) {
var url;
switch (type) {
case 'moblieCode':
url = ' /helper/moblieCode';
break;
case 'ApiRestPassword':
url = '/api/ApiRestPassword';
break;
}
$.ajax({
url: _URL_ + url,
type: 'post',
data: params,
async: false,
dataType: 'json',
timeout: 10000,
success: function (res) {
if (res.code == 0) {
typeof callback == 'function' && callback(res);
} else {
layer.msg(res.msg);
}
},
error: function (res) {
layer.msg('网络出现问题,请重试!')
}
})
},
calcForm: function (opt, type) { calcForm: function (opt, type) {
if (type == 'step1') { if (type == 'step1') {
if (!opt.getMobile()) { if (!opt.getMobile()) {
$(".error").show().text('请输入手机号'); $(".error").show().text('请输入手机号');
return false; return false;
} }
if (!opt.getCode()) {
if (!opt.getCodes()) {
$(".error").show().text('请填写验证码'); $(".error").show().text('请填写验证码');
return false; return false;
} }
} }
$(".error").hide().text(''); $(".error").hide().text('');
return true; return true;
...@@ -79,13 +41,60 @@ ...@@ -79,13 +41,60 @@
$(opt.code).on('click', function () { $(opt.code).on('click', function () {
$(this).prev().find('img').attr('src', '/helper/captcha?' + new Date().getTime()) $(this).prev().find('img').attr('src', '/helper/captcha?' + new Date().getTime())
}); });
//第一步提交 //第一步提交(发送手机验证码)
$(opt.submitStep1).on('click', function () { $(opt.submitStep1).on('click', function () {
if (opt.calcForm(opt, 'step1')) { if (opt.calcForm(opt, 'step1')) {
var s1 = ajax_push('/helper/forgetMobile',{"mobile":$("input[name='mobile']").val(),"code":$("input[name='code']").val()})
if(s1.code > 0){
alert_err(s1.msg)
return false;
}else{
yunxin_forget_password_token = s1.data;
yunxin_forget_mobile = $("input[name='mobile']").val()
$(".step-list").find('li').eq(1).addClass('curr'); $(".step-list").find('li').eq(1).addClass('curr');
$(".step-1").hide(); $(".step-1").hide();
$(".step-2").show(); $(".step-2").show();
} }
}
});
//第二步提交(验证手机验证码)
$("#submitStep2").on('click', function () {
$(".step2_moblie").html(yunxin_forget_mobile)
if ($(".stpe2_code").val() == "") {
$(".error").show().text('请填写手机验证码');
return false;
}
var s1 = ajax_push('/helper/checkMobileCode',{"mobile":$("input[name='mobile']").val(),"code":$("input[name='stpe2_code']").val()})
if(s1.code > 0){
alert_err(s1.msg)
return false;
}else{
$(".step-list").find('li').eq(1).addClass('curr');
$(".step-2").hide();
$(".step-3").show();
}
});
//第三步提交(最后修改密码)
$("#submitStep2").on('click', function () {
$(".step2_moblie").html(yunxin_forget_mobile)
if ($(".stpe2_code").val() == "") {
$(".error").show().text('请填写手机验证码');
return false;
}
var s1 = ajax_push('/helper/checkMobileCode',{"mobile":$("input[name='mobile']").val(),"code":$("input[name='stpe2_code']").val()})
if(s1.code > 0){
alert_err(s1.msg)
return false;
}else{
$(".step-list").find('li').eq(1).addClass('curr');
$(".step-2").hide();
$(".step-3").show();
}
}); });
return this; return this;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<link rel="stylesheet" type="text/css" href="/pc/css/style.min.css?v={{ $time }}"> <link rel="stylesheet" type="text/css" href="/pc/css/style.min.css?v={{ $time }}">
<script> <script>
//存放公共变量 //存放公共变量
var _URL_ = "<?php echo $_URL_; ?>"; var URL_YUNXIN = "<?php echo $URL_YUNXIN; ?>";
var _DOMAIN_ = "<?php echo $_DOMAIN_; ?>"; var _DOMAIN_ = "<?php echo $_DOMAIN_; ?>";
</script> </script>
</head> </head>
...@@ -34,25 +34,28 @@ ...@@ -34,25 +34,28 @@
<span>帮助</span> <span>帮助</span>
</a> </a>
<div class="info-wrap lineBlock va-m"> <div class="info-wrap lineBlock va-m">
<?php if($mobile == "") { ?>
<!--未登录--> <!--未登录-->
<a class="no-login" href="javascript:;"> <a class="no-login" href="/web/login">
<i class="icn ico-1"></i> <i class="icn ico-1"></i>
<span class="va-m">请登录</span> <span class="va-m">请登录</span>
<i class="icn ico-2"></i> <i class="icn ico-2"></i>
</a> </a>
<?php }else{ ?>
<!--已登录--> <!--已登录-->
<a href="javascript:;" class="login" style="display: none"> <a href="javascript:;" class="login" style=" ">
<img src="./images/b.png" width="40" height="40" alt="" class="lineBlock va-m"> <img src="/pc/images/b.png" width="40" height="40" alt="" class="lineBlock va-m">
<span class="va-m">蓝色风沙</span> <span class="va-m"><?= $mobile ?></span>
<i class="icn ico-2"></i> <i class="icn ico-2"></i>
</a> </a>
<!--退出按钮--> <!--退出按钮-->
<a class="exit-btn" href="javascript:;" style="display: none"> <a class="exit-btn" href="/web/LoginOut">
<i class="icn arr"></i> <i class="icn arr"></i>
<i class="icn ico-1"></i> <i class="icn ico-1"></i>
<span>退出登录</span> <span>退出登录</span>
<b class="lineBlock emptys"></b> <b class="lineBlock emptys"></b>
</a> </a>
<?php } ?>
</div> </div>
<b class="emptys lineBlock"></b> <b class="emptys lineBlock"></b>
</div> </div>
...@@ -91,11 +94,11 @@ ...@@ -91,11 +94,11 @@
<form action="step1"> <form action="step1">
<div class="inp-wrap"> <div class="inp-wrap">
<label class="tag lineBlock va-m"><em>*</em>手机号码:</label> <label class="tag lineBlock va-m"><em>*</em>手机号码:</label>
<input type="password" placeholder="请输入手机号" class="inp va-m w338" name="mobile"> <input type="text" placeholder="请输入手机号" class="inp va-m w338" name="mobile">
</div> </div>
<div class="inp-wrap"> <div class="inp-wrap">
<label class="tag lineBlock va-m"><em>*</em>验证码:</label> <label class="tag lineBlock va-m"><em>*</em>验证码:</label>
<input type="text" placeholder="请输入验证码" class="inp va-m w158" name="codes"> <input type="text" placeholder="请输入验证码" class="inp va-m w158" name="code">
<div class="lineBlock va-m code"> <div class="lineBlock va-m code">
<div class="pic lineBlock va-m"><img src="/helper/captcha" alt=""></div> <div class="pic lineBlock va-m"><img src="/helper/captcha" alt=""></div>
<a href="javascript:;" class="va-m" id="code">换一张</a> <a href="javascript:;" class="va-m" id="code">换一张</a>
...@@ -112,16 +115,15 @@ ...@@ -112,16 +115,15 @@
<div class="form-action"> <div class="form-action">
<div class="inp-wrap"> <div class="inp-wrap">
<label class="tag lineBlock va-m"><em>*</em>手机号码:</label> <label class="tag lineBlock va-m"><em>*</em>手机号码:</label>
<span class="txt">185****6352</span> <span class="txt step2_moblie"></span>
</div> </div>
<div class="inp-wrap"> <div class="inp-wrap">
<label class="tag lineBlock va-m"><em>*</em>验证码:</label> <label class="tag lineBlock va-m"><em>*</em>验证码:</label>
<input type="text" placeholder="请输入验证码" class="inp va-m w210" name="code"> <input type="text" placeholder="请输入手机验证码" class="inp va-m w210 " name="stpe2_code">
<a href="javascript:;" class="lineBlock va-m send-code">发送验证码</a>
<em class="error">验证码错误</em> <em class="error">验证码错误</em>
</div> </div>
<div class="bnt-wrap mt1"> <div class="bnt-wrap mt1">
<a href="javascript:;" class="ok btn lineBlock">下一步</a> <a href="javascript:;" class="ok btn lineBlock" id="submitStep2">下一步</a>
</div> </div>
</div> </div>
</div> </div>
...@@ -156,6 +158,7 @@ ...@@ -156,6 +158,7 @@
<script type="text/javascript" src="/pc/js/jquery.min.js"></script> <script type="text/javascript" src="/pc/js/jquery.min.js"></script>
<script type="text/javascript" src="/pc/js/global.js"></script> <script type="text/javascript" src="/pc/js/global.js"></script>
<script type="text/javascript" src="/pc/js/layui/layui.all.js"></script> <script type="text/javascript" src="/pc/js/layui/layui.all.js"></script>
<script type="text/javascript" src="/pc/js/public.js"></script>
<script type="text/javascript" src="/pc/js/controller/ForgetPassword.js"></script> <script type="text/javascript" src="/pc/js/controller/ForgetPassword.js"></script>
</body> </body>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment