Commit 27995165 by 梁建民

js

parent 119f1180
...@@ -153,27 +153,52 @@ Page({ ...@@ -153,27 +153,52 @@ Page({
* 校验字段 * 校验字段
*/ */
bindinputFn: function (e) { bindinputFn: function (e) {
let value = e.detail.value
let reg_mobile = /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/;
let reg_pwd = /^[0-9A-Za-z]{6,}$/;
if (e.currentTarget.dataset.type == 1) { if (e.currentTarget.dataset.type == 1) {
this.setData({ if (value) {
'formData.mobile': e.detail.value
});
this.calcForm({ this.setData({
mobile: this.data.formData.mobile error: true,
}); errorText: '请填写正确的手机号',
mobileFlag: true
});
if (reg_mobile.test(value)) {
this.setData({
error: false,
errorText: '',
mobileFlag: false
});
}
}
} else { } else {
this.setData({ if (value) {
'formData.password': e.detail.value
});
this.calcForm({ this.setData({
mobile: this.data.formData.mobile, error: true,
password: this.data.formData.password errorText: '密码由字母和数字组成,且不能少于6位',
}); passwordFlag: true
});
if (reg_pwd.test(value)) {
this.setData({
error: false,
errorText: '',
passwordFlag: false
});
}
}
} }
}, },
......
...@@ -14,9 +14,11 @@ Page({ ...@@ -14,9 +14,11 @@ Page({
mobileFlag: false, mobileFlag: false,
codeFlag: false, codeFlag: false,
disabled: false, disabled: false,
disabledBtn:false, disabledBtn: false,
loading: false, loading: false,
currentTime: 61, currentTime: 61,
vcode:true,
vcodeFlag:true,
timeText: '发送验证码', timeText: '发送验证码',
formData: { formData: {
mobile: '', mobile: '',
...@@ -84,7 +86,8 @@ Page({ ...@@ -84,7 +86,8 @@ Page({
*/ */
getCode: function() { getCode: function() {
var self = this; let self = this;
var currentTime = this.data.currentTime; var currentTime = this.data.currentTime;
var interval = setInterval(function() { var interval = setInterval(function() {
...@@ -114,22 +117,88 @@ Page({ ...@@ -114,22 +117,88 @@ Page({
*/ */
getVerificationCode: function(e) { getVerificationCode: function(e) {
http.getData(apis.getRegistCode,{ let self = this;
mobile:'',
code_type:2 if (self.data.formData.mobile) {
},function(res){
if(res.err_code === 0){ http.getData(apis.getWxCode, {
mobile: self.data.formData.code,
code_type: 2
}, function(res) {
if (res.err_code === 0) {
self.getCode();
self.setData({
disabled: true
});
}else{
wx.showToast({
title: '发送失败',
icon: 'none',
duration: 2000
});
}
}, true);
} else {
this.setData({
error: true,
errorText: '手机号不能为空',
mobileFlag: true
});
}
},
/**
* 校验字段
*/
bindinputFn: function(e) {
let value = e.detail.value
let reg_mobile = /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/;
http.getData(); if (e.currentTarget.dataset.type == 1) {
this.setData({
'formData.mobile': value
});
if (value) {
this.setData({ this.setData({
disabled: true error: true,
errorText: '请填写正确的手机号',
mobileFlag: true
}); });
if (reg_mobile.test(value)) {
this.setData({
error: false,
errorText: '',
mobileFlag: false
});
}
}
} else {
if (value) {
this.setData({
error: false,
errorText: '',
codeFlag: false
});
} }
});
}
}, },
/** /**
* 校验字段 * 校验字段
...@@ -162,6 +231,18 @@ Page({ ...@@ -162,6 +231,18 @@ Page({
} }
if (!code) {
this.setData({
error: true,
errorText: '验证码不能为空',
codeFlag: true
});
return false;
}
this.setData({ this.setData({
error: false, error: false,
...@@ -196,9 +277,9 @@ Page({ ...@@ -196,9 +277,9 @@ Page({
data: res.data.access_token data: res.data.access_token
}); });
wx.switchTab({ // wx.switchTab({
url: '/pages/tab/home/home' // url: '/pages/tab/home/home'
}) // })
} else { } else {
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<view class="inp-wrap row verCenter {{mobileFlag ? 'inp-error':''}}"> <view class="inp-wrap row verCenter {{mobileFlag ? 'inp-error':''}}">
<text class="icon iconfont iconiconxiantiaoshouji21"></text> <text class="icon iconfont iconiconxiantiaoshouji21"></text>
<view class="form-item-right row verCenter bothSide"> <view class="form-item-right row verCenter bothSide">
<input placeholder="请输入手机号" placeholder-class="placeholderClass" name='mobile'></input> <input placeholder="请输入手机号" placeholder-class="placeholderClass" name='mobile' data-type="1" bindinput='bindinputFn'></input>
<view class="areacode" bindtap="switchPrice"> <view class="areacode" bindtap="switchPrice">
<text class="tel-value">中国 + 86</text> <text class="tel-value">中国 + 86</text>
<text class="icon iconfont iconbianzu1"></text> <text class="icon iconfont iconbianzu1"></text>
...@@ -18,10 +18,18 @@ ...@@ -18,10 +18,18 @@
</view> </view>
</view> </view>
<view class="inp-wrap row verCenter {{vcodeFlag ? 'inp-error':''}}" wx:if="{{vcode}}">
<text class="icon iconfont iconiconxiantiaoshouji"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入验证码" placeholder-class="placeholderClass" name='code' data-type="2" bindinput='bindinputFn'></input>
<button class="vcode {{disabled ? 'vcode-color':''}}" disabled="{{disabled}}" bindtap="getVerificationCode">{{timeText}}</button>
</view>
</view>
<view class="inp-wrap row verCenter {{codeFlag ? 'inp-error':''}}"> <view class="inp-wrap row verCenter {{codeFlag ? 'inp-error':''}}">
<text class="icon iconfont iconiconxiantiaoshouji"></text> <text class="icon iconfont iconiconxiantiaoshouji"></text>
<view class="form-item-right row verCenter bothSide"> <view class="form-item-right row verCenter bothSide">
<input placeholder="请输入验证码" placeholder-class="placeholderClass" name='code'></input> <input placeholder="请输入验证码" placeholder-class="placeholderClass" name='code' data-type="2" bindinput='bindinputFn'></input>
<button class="vcode {{disabled ? 'vcode-color':''}}" disabled="{{disabled}}" bindtap="getVerificationCode">{{timeText}}</button> <button class="vcode {{disabled ? 'vcode-color':''}}" disabled="{{disabled}}" bindtap="getVerificationCode">{{timeText}}</button>
</view> </view>
</view> </view>
......
...@@ -40,6 +40,10 @@ const apis = { ...@@ -40,6 +40,10 @@ const apis = {
*/ */
getRegistCode: auth_url + '/v1/getRegistCode', getRegistCode: auth_url + '/v1/getRegistCode',
/** /**
* 微信验证码
*/
getWxCode: auth_url + '/v1/getwxcode',
/**
* 退出 * 退出
*/ */
authLogout: auth_url + '/auth/logout', authLogout: auth_url + '/auth/logout',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment