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
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
79 additions
and
24 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 {
...
@@ -77,6 +77,13 @@ class HelperController extends Controller {
$check
=
(
new
SupplierAccountModel
())
->
checkMobileCode
(
$request
->
input
(
"mobile"
),
$request
->
input
(
"code"
));
$check
=
(
new
SupplierAccountModel
())
->
checkMobileCode
(
$request
->
input
(
"mobile"
),
$request
->
input
(
"code"
));
$check
?
Export
(
0
,
'存在'
)
:
Export
(
1001
,
'不存在'
);
$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
...
@@ -116,7 +116,7 @@ class SupplierAccountModel extends Model
return
[
0
,
"重置密码成功,请重新登录"
];
return
[
0
,
"重置密码成功,请重新登录"
];
}
}
/*
/*
*
忘记
密码
*
更新
密码
* @param int $account_id 账号id
* @param int $account_id 账号id
*/
*/
public
function
ForgetPassword
(
$request
){
public
function
ForgetPassword
(
$request
){
...
@@ -166,7 +166,7 @@ class SupplierAccountModel extends Model
...
@@ -166,7 +166,7 @@ class SupplierAccountModel extends Model
Export
([
1001
,
'系统不存在此手机号'
]);
Export
([
1001
,
'系统不存在此手机号'
]);
}
}
$moblie_code
=
mt_rand
(
9999
,
99999
);
//手机随机码
$moblie_code
=
mt_rand
(
9999
,
99999
);
//手机随机码
$expire
=
6
0
;
//60秒
$expire
=
8
0
;
//60秒
$check1
=
Redis
::
setex
(
'yunxin_mobile_code_'
.
$mobile
,
$expire
,
$moblie_code
);
$check1
=
Redis
::
setex
(
'yunxin_mobile_code_'
.
$mobile
,
$expire
,
$moblie_code
);
$check2
=
SendMsg
([
'code'
=>
$moblie_code
],
'login-code'
,[
$mobile
]);
//发送验证码
$check2
=
SendMsg
([
'code'
=>
$moblie_code
],
'login-code'
,[
$mobile
]);
//发送验证码
if
(
$check1
==
'OK'
){
if
(
$check1
==
'OK'
){
...
@@ -188,6 +188,29 @@ class SupplierAccountModel extends Model
...
@@ -188,6 +188,29 @@ class SupplierAccountModel extends Model
return
false
;
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;
...
@@ -2,7 +2,7 @@ var yunxin_forget_password_token;
var
yunxin_forget_mobile
;
var
yunxin_forget_mobile
;
;
!
function
()
{
;
!
function
()
{
window
.
ForgetPassword
=
{
window
.
ForgetPassword
=
{
'code'
:
"
#
code"
,
//验证码
'code'
:
"
.
code"
,
//验证码
'submitStep1'
:
"#submitStep1"
,
//第一步
'submitStep1'
:
"#submitStep1"
,
//第一步
init
:
function
()
{
init
:
function
()
{
this
.
handleBind
(
this
);
this
.
handleBind
(
this
);
...
@@ -39,7 +39,7 @@ var yunxin_forget_mobile;
...
@@ -39,7 +39,7 @@ var yunxin_forget_mobile;
handleBind
:
function
(
opt
)
{
handleBind
:
function
(
opt
)
{
//验证码
//验证码
$
(
opt
.
code
).
on
(
'click'
,
function
()
{
$
(
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
()
{
$
(
opt
.
submitStep1
).
on
(
'click'
,
function
()
{
...
@@ -47,7 +47,7 @@ var yunxin_forget_mobile;
...
@@ -47,7 +47,7 @@ var yunxin_forget_mobile;
var
s1
=
ajax_push
(
'/helper/forgetMobile'
,{
"mobile"
:
$
(
"input[name='mobile']"
).
val
(),
"code"
:
$
(
"input[name='code']"
).
val
()})
var
s1
=
ajax_push
(
'/helper/forgetMobile'
,{
"mobile"
:
$
(
"input[name='mobile']"
).
val
(),
"code"
:
$
(
"input[name='code']"
).
val
()})
if
(
s1
.
code
>
0
){
if
(
s1
.
code
>
0
){
alert_err
(
s1
.
msg
)
$
(
".error"
).
show
().
text
(
s1
.
msg
);
return
false
;
return
false
;
}
else
{
}
else
{
yunxin_forget_password_token
=
s1
.
data
;
yunxin_forget_password_token
=
s1
.
data
;
...
@@ -55,13 +55,13 @@ var yunxin_forget_mobile;
...
@@ -55,13 +55,13 @@ var yunxin_forget_mobile;
$
(
".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
();
$
(
".step2_moblie"
).
html
(
yunxin_forget_mobile
)
}
}
}
}
});
});
//第二步提交(验证手机验证码)
//第二步提交(验证手机验证码)
$
(
"#submitStep2"
).
on
(
'click'
,
function
()
{
$
(
"#submitStep2"
).
on
(
'click'
,
function
()
{
$
(
".step2_moblie"
).
html
(
yunxin_forget_mobile
)
if
(
$
(
".stpe2_code"
).
val
()
==
""
)
{
if
(
$
(
".stpe2_code"
).
val
()
==
""
)
{
$
(
".error"
).
show
().
text
(
'请填写手机验证码'
);
$
(
".error"
).
show
().
text
(
'请填写手机验证码'
);
return
false
;
return
false
;
...
@@ -72,28 +72,36 @@ var yunxin_forget_mobile;
...
@@ -72,28 +72,36 @@ var yunxin_forget_mobile;
alert_err
(
s1
.
msg
)
alert_err
(
s1
.
msg
)
return
false
;
return
false
;
}
else
{
}
else
{
$
(
".step-list"
).
find
(
'li'
).
eq
(
1
).
addClass
(
'curr'
);
$
(
".step-list"
).
find
(
'li'
).
eq
(
2
).
addClass
(
'curr'
);
$
(
".step-2"
).
hide
();
$
(
".step-2"
).
hide
();
$
(
".step-3"
).
show
();
$
(
".step-3"
).
show
();
}
}
});
});
//第三步提交(最后修改密码)
//第三步提交(最后修改密码)
$
(
"#submitStep2"
).
on
(
'click'
,
function
()
{
$
(
"#submitStep3"
).
on
(
'click'
,
function
()
{
$
(
".step2_moblie"
).
html
(
yunxin_forget_mobile
)
var
new_password
=
$
(
"#new_password"
).
val
();
if
(
$
(
".stpe2_code"
).
val
()
==
""
)
{
var
new_passwords
=
$
(
"#new_passwords"
).
val
();
$
(
".error"
).
show
().
text
(
'请填写手机验证码'
);
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
;
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
){
if
(
s1
.
code
>
0
){
alert_err
(
s1
.
msg
)
alert_err
(
s1
.
msg
)
return
false
;
return
false
;
}
else
{
}
else
{
$
(
".step-list"
).
find
(
'li'
).
eq
(
1
).
addClass
(
'curr'
);
$
(
".step-list"
).
find
(
'li'
).
eq
(
3
).
addClass
(
'curr'
);
$
(
".step-2
"
).
hide
();
$
(
".step-3
"
).
hide
();
$
(
".step-3
"
).
show
();
$
(
".step-4
"
).
show
();
}
}
});
});
...
...
public/pc/js/public.js
View file @
2a8eabe3
...
@@ -181,3 +181,19 @@ function checkSubmit(callback){
...
@@ -181,3 +181,19 @@ function checkSubmit(callback){
}
}
callback
();
callback
();
}
}
//计算字符长度
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 @@
...
@@ -100,8 +100,8 @@
<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=
"code"
>
<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
code"
><img
src=
"/helper/captcha"
alt=
""
id=
"img_code
"
></div>
<a
href=
"javascript:;"
class=
"va-m
"
id=
"code"
>
换一张
</a>
<a
href=
"javascript:;"
class=
"va-m
code"
>
换一张
</a>
</div>
</div>
</div>
</div>
<div
class=
"bnt-wrap mt1"
>
<div
class=
"bnt-wrap mt1"
>
...
@@ -131,16 +131,15 @@
...
@@ -131,16 +131,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>
<input
type=
"password"
placeholder=
"请输入原始密码"
class=
"inp va-m w338"
>
<input
type=
"password"
id=
"new_password"
placeholder=
"请输入新密码"
class=
"inp va-m w338"
>
<em
class=
"error"
>
密码必须大于等于8位
</em>
</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=
"password"
placeholder=
"请再次输入新密码"
class=
"inp va-m w338"
>
<input
type=
"password"
id=
"new_passwords"
placeholder=
"请再次输入新密码"
class=
"inp va-m w338"
>
<em
class=
"error"
>
格式不对
</em>
</div>
</div>
<em
class=
"error"
>
验证码错误
</em>
<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=
"submitStep3"
>
提交
</a>
</div>
</div>
</div>
</div>
</div>
</div>
...
@@ -148,7 +147,7 @@
...
@@ -148,7 +147,7 @@
<div
class=
"done"
>
<div
class=
"done"
>
<i
class=
"iconfont icon-chenggong-"
></i>
<i
class=
"iconfont icon-chenggong-"
></i>
<p
class=
"t1"
>
新密码重置成功!
</p>
<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>
</div>
</div>
</div>
...
@@ -160,6 +159,7 @@
...
@@ -160,6 +159,7 @@
<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/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>
<script
type=
"text/javascript"
src=
"/pc/js/md5/jquery.md5.js"
></script>
</body>
</body>
</html>
</html>
\ No newline at end of file
resources/views/pc/ResetPassword.blade.php
View file @
2a8eabe3
...
@@ -28,7 +28,6 @@
...
@@ -28,7 +28,6 @@
</div>
</div>
</div>
</div>
<div
class=
"bnt-wrap mt1"
>
<div
class=
"bnt-wrap mt1"
>
<a
href=
"javascript:;"
class=
"cancel btn lineBlock"
>
取消
</a>
<a
href=
"javascript:;"
class=
"ok btn lineBlock"
onclick=
"ResetPassword()"
>
确定
</a>
<a
href=
"javascript:;"
class=
"ok btn lineBlock"
onclick=
"ResetPassword()"
>
确定
</a>
</div>
</div>
</form>
</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