Browse Source

fix[litemall-wx, litemall-wx-api]: 注册时验证码验证不正确

Junling Bu 7 years ago
parent
commit
fe595203ce

+ 3 - 3
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxAuthController.java

@@ -244,11 +244,11 @@ public class WxAuthController {
         String username = JacksonUtil.parseString(body, "username");
         String password = JacksonUtil.parseString(body, "password");
         String mobile = JacksonUtil.parseString(body, "mobile");
-        String captcha = JacksonUtil.parseString(body, "captcha");
         String code = JacksonUtil.parseString(body, "code");
+        String wxCode = JacksonUtil.parseString(body, "wxCode");
 
         if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password) || StringUtils.isEmpty(mobile)
-            || StringUtils.isEmpty(captcha) || StringUtils.isEmpty(code)) {
+            || StringUtils.isEmpty(wxCode) || StringUtils.isEmpty(code)) {
             return ResponseUtil.badArgument();
         }
 
@@ -272,7 +272,7 @@ public class WxAuthController {
 
         String openId = null;
         try {
-            WxMaJscode2SessionResult result = this.wxService.getUserService().getSessionInfo(code);
+            WxMaJscode2SessionResult result = this.wxService.getUserService().getSessionInfo(wxCode);
             openId = result.getOpenid();
         } catch (Exception e) {
             e.printStackTrace();

+ 10 - 10
litemall-wx/pages/auth/register/register.js

@@ -9,7 +9,7 @@ Page({
     password: '',
     confirmPassword: '',
     mobile: '',
-    captcha: ''
+    code: ''
   },
   onLoad: function (options) {
     // 页面初始化 options为页面跳转所带来的参数
@@ -31,7 +31,7 @@ Page({
     // 页面关闭
 
   },
-  sendCaptcha: function () {
+  sendCode: function () {
     let that = this;
 
     if (this.data.mobile.length == 0) {
@@ -79,7 +79,7 @@ Page({
       }
     });
   },
-  requestRegister: function (code) {
+  requestRegister: function (wxCode) {
     let that = this;
     wx.request({
       url: api.AuthRegister,
@@ -87,8 +87,8 @@ Page({
         username: that.data.username,
         password: that.data.password,
         mobile: that.data.mobile,
-        captcha: that.data.captcha,
-        code: code
+        code: that.data.code,
+        wxCode: wxCode
       },
       method: 'POST',
       header: {
@@ -139,7 +139,7 @@ Page({
       return false;
     }
 
-    if (this.data.mobile.length == 0 || this.data.captcha.length == 0) {
+    if (this.data.mobile.length == 0 || this.data.code.length == 0) {
       wx.showModal({
         title: '错误信息',
         content: '手机号和验证码不能为空',
@@ -195,10 +195,10 @@ Page({
       mobile: e.detail.value
     });
   },
-  bindCaptchaInput: function (e) {
+  bindCodeInput: function (e) {
 
     this.setData({
-      captcha: e.detail.value
+      code: e.detail.value
     });
   },
   clearInput: function (e) {
@@ -223,9 +223,9 @@ Page({
           mobile: ''
         });
         break;        
-      case 'clear-captcha':
+      case 'clear-code':
         this.setData({
-          captcha: ''
+          code: ''
         });
         break;
     }

+ 5 - 5
litemall-wx/pages/auth/register/register.wxml

@@ -21,12 +21,12 @@
     	<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-captcha" >
-			<view class="form-item captcha-item">
-				<input class="captcha" value="{{captcha}}" bindinput="bindCaptchaInput" placeholder="验证码"/>
-				<image class="clear" id="clear-captcha" wx:if="{{ captcha.length > 0 }}" src="/static/images/clear_input.png" catchtap="clearInput"></image>
+    <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="captcha-btn" bindtap="sendCaptcha">获取验证码</view>
+			<view class="code-btn" bindtap="sendCode">获取验证码</view>
 		</view>
 
     	<button type="primary" class="register-btn" bindtap="startRegister">注册</button>

+ 4 - 4
litemall-wx/pages/auth/register/register.wxss

@@ -14,7 +14,7 @@
     border-bottom: 1px solid #d9d9d9;
 }
 
-.form-item .username, .form-item .password, .form-item .mobile, .form-item .captcha{
+.form-item .username, .form-item .password, .form-item .mobile, .form-item .code{
     position: absolute;
     top: 26rpx;
     left: 0;
@@ -26,19 +26,19 @@
     font-size: 30rpx;
 }
 
-.form-item-captcha{
+.form-item-code{
     margin-top:32rpx;
     height: auto;
     overflow: hidden;
     width: 100%;
 }
 
-.form-item-captcha .form-item{
+.form-item-code .form-item{
     float: left;
     width: 350rpx;
 }
 
-.form-item-captcha .captcha-btn{
+.form-item-code .code-btn{
     float: right;
     padding: 20rpx 40rpx;
     border: 1px solid #d9d9d9;