From a71e4df4429d4931bf206a0e53ad25cb37de0b38 Mon Sep 17 00:00:00 2001
From: F5VT98DI7XY4X12\Administrator <765199919@qq.com>
Date: Wed, 4 Sep 2019 23:12:54 +0800
Subject: [PATCH] 我的地址 , 验证手机号
---
pages/user/add_address/add_address.js | 11 ++++++++++-
pages/user/add_address/add_address.json | 5 ++++-
pages/user/add_address/add_address.wxml | 4 +++-
utils/util.js | 17 +++++++++++++++++
4 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/pages/user/add_address/add_address.js b/pages/user/add_address/add_address.js
index adec7ca..3bb1f5f 100644
--- a/pages/user/add_address/add_address.js
+++ b/pages/user/add_address/add_address.js
@@ -50,9 +50,18 @@ Page({
var a= this.data.address, b=a,th=this;
Object.assign(a, s.detail.value), a.is_default = Number(a.is_default);
a.store_id = os.stoid;
+
+ var ob = ut.check_mobile(a.mobile);
+ if(ob.code!=1){
+ return getApp().my_warnning(ob.title,0,th);
+ }
+
if (a.more_address == null || a.more_address == undefined || a.more_address=="" ){
- wx.showModal({title: "请选择地区"}); return false;
+ getApp().my_warnning("请选择地区",0,th);
+ return false;
}
+
+
//判断是不是空对象
//--------如果是修改地址----------
if (!th.data.isnew){
diff --git a/pages/user/add_address/add_address.json b/pages/user/add_address/add_address.json
index 2d80317..5394760 100644
--- a/pages/user/add_address/add_address.json
+++ b/pages/user/add_address/add_address.json
@@ -1,4 +1,7 @@
{
"navigationBarTitleText": "收货地址",
- "enablePullDownRefresh": false
+ "enablePullDownRefresh": false,
+ "usingComponents": {
+ "warn": "/components/long_warn/long_warn"
+ }
}
\ No newline at end of file
diff --git a/pages/user/add_address/add_address.wxml b/pages/user/add_address/add_address.wxml
index 76bf6e9..970d4c1 100644
--- a/pages/user/add_address/add_address.wxml
+++ b/pages/user/add_address/add_address.wxml
@@ -7,7 +7,7 @@
手机号码:
-
+
所在地区:
@@ -31,3 +31,5 @@
+
+
diff --git a/utils/util.js b/utils/util.js
index 1d4929b..190adb8 100644
--- a/utils/util.js
+++ b/utils/util.js
@@ -230,6 +230,22 @@ function measureText(text, fontSize = 10) {
return width * fontSize / 10;
}
+//验证手机号
+function check_mobile(phoneMobile){
+ var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/;
+ var ob={code:1};
+ if (phoneMobile.length === 0) {
+ ob.title='输入的手机号为空';
+ ob.code=-1;
+ } else if (phoneMobile.length < 11) {
+ ob.title ='手机号长度有误!';
+ ob.code = -1;
+ } else if (!myreg.test(phoneMobile)) {
+ ob.title = '手机号格式有误!';
+ ob.code = -1;
+ }
+ return ob;
+}
module.exports = {
formatTime: function(e, r) {
@@ -319,4 +335,5 @@ module.exports = {
isArray: isArray,
sub_last: sub_last,//去掉末尾一个字符
measureText: measureText,//画布需要的函数
+ check_mobile: check_mobile,//验证手机
};
--
libgit2 0.21.4