切换导航条
此项目
正在载入...
登录
潘浩文
/
scoreshop
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
潘浩文
6 years ago
提交
112083d00f109fcdbe8d2912d0fe8355f37b1366
1 个父辈
a41309d6
1 个管道 的构建
通过
耗费 2 秒
1
变更
4
构建
1
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
285 行增加
和
211 行删除
app/portal/service/MobileService.php
app/user/controller/RegisterController.php
public/themes/simpleboot3/user/register.html
simplewind/cmf/controller/WeChatBaseController.php
app/portal/service/MobileService.php
0 → 100644
查看文件 @
112083d
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/21
* Time: 10:57
*/
namespace
app\portal\service
;
class
MobileService
{
/**
* 百荣科技短信通知接口
*/
public
function
sendSMSS
(
$mobile
,
$content
){
date_default_timezone_set
(
'PRC'
);
//设置时区
$url
=
"http://www.ztsms.cn/sendNSms.do"
;
//提交地址
$username
=
'nonyegongzhonghao'
;
//用户名
$password
=
'Cxz307312'
;
//原密码
$mobile
=
$mobile
;
$data
=
array
(
'content'
=>
"您的验证码是"
.
$content
.
"有效期1分钟,请及时使用"
.
"【金智农】"
,
//短信内容
'mobile'
=>
$mobile
,
//手机号码
'productid'
=>
'887361'
,
//产品id
'xh'
=>
''
//小号
);
$isTranscoding
=
false
;
$timeout
=
30
;
$data
[
'content'
]
=
$isTranscoding
===
true
?
mb_convert_encoding
(
$data
[
'content'
],
"UTF-8"
)
:
$data
[
'content'
];
$data
[
'username'
]
=
$username
;
$data
[
'tkey'
]
=
date
(
'YmdHis'
);
$data
[
'password'
]
=
md5
(
md5
(
$password
)
.
$data
[
'tkey'
]);
$curl
=
curl_init
();
// 启动一个CURL会话
curl_setopt
(
$curl
,
CURLOPT_URL
,
$url
);
// 要访问的地址
curl_setopt
(
$curl
,
CURLOPT_SSL_VERIFYPEER
,
false
);
// 对认证证书来源的检查
curl_setopt
(
$curl
,
CURLOPT_SSL_VERIFYHOST
,
false
);
// 从证书中检查SSL加密算法是否存在
curl_setopt
(
$curl
,
CURLOPT_USERAGENT
,
$_SERVER
[
'HTTP_USER_AGENT'
]);
// 模拟用户使用的浏览器
curl_setopt
(
$curl
,
CURLOPT_POST
,
true
);
// 发送一个常规的Post请求
curl_setopt
(
$curl
,
CURLOPT_POSTFIELDS
,
http_build_query
(
$data
));
// Post提交的数据包
curl_setopt
(
$curl
,
CURLOPT_TIMEOUT
,
$timeout
);
// 设置超时限制防止死循环
curl_setopt
(
$curl
,
CURLOPT_HEADER
,
false
);
// 显示返回的Header区域内容
curl_setopt
(
$curl
,
CURLOPT_RETURNTRANSFER
,
true
);
// 获取的信息以文件流的形式返回
$result
=
curl_exec
(
$curl
);
// 执行操作
if
(
curl_errno
(
$curl
)){
echo
'Error POST'
.
curl_error
(
$curl
);
}
return
$result
;
}
}
\ No newline at end of file
...
...
app/user/controller/RegisterController.php
查看文件 @
112083d
...
...
@@ -10,106 +10,68 @@
// +----------------------------------------------------------------------
namespace
app\user\controller
;
use
app\portal\service\MobileService
;
use
cmf\controller\HomeBaseController
;
use
cmf\controller\WeChatBaseController
;
use
think\Validate
;
use
app\user\model\UserModel
;
class
RegisterController
extends
Home
BaseController
class
RegisterController
extends
WeChat
BaseController
{
public
function
_initialize
()
{
parent
::
_initialize
();
$this
->
checkWeChatUserLogin
();
$this
->
checkUser
();
}
/**
* 前台用户注册
*/
public
function
index
()
public
function
register
()
{
$redirect
=
$this
->
request
->
post
(
"redirect"
);
if
(
empty
(
$redirect
))
{
$redirect
=
$this
->
request
->
server
(
'HTTP_REFERER'
);
}
else
{
$redirect
=
base64_decode
(
$redirect
);
}
session
(
'login_http_referer'
,
$redirect
);
return
$this
->
fetch
(
":register"
);
}
if
(
cmf_is_user_login
())
{
return
redirect
(
$this
->
request
->
root
()
.
'/'
);
}
else
{
return
$this
->
fetch
(
":register"
);
public
function
getCode
(){
$param
=
$this
->
request
->
param
();
$code
=
cmf_get_verification_code
(
$param
[
'phone'
],
4
);
// var_dump($code);
if
(
$code
)
{
$mobile
=
new
MobileService
();
$mobile
->
sendSMSS
(
$param
[
'phone'
],
$code
);
$re
=
cmf_verification_code_log
(
$param
[
'phone'
],
$code
,
time
()
+
60
);
if
(
$re
){
return
'验证码发送成功'
;
}
else
{
return
'验证码发送失败'
;
}
}
else
{
return
'验证码发送失败'
;
}
}
/**
* 前台用户注册提交
*/
public
function
doRegister
()
{
if
(
$this
->
request
->
isPost
())
{
$rules
=
[
'captcha'
=>
'require'
,
'code'
=>
'require'
,
'password'
=>
'require|min:6|max:32'
,
];
$isOpenRegistration
=
cmf_is_open_registration
();
if
(
$isOpenRegistration
)
{
unset
(
$rules
[
'code'
]);
$param
=
$this
->
request
->
param
();
$result
=
cmf_check_verification_code
(
$param
[
'mobile'
],
$param
[
'code'
],
true
);
if
(
$result
==
''
)
{
$re
=
Db
::
name
(
'users'
)
->
where
([
'mobile'
=>
$param
[
'mobile'
],
'open_id'
=>
session
(
'user'
)[
'id'
]])
->
find
();
if
(
$re
)
{
//用户重复
return
'该用户已注册'
;
}
$validate
=
new
Validate
(
$rules
);
$validate
->
message
([
'code.require'
=>
'验证码不能为空'
,
'password.require'
=>
'密码不能为空'
,
'password.max'
=>
'密码不能超过32个字符'
,
'password.min'
=>
'密码不能小于6个字符'
,
'captcha.require'
=>
'验证码不能为空'
,
]);
$data
=
$this
->
request
->
post
();
if
(
!
$validate
->
check
(
$data
))
{
$this
->
error
(
$validate
->
getError
());
}
if
(
!
cmf_captcha_check
(
$data
[
'captcha'
]))
{
$this
->
error
(
'验证码错误'
);
}
if
(
!
$isOpenRegistration
){
$errMsg
=
cmf_check_verification_code
(
$data
[
'username'
],
$data
[
'code'
]);
if
(
!
empty
(
$errMsg
))
{
$this
->
error
(
$errMsg
);
}
}
$register
=
new
UserModel
();
$user
[
'user_pass'
]
=
$data
[
'password'
];
if
(
Validate
::
is
(
$data
[
'username'
],
'email'
))
{
$user
[
'user_email'
]
=
$data
[
'username'
];
$log
=
$register
->
registerEmail
(
$user
);
}
else
if
(
preg_match
(
'/(^(13\d|15[^4\D]|17[013678]|18\d)\d{8})$/'
,
$data
[
'username'
]))
{
$user
[
'mobile'
]
=
$data
[
'username'
];
$log
=
$register
->
registerMobile
(
$user
);
}
else
{
$log
=
2
;
}
$sessionLoginHttpReferer
=
session
(
'login_http_referer'
);
$redirect
=
empty
(
$sessionLoginHttpReferer
)
?
cmf_get_root
()
.
'/'
:
$sessionLoginHttpReferer
;
switch
(
$log
)
{
case
0
:
$this
->
success
(
'注册成功'
,
$redirect
);
break
;
case
1
:
$this
->
error
(
"您的账户已注册过"
);
break
;
case
2
:
$this
->
error
(
"您输入的账号格式错误"
);
break
;
default
:
$this
->
error
(
'未受理的请求'
);
}
unset
(
$param
[
'code'
]);
$param
[
'open_id'
]
=
session
(
'user'
)[
'id'
];
$param
[
'nickname'
]
=
session
(
'user'
)[
'nickname'
];
$param
[
'avatar'
]
=
session
(
'user'
)[
'avatar'
];
$param
[
'create_time'
]
=
time
();
Db
::
name
(
'users'
)
->
insert
(
$param
);
return
1
;
}
else
{
$this
->
error
(
"请求错误"
)
;
return
$result
;
}
}
}
\ No newline at end of file
...
...
public/themes/simpleboot3/user/register.html
查看文件 @
112083d
<!DOCTYPE html>
<html>
<html
lang=
"en"
>
<head>
<title></title>
<meta
name=
"keywords"
content=
""
/>
<meta
name=
"description"
content=
""
>
<include
file=
"public@head"
/>
<meta
charset=
"UTF-8"
>
<link
rel=
"stylesheet"
href=
"css/base.css"
>
<title>
注册页面
</title>
<style>
body
,
html
{
background
:
#fff
;
}
.title
{
width
:
7.5rem
;
height
:
0.2rem
;
font-size
:
0
;
}
.title
img
{
width
:
100%
;
height
:
100%
;
}
.register_phone
{
width
:
6.86rem
;
height
:
0.88rem
;
margin
:
0
auto
;
margin-top
:
0.66rem
;
display
:
flex
;
border
:
1px
solid
#f5f5f5
;
}
.register_code
{
width
:
6.86rem
;
height
:
0.88rem
;
margin
:
0
auto
;
margin-top
:
0.32rem
;
display
:
flex
;
border
:
1px
solid
#f5f5f5
;
}
.phone_img
{
width
:
0.24rem
;
height
:
0.35rem
;
font-size
:
0
;
}
.code_img
{
width
:
0.32rem
;
height
:
0.36rem
;
font-size
:
0
;
}
.code_img
img
{
width
:
100%
;
height
:
100%
;
}
.phone_img
img
{
width
:
100%
;
height
:
100%
;
}
.register_num
{
width
:
0.96rem
;
height
:
0.88rem
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
border-right
:
1px
solid
#f5f5f5
;
}
.register_tel
{
width
:
5.9rem
;
height
:
0.88rem
;
font-size
:
0
;
border-right
:
1px
solid
#f5f5f5
;
}
.register_codenum
{
width
:
4.3rem
;
height
:
0.88rem
;
font-size
:
0
;
border-right
:
1px
solid
#f5f5f5
;
}
.register_tel
input
{
width
:
5.9rem
;
height
:
0.84rem
;
border
:
none
;
outline
:
none
;
color
:
#97A0A8
;
font-size
:
0.28rem
;
margin-top
:
0.01rem
;
padding-left
:
0.53rem
;
margin-left
:
0.02rem
;
}
.register_codenum
input
{
width
:
4.3rem
;
height
:
0.84rem
;
border
:
none
;
outline
:
none
;
color
:
#97A0A8
;
font-size
:
0.28rem
;
margin-top
:
0.01rem
;
padding-left
:
0.53rem
;
margin-left
:
0.02rem
;
}
.getcode
{
color
:
#CA277B
;
font-size
:
0.24rem
;
height
:
0.88rem
;
line-height
:
0.88rem
;
border
:
none
;
outline
:
none
;
background
:
#fff
;
}
.sure
{
width
:
6.86rem
;
display
:
block
;
height
:
0.88rem
;
background
:
#CA277B
;
color
:
#fff
;
font-size
:
0.32rem
;
margin
:
0
auto
;
margin-top
:
0.72rem
;
border-radius
:
0.1rem
;
text-align
:
center
;
line-height
:
0.88rem
;
}
</style>
</head>
<body>
<div
class=
"container"
>
<div
class=
"title"
>
<img
src=
"__TMPL__/public/assets/images/img/line.png"
alt=
""
>
</div>
<div
class=
"register_phone"
>
<div
class=
"register_num"
>
<p
class=
"phone_img"
>
<img
src=
"__TMPL__/public/assets/images/img/phone.png"
alt=
""
>
</p>
</div>
<div
class=
"register_tel"
>
<input
type=
"text"
placeholder=
"手机号"
>
</div>
<body
class=
"body-white"
>
<include
file=
"public@nav"
/>
<div
class=
"container tc-main"
>
<div
class=
"row"
>
<div
class=
"col-md-4 col-md-offset-4"
>
<h2
class=
"text-center"
>
用户注册
</h2>
<php>
$mobile_tab_active=empty($theme_vars['enable_mobile'])?'':'active';
$email_tab_active=empty($theme_vars['enable_mobile'])?'active':'';
</php>
<notempty
name=
"theme_vars.enable_mobile"
>
<ul
class=
"nav nav-tabs nav-justified"
id=
"myTab"
style=
"margin-bottom: 15px;"
>
<li
class=
"active"
><a
href=
"#mobile"
data-toggle=
"tab"
>
手机注册
</a></li>
<li><a
href=
"#email"
data-toggle=
"tab"
>
邮箱注册
</a></li>
</ul>
</notempty>
<php>
$is_open_registration = cmf_is_open_registration();
</php>
<div
class=
"tab-content"
>
<notempty
name=
"theme_vars.enable_mobile"
>
<div
class=
"tab-pane {$mobile_tab_active}"
id=
"mobile"
>
<form
class=
"js-ajax-form"
action=
"{:url('user/Register/doRegister')}"
method=
"post"
>
<div
class=
"form-group"
>
<input
type=
"text"
name=
"username"
placeholder=
"手机号"
class=
"form-control"
id=
"js-mobile-input"
>
</div>
<empty
name=
"is_open_registration"
>
<div
class=
"form-group"
>
<div
style=
"position: relative;"
>
<input
type=
"text"
name=
"code"
placeholder=
"手机验证码"
style=
"width:170px;"
class=
"form-control"
>
<a
class=
"btn btn-success js-get-mobile-code"
style=
"width: 163px;position: absolute;top:0;right: 0;"
data-wait-msg=
"[second]秒后才能再次获取"
data-mobile-input=
"#js-mobile-input"
data-url=
"{:url('user/VerificationCode/send')}"
data-init-second-left=
"60"
>
获取手机验证码
</a>
</div>
</div>
</empty>
<div
class=
"form-group"
>
<input
type=
"password"
name=
"password"
placeholder=
"密码"
class=
"form-control"
>
</div>
<div
class=
"form-group"
>
<div
style=
"position: relative;"
>
<input
type=
"text"
name=
"captcha"
placeholder=
"验证码"
class=
"form-control"
style=
"width: 170px;float: left;margin-right: 30px"
>
<captcha
height=
"38"
width=
"160"
font-size=
"20"
/>
</div>
</div>
<div
class=
"form-group"
>
<button
class=
"btn btn-primary btn-block js-ajax-submit"
type=
"submit"
data-wait=
"1500"
style=
"margin-left: 0px;"
>
确定注册
</button>
</div>
<div
class=
"form-group"
style=
"text-align: center;"
>
<p>
已有账号?
<a
href=
"{:cmf_url('user/Login/index')}"
>
点击此处登录
</a>
</p>
</div>
</form>
</div>
</notempty>
<div
class=
"tab-pane {$email_tab_active}"
id=
"email"
>
<form
class=
"js-ajax-form"
action=
"{:url('user/register/doRegister')}"
method=
"post"
>
<div
class=
"form-group"
>
<input
type=
"text"
name=
"username"
placeholder=
"邮箱"
class=
"form-control"
id=
"js-email-input"
>
</div>
<empty
name=
"is_open_registration"
>
<div
class=
"form-group"
>
<div
style=
"position: relative;"
>
<input
type=
"text"
name=
"code"
placeholder=
"邮件验证码"
style=
"width:170px;"
class=
"form-control"
>
<a
class=
"btn btn-success js-get-email-code"
style=
"width: 163px;position: absolute;top:0;right: 0;"
data-wait-msg=
"[second]秒后才能再次获取"
data-email-input=
"#js-email-input"
data-url=
"{:url('user/VerificationCode/send')}"
data-init-second-left=
"60"
>
获取邮箱验证码
</a>
</div>
</div>
</empty>
<div
class=
"form-group"
>
<input
type=
"password"
name=
"password"
placeholder=
"密码"
class=
"form-control"
>
</div>
<div
class=
"form-group"
>
<div
style=
"position: relative;"
>
<input
type=
"text"
name=
"captcha"
placeholder=
"验证码"
class=
"form-control"
style=
"width: 170px;float: left;margin-right: 30px"
>
<captcha
height=
"38"
width=
"160"
font-size=
"20"
/>
</div>
</div>
<div
class=
"form-group"
>
<button
class=
"btn btn-primary btn-block js-ajax-submit"
type=
"submit"
data-wait=
"1500"
style=
"margin-left: 0px;"
>
确定注册
</button>
</div>
<div
class=
"form-group"
style=
"text-align: center;"
>
<p>
已有账号?
<a
href=
"{:cmf_url('user/Login/index')}"
>
点击此处登录
</a>
</p>
</div>
</form>
</div>
</div>
</div>
<div
class=
"register_code"
>
<div
class=
"register_num"
>
<p
class=
"code_img"
>
<img
src=
"__TMPL__/public/assets/images/img/code.png"
alt=
""
>
</p>
</div>
<div
class=
"register_codenum"
>
<input
type=
"text"
placeholder=
"验证码"
>
</div>
<button
class=
"getcode"
></button>
</div>
<button
class=
"sure"
>
确定
</button>
</div>
<!-- /container -->
<include
file=
"public@scripts"
/>
<script
type=
"text/javascript"
src=
"__TMPL__/public/assets/js/base.js"
></script>
<script
type=
"text/javascript"
src=
"__TMPL__/public/assets/js/jquery.min.js"
></script>
<script>
var
InterValObj
;
//timer变量,控制时间
var
count
=
10
;
//间隔函数,1秒执行
var
curCount
=
''
;
//当前剩余秒数
var
t
=
localStorage
.
getItem
(
"time"
);
InterValObj
=
window
.
setInterval
(
SetRemainTime
,
1000
);
if
(
t
!=
null
){
curCount
=
t
;
$
(
".sure"
).
attr
(
"disabled"
,
true
);
}
else
{
curCount
=
60
;
window
.
clearInterval
(
InterValObj
);
$
(
".getcode"
).
html
(
"获取验证码"
);
}
//启动计时器,1秒执行一次
$
(
".getcode"
).
click
(
function
(){
curCount
=
count
;
//设置button效果,开始计时
$
(
".getcode"
).
attr
(
"disabled"
,
true
);
$
(
".sure"
).
attr
(
"disabled"
,
true
);
// $(".sendcode").unbind()
$
(
".getcode"
).
html
(
curCount
+
"秒"
);
InterValObj
=
window
.
setInterval
(
SetRemainTime
,
1000
);
//启动计时器,1秒执行一次
});
//timer处理函数
function
SetRemainTime
()
{
if
(
curCount
==
0
)
{
window
.
clearInterval
(
InterValObj
);
//停止计时器
$
(
".getcode"
).
removeAttr
(
"disabled"
);
//启用按钮
$
(
".sure"
).
removeAttr
(
"disabled"
);
$
(
".getcode"
).
html
(
"重新获取证码"
);
localStorage
.
clear
();
}
else
{
curCount
--
;
localStorage
.
setItem
(
"time"
,
curCount
);
$
(
".getcode"
).
html
(
curCount
+
"秒"
);
}
}
</script>
</body>
</html>
\ No newline at end of file
</html>
...
...
simplewind/cmf/controller/WeChatBaseController.php
查看文件 @
112083d
...
...
@@ -223,7 +223,7 @@ class WeChatBaseController extends BaseController
public
function
checkUser
(){
$re
=
Db
::
name
(
'users'
)
->
where
([
'open_id'
=>
session
(
'wechat_user'
)[
'id'
]])
->
find
();
if
(
!
$re
[
'mobile'
]){
$this
->
redirect
(
url
(
'user/
login/login
'
));
$this
->
redirect
(
url
(
'user/
register/register
'
));
// }else{
// return $re;
}
else
{
...
...
请
注册
或
登录
后发表评论