update[litemall-wx, litemall-wx-api]: 实现账号注册功能,但是手机验证码不支持。
This commit is contained in:
@@ -173,6 +173,7 @@ public class WxAuthController {
|
||||
user = new LitemallUser();
|
||||
user.setUsername(username);
|
||||
user.setPassword(password);
|
||||
user.setMobile(mobile);
|
||||
user.setWeixinOpenid("");
|
||||
user.setAvatar("https://yanxuan.nosdn.127.net/80841d741d7fa3073e0ae27bf487339f.jpg?imageView&quality=90&thumbnail=64x64");
|
||||
user.setNickname(username);
|
||||
@@ -198,4 +199,35 @@ public class WxAuthController {
|
||||
result.put("userInfo", userInfo);
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ module.exports = {
|
||||
AuthLoginByWeixin: WxApiRoot + 'auth/login_by_weixin', //微信登录
|
||||
AuthLoginByAccount: WxApiRoot + 'auth/login', //账号登录
|
||||
AuthRegister: WxApiRoot + 'auth/register', //账号注册
|
||||
AuthReset: WxApiRoot + 'auth/reset', //账号密码重置
|
||||
|
||||
GoodsCount: WxApiRoot + 'goods/count', //统计商品总数
|
||||
GoodsList: WxApiRoot + 'goods/list', //获得商品列表
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
var api = require('../../../config/api.js');
|
||||
var app = getApp();
|
||||
Page({
|
||||
data: {
|
||||
username: '',
|
||||
code: ''
|
||||
mobile: '',
|
||||
code: '',
|
||||
password: '',
|
||||
confirmPassword: ''
|
||||
},
|
||||
onLoad: function (options) {
|
||||
// 页面初始化 options为页面跳转所带来的参数
|
||||
@@ -24,13 +27,84 @@ Page({
|
||||
// 页面关闭
|
||||
|
||||
},
|
||||
startLogin: function(){
|
||||
var that = this;
|
||||
sendCode: function () {
|
||||
wx.showModal({
|
||||
title: '注意',
|
||||
content: '由于目前不支持手机短信发送,因此验证码任意值都可以',
|
||||
showCancel: false
|
||||
});
|
||||
},
|
||||
bindUsernameInput: function(e){
|
||||
|
||||
startReset: function(){
|
||||
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
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
bindPasswordInput: function (e) {
|
||||
|
||||
this.setData({
|
||||
username: e.detail.value
|
||||
password: e.detail.value
|
||||
});
|
||||
},
|
||||
bindConfirmPasswordInput: function (e) {
|
||||
|
||||
this.setData({
|
||||
confirmPassword: e.detail.value
|
||||
});
|
||||
},
|
||||
bindMobileInput: function (e) {
|
||||
|
||||
this.setData({
|
||||
mobile: e.detail.value
|
||||
});
|
||||
},
|
||||
bindCodeInput: function(e){
|
||||
@@ -41,12 +115,22 @@ Page({
|
||||
},
|
||||
clearInput: function(e){
|
||||
switch (e.currentTarget.id){
|
||||
case 'clear-username':
|
||||
case 'clear-password':
|
||||
this.setData({
|
||||
username: ''
|
||||
password: ''
|
||||
});
|
||||
break;
|
||||
case 'clear-code':
|
||||
case 'clear-confirm-password':
|
||||
this.setData({
|
||||
confirmPassword: ''
|
||||
});
|
||||
break;
|
||||
case 'clear-mobile':
|
||||
this.setData({
|
||||
mobile: ''
|
||||
});
|
||||
break;
|
||||
case 'clear-code':
|
||||
this.setData({
|
||||
code: ''
|
||||
});
|
||||
|
||||
@@ -1,20 +1,30 @@
|
||||
<view class="container">
|
||||
<view class="form-box">
|
||||
|
||||
<view class="form-item">
|
||||
<input class="username" value="{{username}}" bindinput="bindUsernameInput" placeholder="请输入账号" auto-focus/>
|
||||
<image wx:if="{{ username.length > 0 }}" id="clear-username" class="clear" src="/static/images/clear_input.png" catchtap="clearInput"></image>
|
||||
</view>
|
||||
|
||||
<view class="form-item-code" >
|
||||
<view class="form-item code-item">
|
||||
<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>
|
||||
</view>
|
||||
<image class="code-img" src="https://dl.reg.163.com/cp?pd=yanxuan_web&pkid=SkeBZeG&random=1489903563234"></image>
|
||||
</view>
|
||||
|
||||
<button type="default" class="login-btn" bindtap="startNext">下一步</button>
|
||||
<view class="form-box">
|
||||
|
||||
<view class="form-item">
|
||||
<input class="mobile" value="{{mobile}}" bindinput="bindMobileInput" placeholder="手机号" />
|
||||
<image wx:if="{{ mobile.length > 0 }}" id="clear-mobile" class="clear" src="/static/images/clear_input.png" catchtap="clearInput"></image>
|
||||
</view>
|
||||
|
||||
<view class="form-item-code">
|
||||
<view class="form-item code-item">
|
||||
<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>
|
||||
</view>
|
||||
<view class="code-btn" bindtap="sendCode">获取验证码</view>
|
||||
</view>
|
||||
|
||||
<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>
|
||||
|
||||
<button type="default" class="reset-btn" bindtap="startReset">密码重置</button>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
@@ -14,7 +14,7 @@
|
||||
border-bottom: 1px solid #d9d9d9;
|
||||
}
|
||||
|
||||
.form-item .username, .form-item .code{
|
||||
.form-item .mobile, .form-item .password, .form-item .code{
|
||||
position: absolute;
|
||||
top: 26rpx;
|
||||
left: 0;
|
||||
@@ -38,11 +38,11 @@
|
||||
width: 350rpx;
|
||||
}
|
||||
|
||||
.form-item-code .code-img{
|
||||
.form-item-code .code-btn{
|
||||
float: right;
|
||||
margin-top: 4rpx;
|
||||
height: 88rpx;
|
||||
width: 236rpx;
|
||||
padding: 20rpx 40rpx;
|
||||
border: 1px solid #d9d9d9;
|
||||
border-radius: 10rpx;
|
||||
}
|
||||
|
||||
.form-item .clear{
|
||||
@@ -56,7 +56,7 @@
|
||||
width: 44rpx;
|
||||
}
|
||||
|
||||
.login-btn{
|
||||
.reset-btn{
|
||||
margin: 60rpx 0 40rpx 0;
|
||||
height: 96rpx;
|
||||
line-height: 96rpx;
|
||||
@@ -65,4 +65,4 @@
|
||||
width: 100%;
|
||||
background: #b4282d;
|
||||
border-radius: 6rpx;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user