From 17e8a86bc7797bfc3b67987402d97f29f5a5f085 Mon Sep 17 00:00:00 2001 From: Junling Bu Date: Sat, 12 May 2018 00:21:59 +0800 Subject: [PATCH] =?UTF-8?q?update[litemall-wx]:=20=E6=89=8B=E6=9C=BA?= =?UTF-8?q?=E5=8F=B7=E6=94=AF=E6=8C=81=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- litemall-wx/pages/auth/register/register.js | 19 ++++++++++++++++++- litemall-wx/pages/auth/reset/reset.js | 11 +++++++++++ litemall-wx/utils/check.js | 12 ++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 litemall-wx/utils/check.js diff --git a/litemall-wx/pages/auth/register/register.js b/litemall-wx/pages/auth/register/register.js index 3c5c810a..cb0681ab 100644 --- a/litemall-wx/pages/auth/register/register.js +++ b/litemall-wx/pages/auth/register/register.js @@ -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 + }); } } }); diff --git a/litemall-wx/pages/auth/reset/reset.js b/litemall-wx/pages/auth/reset/reset.js index 57401bcf..0c3a6904 100644 --- a/litemall-wx/pages/auth/reset/reset.js +++ b/litemall-wx/pages/auth/reset/reset.js @@ -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: '错误信息', diff --git a/litemall-wx/utils/check.js b/litemall-wx/utils/check.js new file mode 100644 index 00000000..ade1a685 --- /dev/null +++ b/litemall-wx/utils/check.js @@ -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 +} \ No newline at end of file