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
cb6a89f3
authored
Apr 04, 2019
by
PRY5YKGJ82EZEPX\Administrator
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1.0
parent
ea23a175
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
136 additions
and
64 deletions
app/Http/Controllers/ApiController.php
app/Http/Controllers/HelperController.php
app/Http/Controllers/WebController.php
app/Http/Middleware/CheckLogin.php
app/Http/function.php
app/Model/OperationLogModel.php
app/Model/SupplierAccountModel.php
public/pc/images/b.png
public/pc/js/controller/ForgetPassword.js
resources/views/pc/ForgetPassword.blade.php
app/Http/Controllers/ApiController.php
View file @
cb6a89f3
...
...
@@ -148,4 +148,5 @@ class ApiController extends Controller
}
}
app/Http/Controllers/HelperController.php
View file @
cb6a89f3
...
...
@@ -3,6 +3,7 @@
namespace
App\Http\Controllers
;
use
App\Http\Requests
;
use
App\Model\SupplierAccountModel
;
use
Gregwar\Captcha\CaptchaBuilder
;
use
Illuminate\Http\Request
;
use
App\Plugin\Session
;
...
...
@@ -63,7 +64,19 @@ class HelperController extends Controller {
$check2
=
SendMsg
([
'code'
=>
$moblie_code
],
'login-code'
,[
$mobile
]);
//发送验证码
$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
,
'不存在'
);
}
}
app/Http/Controllers/WebController.php
View file @
cb6a89f3
...
...
@@ -50,6 +50,7 @@ class WebController extends Controller
}
//找回密码
private
function
ForgetPassword
(
$request
,
$data
,
$id
){
$data
[
'mobile'
]
=
$request
->
mobile
;
$data
[
'title'
]
=
'忘记密码'
;
return
view
(
'pc.ForgetPassword'
,
$data
);
}
...
...
app/Http/Middleware/CheckLogin.php
View file @
cb6a89f3
...
...
@@ -22,6 +22,7 @@ class CheckLogin
$isApi
=
false
;
if
(
$pos
===
0
)
$isApi
=
true
;
$request
->
supplier_name
=
""
;
//登录用户名
if
(
empty
(
$yunxin_token
)
||
empty
(
$userInfo
)
){
//没有登录跳到登录页
if
(
strpos
(
$nowUrl
,
'/api/ApiLogin'
)
==
false
&&
strpos
(
$nowUrl
,
'/api/ApiForgetPassword'
)
==
false
&&
$isApi
){
Export
([
-
1
,
'请登录'
]);
...
...
app/Http/function.php
View file @
cb6a89f3
...
...
@@ -1136,7 +1136,7 @@ function SendMsg($data, $key = '', $ToUser = 'INNER_PERSON'){
$check
[
'k2'
]
=
MD5
(
MD5
(
$check
[
'k1'
])
.
Config
(
'website.UploadKey'
));
$return
=
curl
(
config
(
"website.API_DOMAIN"
)
.
'/msg/sendMessageByAuto'
,
$check
);
\App\Model\
LogOperation
Model
::
log
([
"operation_type"
=>
"1"
,
"relevance_type"
=>
'send_msg'
,
"content"
=>
$check
,
"extend1"
=>
$return
]);
//日志
\App\Model\
OperationLog
Model
::
log
([
"operation_type"
=>
"1"
,
"relevance_type"
=>
'send_msg'
,
"content"
=>
$check
,
"extend1"
=>
$return
]);
//日志
$res
=
json_decode
(
$return
,
true
);
if
(
empty
(
$res
[
'err_code'
])
||
$res
[
'err_code'
]
!=
0
)
return
false
;
...
...
app/Model/OperationLogModel.php
View file @
cb6a89f3
...
...
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model;
use
Request
;
use
DB
;
class
LogOperation
Model
extends
Model
class
OperationLog
Model
extends
Model
{
protected
$connection
=
'yunxin'
;
protected
$table
=
'operation_log'
;
...
...
app/Model/SupplierAccountModel.php
View file @
cb6a89f3
...
...
@@ -8,6 +8,7 @@ use League\Flysystem\Exception;
use
Request
;
use
DB
;
use
Illuminate\Support\Facades\Redis
;
use
App\Plugin\Session
;
class
SupplierAccountModel
extends
Model
{
...
...
@@ -146,5 +147,47 @@ class SupplierAccountModel extends Model
Redis
::
del
(
"yunxin_login_"
.
$request
->
yunxin_token
);
//删除登录信息
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
public/pc/images/b.png
View file @
cb6a89f3
4.88 KB
|
W:
|
H:
6.29 KB
|
W:
|
H:
2-up
Swipe
Onion skin
public/pc/js/controller/ForgetPassword.js
View file @
cb6a89f3
var
yunxin_forget_password_token
;
var
yunxin_forget_mobile
;
;
!
function
()
{
window
.
ForgetPassword
=
{
'code'
:
"#code"
,
//验证码
...
...
@@ -12,13 +14,6 @@
}
return
false
;
},
getCodes
:
function
()
{
var
val
=
$
(
"input[name='codes']"
).
val
();
if
(
val
)
{
return
val
;
}
return
false
;
},
getCode
:
function
()
{
var
val
=
$
(
"input[name='code']"
).
val
();
if
(
val
)
{
...
...
@@ -26,50 +21,17 @@
}
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
)
{
if
(
type
==
'step1'
)
{
if
(
!
opt
.
getMobile
())
{
$
(
".error"
).
show
().
text
(
'请输入手机号'
);
return
false
;
}
if
(
!
opt
.
getCodes
())
{
if
(
!
opt
.
getCode
())
{
$
(
".error"
).
show
().
text
(
'请填写验证码'
);
return
false
;
}
}
$
(
".error"
).
hide
().
text
(
''
);
return
true
;
...
...
@@ -79,12 +41,59 @@
$
(
opt
.
code
).
on
(
'click'
,
function
()
{
$
(
this
).
prev
().
find
(
'img'
).
attr
(
'src'
,
'/helper/captcha?'
+
new
Date
().
getTime
())
});
//第一步提交
//第一步提交
(发送手机验证码)
$
(
opt
.
submitStep1
).
on
(
'click'
,
function
()
{
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-1"
).
hide
();
$
(
".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-
1
"
).
hide
();
$
(
".step-
2
"
).
show
();
$
(
".step-
2
"
).
hide
();
$
(
".step-
3
"
).
show
();
}
});
...
...
resources/views/pc/ForgetPassword.blade.php
View file @
cb6a89f3
...
...
@@ -13,7 +13,7 @@
<link
rel=
"stylesheet"
type=
"text/css"
href=
"/pc/css/style.min.css?v={{ $time }}"
>
<script>
//存放公共变量
var
_URL_
=
"
<?php
echo
$_URL_
;
?>
";
var
URL_YUNXIN
=
"
<?php
echo
$URL_YUNXIN
;
?>
";
var _DOMAIN_ = "
<?php
echo
$_DOMAIN_
;
?>
"
;
</script>
</head>
...
...
@@ -34,25 +34,28 @@
<span>
帮助
</span>
</a>
<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>
<span
class=
"va-m"
>
请登录
</span>
<i
class=
"icn ico-2"
></i>
</a>
<?php
}
else
{
?>
<!--已登录-->
<a
href=
"javascript:;"
class=
"login"
style=
"
display: none
"
>
<img
src=
"
.
/images/b.png"
width=
"40"
height=
"40"
alt=
""
class=
"lineBlock va-m"
>
<span
class=
"va-m"
>
蓝色风沙
</span>
<a
href=
"javascript:;"
class=
"login"
style=
"
"
>
<img
src=
"
/pc
/images/b.png"
width=
"40"
height=
"40"
alt=
""
class=
"lineBlock va-m"
>
<span
class=
"va-m"
>
<?=
$mobile
?>
</span>
<i
class=
"icn ico-2"
></i>
</a>
<!--退出按钮-->
<a
class=
"exit-btn"
href=
"javascript:;"
style=
"display: none"
>
<i
class=
"icn arr"
></i>
<i
class=
"icn ico-1"
></i>
<span>
退出登录
</span>
<b
class=
"lineBlock emptys"
></b>
</a>
<a
class=
"exit-btn"
href=
"/web/LoginOut"
>
<i
class=
"icn arr"
></i>
<i
class=
"icn ico-1"
></i>
<span>
退出登录
</span>
<b
class=
"lineBlock emptys"
></b>
</a>
<?php
}
?>
</div>
<b
class=
"emptys lineBlock"
></b>
</div>
...
...
@@ -91,11 +94,11 @@
<form
action=
"step1"
>
<div
class=
"inp-wrap"
>
<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
class=
"inp-wrap"
>
<label
class=
"tag lineBlock va-m"
><em>
*
</em>
验证码:
</label>
<input
type=
"text"
placeholder=
"请输入验证码"
class=
"inp va-m w158"
name=
"code
s
"
>
<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>
...
...
@@ -112,16 +115,15 @@
<div
class=
"form-action"
>
<div
class=
"inp-wrap"
>
<label
class=
"tag lineBlock va-m"
><em>
*
</em>
手机号码:
</label>
<span
class=
"txt
"
>
185****6352
</span>
<span
class=
"txt
step2_moblie"
>
</span>
</div>
<div
class=
"inp-wrap"
>
<label
class=
"tag lineBlock va-m"
><em>
*
</em>
验证码:
</label>
<input
type=
"text"
placeholder=
"请输入验证码"
class=
"inp va-m w210"
name=
"code"
>
<a
href=
"javascript:;"
class=
"lineBlock va-m send-code"
>
发送验证码
</a>
<input
type=
"text"
placeholder=
"请输入手机验证码"
class=
"inp va-m w210 "
name=
"stpe2_code"
>
<em
class=
"error"
>
验证码错误
</em>
</div>
<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>
...
...
@@ -156,6 +158,7 @@
<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/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>
</body>
...
...
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