Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
2d78fe03
Commit
2d78fe03
authored
Apr 02, 2018
by
Junling Bu
Browse files
update[litemall-wx, litemall-wx-api]: 实现账号注册功能,但是手机验证码不支持。
parent
f55066f9
Changes
5
Hide whitespace changes
Inline
Side-by-side
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxAuthController.java
View file @
2d78fe03
...
@@ -173,6 +173,7 @@ public class WxAuthController {
...
@@ -173,6 +173,7 @@ public class WxAuthController {
user
=
new
LitemallUser
();
user
=
new
LitemallUser
();
user
.
setUsername
(
username
);
user
.
setUsername
(
username
);
user
.
setPassword
(
password
);
user
.
setPassword
(
password
);
user
.
setMobile
(
mobile
);
user
.
setWeixinOpenid
(
""
);
user
.
setWeixinOpenid
(
""
);
user
.
setAvatar
(
"https://yanxuan.nosdn.127.net/80841d741d7fa3073e0ae27bf487339f.jpg?imageView&quality=90&thumbnail=64x64"
);
user
.
setAvatar
(
"https://yanxuan.nosdn.127.net/80841d741d7fa3073e0ae27bf487339f.jpg?imageView&quality=90&thumbnail=64x64"
);
user
.
setNickname
(
username
);
user
.
setNickname
(
username
);
...
@@ -198,4 +199,35 @@ public class WxAuthController {
...
@@ -198,4 +199,35 @@ public class WxAuthController {
result
.
put
(
"userInfo"
,
userInfo
);
result
.
put
(
"userInfo"
,
userInfo
);
return
ResponseUtil
.
ok
(
result
);
return
ResponseUtil
.
ok
(
result
);
}
}
/**
* 账号密码重置
*/
@PostMapping
(
"reset"
)
public
Object
reset
(
@RequestBody
String
body
,
HttpServletRequest
request
)
{
String
password
=
JacksonUtil
.
parseString
(
body
,
"password"
);
String
mobile
=
JacksonUtil
.
parseString
(
body
,
"mobile"
);
String
code
=
JacksonUtil
.
parseString
(
body
,
"code"
);
if
(
mobile
==
null
||
code
==
null
||
password
==
null
){
return
ResponseUtil
.
badArgument
();
}
List
<
LitemallUser
>
userList
=
userService
.
queryByMobile
(
mobile
);
LitemallUser
user
=
null
;
if
(
userList
.
size
()
>
1
){
return
ResponseUtil
.
serious
();
}
else
if
(
userList
.
size
()
==
0
){
return
ResponseUtil
.
fail
(
403
,
"手机号未注册"
);
}
else
{
user
=
userList
.
get
(
0
);
}
user
.
setPassword
(
password
);
userService
.
update
(
user
);
return
ResponseUtil
.
ok
();
}
}
}
litemall-wx/config/api.js
View file @
2d78fe03
...
@@ -23,6 +23,7 @@ module.exports = {
...
@@ -23,6 +23,7 @@ module.exports = {
AuthLoginByWeixin
:
WxApiRoot
+
'
auth/login_by_weixin
'
,
//微信登录
AuthLoginByWeixin
:
WxApiRoot
+
'
auth/login_by_weixin
'
,
//微信登录
AuthLoginByAccount
:
WxApiRoot
+
'
auth/login
'
,
//账号登录
AuthLoginByAccount
:
WxApiRoot
+
'
auth/login
'
,
//账号登录
AuthRegister
:
WxApiRoot
+
'
auth/register
'
,
//账号注册
AuthRegister
:
WxApiRoot
+
'
auth/register
'
,
//账号注册
AuthReset
:
WxApiRoot
+
'
auth/reset
'
,
//账号密码重置
GoodsCount
:
WxApiRoot
+
'
goods/count
'
,
//统计商品总数
GoodsCount
:
WxApiRoot
+
'
goods/count
'
,
//统计商品总数
GoodsList
:
WxApiRoot
+
'
goods/list
'
,
//获得商品列表
GoodsList
:
WxApiRoot
+
'
goods/list
'
,
//获得商品列表
...
...
litemall-wx/pages/auth/reset/reset.js
View file @
2d78fe03
var
api
=
require
(
'
../../../config/api.js
'
);
var
app
=
getApp
();
var
app
=
getApp
();
Page
({
Page
({
data
:
{
data
:
{
username
:
''
,
mobile
:
''
,
code
:
''
code
:
''
,
password
:
''
,
confirmPassword
:
''
},
},
onLoad
:
function
(
options
)
{
onLoad
:
function
(
options
)
{
// 页面初始化 options为页面跳转所带来的参数
// 页面初始化 options为页面跳转所带来的参数
...
@@ -24,13 +27,84 @@ Page({
...
@@ -24,13 +27,84 @@ Page({
// 页面关闭
// 页面关闭
},
},
startLogin
:
function
(){
sendCode
:
function
()
{
wx
.
showModal
({
title
:
'
注意
'
,
content
:
'
由于目前不支持手机短信发送,因此验证码任意值都可以
'
,
showCancel
:
false
});
},
startReset
:
function
(){
var
that
=
this
;
var
that
=
this
;
if
(
this
.
data
.
mobile
.
length
==
0
||
this
.
data
.
code
.
length
==
0
)
{
wx
.
showModal
({
title
:
'
错误信息
'
,
content
:
'
手机号和验证码不能为空
'
,
showCancel
:
false
});
return
false
;
}
if
(
this
.
data
.
password
.
length
<
3
)
{
wx
.
showModal
({
title
:
'
错误信息
'
,
content
:
'
用户名和密码不得少于3位
'
,
showCancel
:
false
});
return
false
;
}
if
(
this
.
data
.
password
!=
this
.
data
.
confirmPassword
)
{
wx
.
showModal
({
title
:
'
错误信息
'
,
content
:
'
确认密码不一致
'
,
showCancel
:
false
});
return
false
;
}
wx
.
request
({
url
:
api
.
AuthReset
,
data
:
{
mobile
:
that
.
data
.
mobile
,
code
:
that
.
data
.
code
,
password
:
that
.
data
.
password
},
method
:
'
POST
'
,
header
:
{
'
content-type
'
:
'
application/json
'
},
success
:
function
(
res
)
{
if
(
res
.
data
.
errno
==
0
)
{
wx
.
navigateBack
();
}
else
{
wx
.
showModal
({
title
:
'
密码重置失败
'
,
content
:
res
.
data
.
errmsg
,
showCancel
:
false
});
}
}
});
},
},
bindUsernameInput
:
function
(
e
){
bindPasswordInput
:
function
(
e
)
{
this
.
setData
({
password
:
e
.
detail
.
value
});
},
bindConfirmPasswordInput
:
function
(
e
)
{
this
.
setData
({
confirmPassword
:
e
.
detail
.
value
});
},
bindMobileInput
:
function
(
e
)
{
this
.
setData
({
this
.
setData
({
usernam
e
:
e
.
detail
.
value
mobil
e
:
e
.
detail
.
value
});
});
},
},
bindCodeInput
:
function
(
e
){
bindCodeInput
:
function
(
e
){
...
@@ -41,12 +115,22 @@ Page({
...
@@ -41,12 +115,22 @@ Page({
},
},
clearInput
:
function
(
e
){
clearInput
:
function
(
e
){
switch
(
e
.
currentTarget
.
id
){
switch
(
e
.
currentTarget
.
id
){
case
'
clear-username
'
:
case
'
clear-password
'
:
this
.
setData
({
password
:
''
});
break
;
case
'
clear-confirm-password
'
:
this
.
setData
({
confirmPassword
:
''
});
break
;
case
'
clear-mobile
'
:
this
.
setData
({
this
.
setData
({
usernam
e
:
''
mobil
e
:
''
});
});
break
;
break
;
case
'
clear-code
'
:
case
'
clear-code
'
:
this
.
setData
({
this
.
setData
({
code
:
''
code
:
''
});
});
...
...
litemall-wx/pages/auth/reset/reset.wxml
View file @
2d78fe03
<view class="container">
<view class="container">
<view class="form-box">
<view class="form-box">
<view class="form-item">
<view class="form-item">
<input class="
usernam
e" value="{{
usernam
e}}" bindinput="bind
Usernam
eInput" placeholder="
请输入账号" auto-focus
/>
<input class="
mobil
e" value="{{
mobil
e}}" bindinput="bind
Mobil
eInput" placeholder="
手机号"
/>
<image wx:if="{{
usernam
e.length > 0 }}" id="clear-
usernam
e" class="clear" src="/static/images/clear_input.png" catchtap="clearInput"></image>
<image wx:if="{{
mobil
e.length > 0 }}" id="clear-
mobil
e" class="clear" src="/static/images/clear_input.png" catchtap="clearInput"></image>
</view>
</view>
<view class="form-item-code"
>
<view class="form-item-code">
<view class="form-item code-item">
<view class="form-item code-item">
<input class="code" value="{{code}}" bindinput="bindCodeInput" placeholder="验证码"/>
<input class="code" value="{{code}}" bindinput="bindCodeInput" placeholder="验证码"
/>
<image class="clear" id="clear-code" wx:if="{{ code.length > 0 }}" src="/static/images/clear_input.png" catchtap="clearInput"></image>
<image class="clear" id="clear-code" wx:if="{{ code.length > 0 }}" src="/static/images/clear_input.png" catchtap="clearInput"></image>
</view>
</view>
<image
class="code-
img" src="https://dl.reg.163.com/cp?pd=yanxuan_web&pkid=SkeBZeG&random=1489903563234"></image
>
<view
class="code-
btn" bindtap="sendCode">获取验证码</view
>
</view>
</view>
<button type="default" class="login-btn" bindtap="startNext">下一步</button>
<view class="form-item">
<input class="password" value="{{password}}" password bindinput="bindPasswordInput" placeholder="密码" />
<image class="clear" id="clear-password" wx:if="{{ password.length > 0 }}" src="/static/images/clear_input.png" catchtap="clearInput"></image>
</view>
<view class="form-item">
<input class="password" value="{{confirmPassword}}" password bindinput="bindConfirmPasswordInput" placeholder="确认密码" />
<image class="clear" id="clear-confirm-password" wx:if="{{ confirmPassword.length > 0 }}" src="/static/images/clear_input.png" catchtap="clearInput"></image>
</view>
</view>
<button type="default" class="reset-btn" bindtap="startReset">密码重置</button>
</view>
</view>
</view>
\ No newline at end of file
litemall-wx/pages/auth/reset/reset.wxss
View file @
2d78fe03
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
border-bottom: 1px solid #d9d9d9;
border-bottom: 1px solid #d9d9d9;
}
}
.form-item .
username
, .form-item .code{
.form-item .
mobile, .form-item .password
, .form-item .code{
position: absolute;
position: absolute;
top: 26rpx;
top: 26rpx;
left: 0;
left: 0;
...
@@ -38,11 +38,11 @@
...
@@ -38,11 +38,11 @@
width: 350rpx;
width: 350rpx;
}
}
.form-item-code .code-
img
{
.form-item-code .code-
btn
{
float: right;
float: right;
margin-top:
4rpx;
padding: 20rpx
4
0
rpx;
height: 88rpx
;
border: 1px solid #d9d9d9
;
width: 236
rpx;
border-radius: 10
rpx;
}
}
.form-item .clear{
.form-item .clear{
...
@@ -56,7 +56,7 @@
...
@@ -56,7 +56,7 @@
width: 44rpx;
width: 44rpx;
}
}
.
login
-btn{
.
reset
-btn{
margin: 60rpx 0 40rpx 0;
margin: 60rpx 0 40rpx 0;
height: 96rpx;
height: 96rpx;
line-height: 96rpx;
line-height: 96rpx;
...
@@ -65,4 +65,4 @@
...
@@ -65,4 +65,4 @@
width: 100%;
width: 100%;
background: #b4282d;
background: #b4282d;
border-radius: 6rpx;
border-radius: 6rpx;
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
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