51 lines
1.5 KiB
JavaScript
51 lines
1.5 KiB
JavaScript
var e = getApp();
|
|
|
|
Page({
|
|
data: {
|
|
disabled: !1,
|
|
nav_select: !1,
|
|
name: "",
|
|
region: "",
|
|
phone: "",
|
|
detail: "",
|
|
error: ""
|
|
},
|
|
onLoad: function(e) {},
|
|
saveData: function(a) {
|
|
var t = this, n = a.detail.value;
|
|
if (n.region = t.data.region, !t.validation(n)) return e.showError(t.data.error),
|
|
!1;
|
|
t.setData({
|
|
disabled: !0
|
|
}), e._post_form("address/add", n, function(a) {
|
|
e.showSuccess(a.msg, function() {
|
|
wx.navigateBack();
|
|
});
|
|
}, !1, function() {
|
|
t.setData({
|
|
disabled: !1
|
|
});
|
|
});
|
|
},
|
|
webvue1: function() {
|
|
console.log(111), wx.navigateTo({
|
|
url: "webvue?id=1"
|
|
});
|
|
},
|
|
webvue2: function() {
|
|
console.log(111), wx.navigateTo({
|
|
url: "webvue?id=2"
|
|
});
|
|
},
|
|
validation: function(e) {
|
|
if ("" === e.name) return this.data.error = "收件人不能为空", !1;
|
|
if (e.phone.length < 1) return this.data.error = "手机号不能为空", !1;
|
|
return /^((0\d{2,3}-\d{7,8})|(1[3456789]\d{9}))$/.test(e.phone) ? this.data.region ? "" !== e.detail || (this.data.error = "详细地址不能为空",
|
|
!1) : (this.data.error = "省市区不能空", !1) : (this.data.error = "手机号不符合要求", !1);
|
|
},
|
|
bindRegionChange: function(e) {
|
|
this.setData({
|
|
region: e.detail.value
|
|
});
|
|
}
|
|
}); |