...
|
...
|
@@ -11,12 +11,19 @@ let CACHE_AREA_LIST = {}; |
|
|
const yas = new Yas();
|
|
|
|
|
|
const validateAddress = function(data) {
|
|
|
let regx = {
|
|
|
const errorTip = {
|
|
|
consignee: '请输入正确的收件人姓名',
|
|
|
area_code: '请选择省市区',
|
|
|
mobile: '请输入正确的手机号',
|
|
|
address: '请输入详细的收件地址'
|
|
|
};
|
|
|
const regx = {
|
|
|
consignee: /^([\u4e00-\u9fa5\w*]{1,20})$/,
|
|
|
area_code: /^[0-9]{6,9}$/,
|
|
|
mobile: /^\d{3}(\d{4}|\*{4})\d{4,11}$/
|
|
|
},
|
|
|
pass = true;
|
|
|
};
|
|
|
let pass = true;
|
|
|
let errorType;
|
|
|
|
|
|
data = data || {};
|
|
|
|
...
|
...
|
@@ -25,11 +32,21 @@ const validateAddress = function(data) { |
|
|
regx[i] &&
|
|
|
!regx[i].test(data[i])) {
|
|
|
pass = false;
|
|
|
!errorType && (errorType = i);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (data.hasOwnProperty('address') && !data.address) {
|
|
|
pass = false;
|
|
|
!errorType && (errorType = 'address');
|
|
|
}
|
|
|
|
|
|
if (!pass) {
|
|
|
wx.showToast({
|
|
|
title: errorTip[errorType] || '请输入正确的信息',
|
|
|
icon: 'none',
|
|
|
duration: 2000
|
|
|
});
|
|
|
}
|
|
|
|
|
|
return pass;
|
...
|
...
|
@@ -80,7 +97,12 @@ Page({ |
|
|
loadAddrList() {
|
|
|
addressModel.addressList().then(res => {
|
|
|
if (res.code === 200) {
|
|
|
this.setData({addressList: res.data});
|
|
|
let list = res.data;
|
|
|
|
|
|
this.setData({
|
|
|
addressEmpty: !list || !list.length,
|
|
|
addressList: list
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
},
|
...
|
...
|
@@ -272,8 +294,8 @@ Page({ |
|
|
is_default: address.is_default
|
|
|
}).then(result => {
|
|
|
if (!result || result.code !== 200) {
|
|
|
wx.showModal({
|
|
|
content: '保存失败,请稍后重试',
|
|
|
return wx.showModal({
|
|
|
content: result.message || '保存失败,请稍后重试',
|
|
|
confirmText: '好的',
|
|
|
showCancel: false
|
|
|
});
|
...
|
...
|
|