update[litemall-wx]: 手机号支持验证

This commit is contained in:
Junling Bu
2018-05-12 00:21:59 +08:00
parent 16f2f75808
commit 17e8a86bc7
3 changed files with 41 additions and 1 deletions

View File

@@ -1,4 +1,6 @@
var api = require('../../../config/api.js');
var check = require('../../../utils/check.js');
var app = getApp();
Page({
data: {
@@ -65,6 +67,15 @@ Page({
return false;
}
if (!check.isValidPhone(this.data.mobile)) {
wx.showModal({
title: '错误信息',
content: '手机号输入不正确',
showCancel: false
});
return false;
}
wx.request({
url: api.AuthRegister,
data: {
@@ -90,7 +101,13 @@ Page({
});
}
});
}
else{
wx.showModal({
title: '错误信息',
content: res.data.errmsg,
showCancel: false
});
}
}
});

View File

@@ -1,4 +1,6 @@
var api = require('../../../config/api.js');
var check = require('../../../utils/check.js');
var app = getApp();
Page({
data: {
@@ -46,6 +48,15 @@ Page({
return false;
}
if (!check.isValidPhone(this.data.mobile)) {
wx.showModal({
title: '错误信息',
content: '手机号输入不正确',
showCancel: false
});
return false;
}
if (this.data.password.length < 3) {
wx.showModal({
title: '错误信息',

View File

@@ -0,0 +1,12 @@
function isValidPhone(str) {
var myreg = /^[1][3,4,5,7,8][0-9]{9}$/;
if (!myreg.test(str)) {
return false;
} else {
return true;
}
}
module.exports = {
isValidPhone
}