Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄成意
/
yunxin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
2a8eabe3
authored
Apr 08, 2019
by
梁建民
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'master' of
http://119.23.72.7/q578953158/yunxin
parents
7a0c7cbf
ddb3f855
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
87 additions
and
33 deletions
app/Http/Controllers/HelperController.php
app/Model/SupplierAccountModel.php
public/pc/js/controller/ForgetPassword.js
public/pc/js/public.js
resources/views/pc/ForgetPassword.blade.php
resources/views/pc/ResetPassword.blade.php
app/Http/Controllers/HelperController.php
View file @
2a8eabe3
...
...
@@ -77,6 +77,13 @@ class HelperController extends Controller {
$check
=
(
new
SupplierAccountModel
())
->
checkMobileCode
(
$request
->
input
(
"mobile"
),
$request
->
input
(
"code"
));
$check
?
Export
(
0
,
'存在'
)
:
Export
(
1001
,
'不存在'
);
}
/*
* 找回密码最后修改密码
*/
private
function
forgetPassword
(
$request
){
$check
=
(
new
SupplierAccountModel
())
->
ForgetPassword2
(
$request
);
Export
(
$check
);
}
}
app/Model/SupplierAccountModel.php
View file @
2a8eabe3
...
...
@@ -116,7 +116,7 @@ class SupplierAccountModel extends Model
return
[
0
,
"重置密码成功,请重新登录"
];
}
/*
*
忘记
密码
*
更新
密码
* @param int $account_id 账号id
*/
public
function
ForgetPassword
(
$request
){
...
...
@@ -166,7 +166,7 @@ class SupplierAccountModel extends Model
Export
([
1001
,
'系统不存在此手机号'
]);
}
$moblie_code
=
mt_rand
(
9999
,
99999
);
//手机随机码
$expire
=
6
0
;
//60秒
$expire
=
8
0
;
//60秒
$check1
=
Redis
::
setex
(
'yunxin_mobile_code_'
.
$mobile
,
$expire
,
$moblie_code
);
$check2
=
SendMsg
([
'code'
=>
$moblie_code
],
'login-code'
,[
$mobile
]);
//发送验证码
if
(
$check1
==
'OK'
){
...
...
@@ -188,6 +188,29 @@ class SupplierAccountModel extends Model
return
false
;
}
}
/*
* 找回密码
*/
public
function
ForgetPassword2
(
$request
){
$mobile
=
$request
->
input
(
'mobile'
);
$new_password
=
$request
->
input
(
'new_password'
);
$token
=
Request
::
input
(
'token'
);
//手机验证码
$redis_token
=
Redis
::
get
(
'yunxin_forget_password_token_'
.
$mobile
);
if
(
$token
!=
$redis_token
){
return
[
1001
,
'token已过期,请重试'
];
}
$account
=
$this
->
where
(
"mobile"
,
$mobile
)
->
first
();
if
(
!
$account
){
return
[
1002
,
'不存在此账号'
];
}
if
(
utf8_strlen
(
$new_password
)
!=
32
)
return
[
1001
,
'新密码长度不对'
];
$password
=
createPassword
(
$new_password
);
$this
->
where
(
"mobile"
,
$mobile
)
->
update
([
'password'
=>
$password
]);
Redis
::
del
(
"yunxin_login_"
.
$request
->
yunxin_token
);
//删除缓存
return
[
0
,
"成功,请登录"
];
}
}
\ No newline at end of file
public/pc/js/controller/ForgetPassword.js
View file @
2a8eabe3
...
...
@@ -2,7 +2,7 @@ var yunxin_forget_password_token;
var
yunxin_forget_mobile
;
;
!
function
()
{
window
.
ForgetPassword
=
{
'code'
:
"
#
code"
,
//验证码
'code'
:
"
.
code"
,
//验证码
'submitStep1'
:
"#submitStep1"
,
//第一步
init
:
function
()
{
this
.
handleBind
(
this
);
...
...
@@ -39,7 +39,7 @@ var yunxin_forget_mobile;
handleBind
:
function
(
opt
)
{
//验证码
$
(
opt
.
code
).
on
(
'click'
,
function
()
{
$
(
this
).
prev
().
find
(
'img'
).
attr
(
'src'
,
'/helper/captcha?'
+
new
Date
().
getTime
())
$
(
"#img_code"
).
attr
(
'src'
,
'/helper/captcha?'
+
new
Date
().
getTime
())
});
//第一步提交(发送手机验证码)
$
(
opt
.
submitStep1
).
on
(
'click'
,
function
()
{
...
...
@@ -47,7 +47,7 @@ var yunxin_forget_mobile;
var
s1
=
ajax_push
(
'/helper/forgetMobile'
,{
"mobile"
:
$
(
"input[name='mobile']"
).
val
(),
"code"
:
$
(
"input[name='code']"
).
val
()})
if
(
s1
.
code
>
0
){
alert_err
(
s1
.
msg
)
$
(
".error"
).
show
().
text
(
s1
.
msg
);
return
false
;
}
else
{
yunxin_forget_password_token
=
s1
.
data
;
...
...
@@ -55,13 +55,13 @@ var yunxin_forget_mobile;
$
(
".step-list"
).
find
(
'li'
).
eq
(
1
).
addClass
(
'curr'
);
$
(
".step-1"
).
hide
();
$
(
".step-2"
).
show
();
$
(
".step2_moblie"
).
html
(
yunxin_forget_mobile
)
}
}
});
//第二步提交(验证手机验证码)
$
(
"#submitStep2"
).
on
(
'click'
,
function
()
{
$
(
".step2_moblie"
).
html
(
yunxin_forget_mobile
)
if
(
$
(
".stpe2_code"
).
val
()
==
""
)
{
$
(
".error"
).
show
().
text
(
'请填写手机验证码'
);
return
false
;
...
...
@@ -72,29 +72,37 @@ var yunxin_forget_mobile;
alert_err
(
s1
.
msg
)
return
false
;
}
else
{
$
(
".step-list"
).
find
(
'li'
).
eq
(
1
).
addClass
(
'curr'
);
$
(
".step-list"
).
find
(
'li'
).
eq
(
2
).
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
;
}
$
(
"#submitStep3"
).
on
(
'click'
,
function
()
{
var
new_password
=
$
(
"#new_password"
).
val
();
var
new_passwords
=
$
(
"#new_passwords"
).
val
();
if
(
strlen
(
new_password
)
>
20
||
strlen
(
new_password
)
<
8
){
$
(
".error"
).
show
().
text
(
"新密码必须在8~20位之间"
);
return
false
;
}
if
(
new_passwords
!=
new_password
){
$
(
".error"
).
show
().
text
(
"新密码和重复密码不一致"
);
return
false
;
}
var
s1
=
ajax_push
(
'/helper/forgetPassword'
,{
"mobile"
:
$
(
"input[name='mobile']"
).
val
(),
"token"
:
yunxin_forget_password_token
,
"new_password"
:
$
.
md5
(
$
(
"#new_password"
).
val
())})
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
();
}
if
(
s1
.
code
>
0
){
alert_err
(
s1
.
msg
)
return
false
;
}
else
{
$
(
".step-list"
).
find
(
'li'
).
eq
(
3
).
addClass
(
'curr'
);
$
(
".step-3"
).
hide
();
$
(
".step-4"
).
show
();
}
});
return
this
;
...
...
public/pc/js/public.js
View file @
2a8eabe3
...
...
@@ -180,4 +180,20 @@ function checkSubmit(callback){
return
false
;
}
callback
();
}
\ No newline at end of file
}
//计算字符长度
function
strlen
(
str
){
var
len
=
0
;
for
(
var
i
=
0
;
i
<
str
.
length
;
i
++
)
{
var
c
=
str
.
charCodeAt
(
i
);
//单字节加1
if
((
c
>=
0x0001
&&
c
<=
0x007e
)
||
(
0xff60
<=
c
&&
c
<=
0xff9f
))
{
len
++
;
}
else
{
len
+=
2
;
}
}
return
len
;
}
resources/views/pc/ForgetPassword.blade.php
View file @
2a8eabe3
...
...
@@ -100,8 +100,8 @@
<label
class=
"tag lineBlock va-m"
><em>
*
</em>
验证码:
</label>
<input
type=
"text"
placeholder=
"请输入验证码"
class=
"inp va-m w158"
name=
"code"
>
<div
class=
"lineBlock va-m code"
>
<div
class=
"pic lineBlock va-m
"
><img
src=
"/helper/captcha"
alt=
"
"
></div>
<a
href=
"javascript:;"
class=
"va-m
"
id=
"code"
>
换一张
</a>
<div
class=
"pic lineBlock va-m
code"
><img
src=
"/helper/captcha"
alt=
""
id=
"img_code
"
></div>
<a
href=
"javascript:;"
class=
"va-m
code"
>
换一张
</a>
</div>
</div>
<div
class=
"bnt-wrap mt1"
>
...
...
@@ -131,16 +131,15 @@
<div
class=
"form-action"
>
<div
class=
"inp-wrap"
>
<label
class=
"tag lineBlock va-m"
><em>
*
</em>
新登录密码:
</label>
<input
type=
"password"
placeholder=
"请输入原始密码"
class=
"inp va-m w338"
>
<em
class=
"error"
>
密码必须大于等于8位
</em>
<input
type=
"password"
id=
"new_password"
placeholder=
"请输入新密码"
class=
"inp va-m w338"
>
</div>
<div
class=
"inp-wrap"
>
<label
class=
"tag lineBlock va-m"
><em>
*
</em>
确认新密码:
</label>
<input
type=
"password"
placeholder=
"请再次输入新密码"
class=
"inp va-m w338"
>
<em
class=
"error"
>
格式不对
</em>
<input
type=
"password"
id=
"new_passwords"
placeholder=
"请再次输入新密码"
class=
"inp va-m w338"
>
</div>
<em
class=
"error"
>
验证码错误
</em>
<div
class=
"bnt-wrap mt1"
>
<a
href=
"javascript:;"
class=
"ok btn lineBlock"
>
提交
</a>
<a
href=
"javascript:;"
class=
"ok btn lineBlock"
id=
"submitStep3"
>
提交
</a>
</div>
</div>
</div>
...
...
@@ -148,7 +147,7 @@
<div
class=
"done"
>
<i
class=
"iconfont icon-chenggong-"
></i>
<p
class=
"t1"
>
新密码重置成功!
</p>
<p
class=
"t2"
>
请牢记您的新密码!
<em>
去
</em><a
href=
""
class=
"lineBlock va-m"
>
登录
</a></p>
<p
class=
"t2"
>
请牢记您的新密码!
<em>
去
</em><a
href=
"
/web/login
"
class=
"lineBlock va-m"
>
登录
</a></p>
</div>
</div>
</div>
...
...
@@ -160,6 +159,7 @@
<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/md5/jquery.md5.js"
></script>
</body>
</html>
\ No newline at end of file
resources/views/pc/ResetPassword.blade.php
View file @
2a8eabe3
...
...
@@ -28,7 +28,6 @@
</div>
</div>
<div
class=
"bnt-wrap mt1"
>
<a
href=
"javascript:;"
class=
"cancel btn lineBlock"
>
取消
</a>
<a
href=
"javascript:;"
class=
"ok btn lineBlock"
onclick=
"ResetPassword()"
>
确定
</a>
</div>
</form>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment