XWookey 2 năm trước cách đây
mục cha
commit
75e307038b

BIN
images/vcode.png


+ 195 - 41
pages/register/register.js

@@ -16,7 +16,14 @@ Page({
     userInfo: {},
     hasUserInfo: false,
     canIUseGetUserProfile: false,
-
+    vcodeFlag: false,
+    vcodeTimeOut: 0,
+    vcodeTimeOutDefault: 0,
+    scene: "REGIST",
+    vcodeLen:2,
+    vcodeInterval:null,
+    vcode_button_text:'获取验证码',
+    servicetel: '4009608068'
   },
 
   /**
@@ -28,6 +35,24 @@ Page({
         canIUseGetUserProfile: true
       })
     }
+    let scene = this.data.scene;
+    let that = this
+    wx.request({
+      url: getApp().globalData.postHeadAgreement + '/restapi/wechat/vcodeInfo',
+      data: {
+        scene,
+      },
+      method: 'POST',
+      success(res) {
+        that.setData({
+          vcodeInfo:false,
+          vcodeTimeOut:res.data.result.expire,
+          vcodeTimeOutDefault:res.data.result.expire,
+          vcodeLen:res.data.result.len
+        })
+      }
+    });
+
 
     //var that = this;
     //查看是否授权
@@ -82,7 +107,8 @@ Page({
         password,
         phone,
         carNum,
-        email
+        email,
+        vcode
       } = this.data;
       wx.login({
         success(res) {
@@ -98,8 +124,10 @@ Page({
                 password,
                 phonenumber: phone,
                 email,
+                vcode,
                 license_number: carNum,
-                code: res.code
+                code: res.code,
+                
               },
               method: 'POST',
               success(res1) {
@@ -154,6 +182,12 @@ Page({
     });
     this.checkAll();
   },
+  inputVcode(e) {
+    this.setData({
+      vcode: e.detail.value
+    });
+    this.checkAll();
+  },
   inputEmail(e) {
     this.setData({
       email: e.detail.value
@@ -174,8 +208,14 @@ Page({
   },
   checkPhone() {
     if (!(/^1[3456789]\d{9}$/.test(this.data.phone))) {
+      this.setData({
+        vcodeFlag:false
+      })
       return false;
     }
+    this.setData({
+      vcodeFlag:true
+    })
     return true;
   },
   checkMail() {
@@ -184,6 +224,15 @@ Page({
     }
     return true;
   },
+  checkVcode() {
+    if (this.data.vcode==undefined || this.data.vcode=="") {
+      return false;
+    }
+    if(this.data.vcode.length==this.data.vcodeLen){
+      return true;
+    }
+    return false;
+  },
   checkCarNum(){
     if (this.data.carNum){
       // if (!(/^(([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z](([0-9]{5}[DF])|([DF]([A-HJ-NP-Z0-9])[0-9]{4})))|([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z][A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳使领]))$/.test(this.data.carNum))) {
@@ -193,65 +242,139 @@ Page({
     }
     return true;
   },
-  checkAll() {
-    if (!this.data.userName || !this.data.userName.replace(/(^\s*)|(\s*$)/g,"")) {
-      this.setData({
-        errorMsg: '账号不能为空'
-      });
-      this.setData({
-        checkPass: false
-      });
-      return;
-    } else if (this.data.userName.length < 2 || this.data.userName.length > 20) {
-      this.setData({
-        errorMsg: '账号长度应为2-20'
-      });
-      this.setData({
-        checkPass: false
-      });
-      return;
-    } else if (!(/^[a-zA-Z0-9_.\u4e00-\u9fa5]+$/.test(this.data.userName))) {
-      this.setData({
-        errorMsg: '账号只能包含字母、数字、中文、下划线和点'
-      });
-      this.setData({
-        checkPass: false
-      });
-      return;
-    }else{
-      this.setData({
-        errorMsg: ''
-      }); 
-    }
-    if (!this.checkPhone()) {
-      this.setData({
+  sendVcode(e){
+    let that  = this
+    if (!that.checkPhone()) {
+      that.setData({
         errorMsg: '手机号输入有误,请重新输入'
       });
-      this.setData({
+      that.setData({
         checkPass: false
       });
       return;
     } else {
-      this.setData({
+      that.setData({
         errorMsg: ''
       });
     }
-    if (!this.checkMail()) {
+    that.setData({
+      vcodeTimeOut:this.data.vcodeTimeOutDefault
+    })
+
+    let phone = that.data.phone;
+    let vcodeInterval = setInterval(that.vcodeFun,1000);
+    that.setData({
+      vcodeInterval 
+    })
+
+    wx.request({
+      url: getApp().globalData.postHeadAgreement + '/restapi/wechat/sendPhoneVcodeUnique',
+      data: {
+        scene: that.data.scene,
+        terminal: phone,
+      },
+      method: 'POST',
+      success(res) {
+        //console.log(res1);
+        //console.log(res1.data.code == 1);
+        if (res.data.code == 1) {
+          wx.showModal({
+            title: '提示',
+            content:res.data.msg,
+            showCancel:false,
+            confirmColor:'#4359b5'
+          });
+        }else if (res.data.code == 2) {
+          // 跳转
+          wx.showModal({
+            title: '提示',
+            content: '手机号已绑定账户,请检查手机号是否填写正确或联系客服',
+            showCancel:true,
+            confirmText: '去登陆',
+            confirmColor:'#36a9a6',
+            success: function (res1) {
+              if (res1.confirm) {
+                let url = '/pages/login/login';
+                wx.redirectTo({
+                  url
+                })
+              }
+            }
+      
+          });
+        }else{
+          
+        }
+      }
+    });
+
+
+  },
+  vcodeFun(){
+    
+      if(this.data.vcodeTimeOut<=0){
+        this.setData({
+          vcodeFlag:true,
+          vcode_button_text:'获取验证码'
+        })
+        clearInterval(this.data.vcodeInterval)
+      }else{
+        this.setData({
+          vcodeTimeOut:this.data.vcodeTimeOut-1,
+          vcodeFlag:false,
+          vcode_button_text:'获取验证码(' + this.data.vcodeTimeOut+'s)'
+        })
+      }
+
+  },
+  checkAll() {
+    // if (!this.data.userName || !this.data.userName.replace(/(^\s*)|(\s*$)/g,"")) {
+    //   this.setData({
+    //     errorMsg: '账号不能为空'
+    //   });
+    //   this.setData({
+    //     checkPass: false
+    //   });
+    //   return;
+    // } else if (this.data.userName.length < 2 || this.data.userName.length > 20) {
+    //   this.setData({
+    //     errorMsg: '账号长度应为2-20'
+    //   });
+    //   this.setData({
+    //     checkPass: false
+    //   });
+    //   return;
+    // } else if (!(/^[a-zA-Z0-9_.\u4e00-\u9fa5]+$/.test(this.data.userName))) {
+    //   this.setData({
+    //     errorMsg: '账号只能包含字母、数字、中文、下划线和点'
+    //   });
+    //   this.setData({
+    //     checkPass: false
+    //   });
+    //   return;
+    // }else{
+    //   this.setData({
+    //     errorMsg: ''
+    //   }); 
+    // }
+    if (!this.checkPhone()) {
       this.setData({
-        errorMsg: '邮箱输入有误,请重新输入'
+        errorMsg: '手机号输入有误,请重新输入'
       });
       this.setData({
         checkPass: false
       });
+
       return;
     } else {
       this.setData({
         errorMsg: ''
       });
+
     }
-    if (!this.checkCarNum()) {
+    if (!this.checkVcode()) {
       this.setData({
-        errorMsg: '车牌号输入有误,请重新输入'
+        errorMsg: '验证码格式不正确'
       });
       this.setData({
         checkPass: false
@@ -262,6 +385,32 @@ Page({
         errorMsg: ''
       });
     }
+    // if (!this.checkMail()) {
+    //   this.setData({
+    //     errorMsg: '邮箱输入有误,请重新输入'
+    //   });
+    //   this.setData({
+    //     checkPass: false
+    //   });
+    //   return;
+    // } else {
+    //   this.setData({
+    //     errorMsg: ''
+    //   });
+    // }
+    // if (!this.checkCarNum()) {
+    //   this.setData({
+    //     errorMsg: '车牌号输入有误,请重新输入'
+    //   });
+    //   this.setData({
+    //     checkPass: false
+    //   });
+    //   return;
+    // } else {
+    //   this.setData({
+    //     errorMsg: ''
+    //   });
+    // }
     if (this.data.password && (this.data.password.length < 5 || this.data.password.length > 20)) {
       this.setData({
         errorMsg: '密码长度应为5-20'
@@ -288,6 +437,11 @@ Page({
       checkPass: true
     });
   },
+  phoneCall(){
+    wx.makePhoneCall({
+      phoneNumber: this.data.servicetel,
+    })
+  },
   /**
    * 生命周期函数--监听页面初次渲染完成
    */

+ 17 - 6
pages/register/register.wxml

@@ -5,29 +5,36 @@
     <view class="logo_view"><image class="login_logo1" src="/images/login_logo1.png"></image></view>
     <view class="logo_view"><image class="login_logo2" src="/images/login_logo2.png"></image></view>
     <view class='context_input'>
-      <view class='input_view'>
+      <!-- <view class='input_view'>
         <image class='account_img' src='/images/account.png'></image><div class="line"></div>
         <input placeholder='请设置账号' bindinput='inputAccount' maxlength='20' focus='true' placeholder-class='placeholder'></input>
-      </view>
+      </view> -->
 
       <view class='input_view'>
         <image class='phone_img' src='/images/phone.png'></image><div class="line"></div>
-        <input placeholder='请输入电话' maxlength='11' bindinput='inputPhone' type='number' placeholder-class='placeholder'></input>
+        <input placeholder='请输手机号' maxlength='11' bindinput='inputPhone' type='number' placeholder-class='placeholder'></input>
       </view>  
+
       <view class='input_view'>
+        <image class='phone_img' src='/images/vcode.png'></image><div class="line"></div>
+        <input placeholder='请输入验证码' maxlength='6' bindinput='inputVcode' type='number' placeholder-class='placeholder'></input>
+        <view class='{{vcodeFlag?"vcode_button":"vcode_button_disable"}}' bindtap="{{vcodeFlag?'sendVcode':''}}">{{vcode_button_text}}</view>
+      </view>  
+
+      <!-- <view class='input_view'>
         <image class='email_img' src='/images/email1.png'></image><div class="line"></div>
         <input placeholder='请输入邮箱' maxlength='48' bindinput='inputEmail' type='text' placeholder-class='placeholder'></input>
-      </view> 
+      </view>  -->
       <!-- 
         <view class='input_view'>
           <image class='man_img' src='/images/man.png'></image>
           <input placeholder='请选择性别' maxlength='16' bindinput='checkPassword' type='password' placeholder-class='placeholder'></input>
         </view> 
       -->  
-    <view class='input_view'>
+    <!-- <view class='input_view'>
         <image class='carNum_img' src='/images/car.png'></image><div class="line"></div>
         <input placeholder='请输入车牌号' maxlength='8' bindinput='inputCarNum' type='text' placeholder-class='placeholder'></input>
-      </view>
+      </view> -->
       <view class='input_view'>
         <image class='password_img' src='/images/password.png'></image><div class="line"></div>
         <input placeholder='请设置密码' maxlength='16' bindinput='inputPassword' type='password' placeholder-class='placeholder'></input>
@@ -41,6 +48,10 @@
     <button class='{{checkPass?"login_button":"login_button_disable"}}' bindtap="{{checkPass?'getUserProfile':''}}">
       注册
     </button>
+    
+    <view class='phone_call_class' bindtap="phoneCall">
+          <span>联系客服:  {{servicetel}}</span>
+  </view>
     <!-- <view style="width: 100%;margin-top:50rpx">
       <ad unit-id="adunit-8eb13875bcf592b0" ad-intervals="30"></ad>
     </view> -->

+ 41 - 0
pages/register/register.wxss

@@ -29,6 +29,7 @@
   position: absolute;
   top: 0;
   left: 0;
+  margin-top:20rpx;
   box-shadow: 0rpx 6rpx 6rpx  #f5f5f5 inset;
 }
 
@@ -110,6 +111,7 @@
   border-radius: 10rpx;
   margin: 15rpx 0rpx;
   height: 88rpx;
+  position: relative;
 }
 .errorMsg{
   height: 28rpx;
@@ -166,6 +168,45 @@
   border: none;
   margin: 20rpx 135rpx 0 135rpx;
 }
+
+.vcode_button {
+  font-size: 32rpx;
+  font-family: 'Lucida Sans','Lucida Sans Regular','Lucida Grande','Lucida Sans Unicode',Geneva,Verdana,sans-serif;
+  position: absolute;
+  display: inline-block;
+  font-size: 30rpx;
+  right: 20rpx;
+  margin: 20rpx 10rpx;
+  border: none;
+  border-radius: 10rpx;
+  background: rgb(0, 170, 221);
+  z-index: 9999;
+  color: #FFF;
+  padding: 10rpx 10rpx;
+}
+.vcode_button_disable{
+  font-size: 32rpx;
+  font-family: 'Lucida Sans','Lucida Sans Regular','Lucida Grande','Lucida Sans Unicode',Geneva,Verdana,sans-serif;
+  position: absolute;
+  display: inline-block;
+  font-size: 26rpx;
+  right: 0rpx;
+  margin: 20rpx 10rpx;
+  border: none;
+  border-radius: 5rpx;
+  background: #c9c9c9;
+  color: #FFF;
+  z-index: 9999;
+  padding: 10rpx 10rpx;
+}
+
 .login_button.button-hover {
   background-color: #36a9a6;
 }
+
+.phone_call_class{
+  text-align: center;
+  margin: 40rpx;
+  color: #c9c9c9;
+  font-size: 28rpx;
+}

+ 2 - 2
pages/ucenter/chargemoneylog/chargemoneylog.js

@@ -8,7 +8,7 @@ Page({
     chargemoneylogs: [],
     userInfo: {},
     isLogin: false,
-    pagesize:10,
+    pagesize:15,
     pagenum:1,
     total:-1,
     loadTotal: 0,
@@ -65,7 +65,7 @@ Page({
       data: {
         userId:  wx.getStorageSync('userInfo').userId,
         pagenum: this.data.pagenum++,
-        pagesize: 10,
+        pagesize: 15,
       },
       method: 'POST',
       success(res) {