...
|
...
|
@@ -20,7 +20,8 @@ var active; |
|
|
|
|
|
var dialogMessage = '<p class="message-title"><i class="order-icon {{messageIcon}}"></i>{{messageTitle}}</p><p class="message-summary">{{messageSummary}}</p>';
|
|
|
var $dialogEdit = $('#edit-dialog-tpl');
|
|
|
var $addressManage, $province, $city, $county, $selectList, $name, $phone, $address, $telCode, $tel, isProvinceChecked = false;;
|
|
|
var $addressManage, $province, $city, $county, $selectList, $name, $phone, $address, $telCode, $tel, isProvinceChecked = false;
|
|
|
;
|
|
|
|
|
|
function cancelFactory(id) {
|
|
|
var options = {
|
...
|
...
|
@@ -175,6 +176,7 @@ $('.me-orders, .order-detail').on('click', '.cancel-order', function(e) { |
|
|
});
|
|
|
active.show();
|
|
|
}).on('click', '.edit-order', function() {
|
|
|
$(this).addClass('edit-order-active');
|
|
|
active = editOrder($(this).closest('.order, .order-detail').data('id'))
|
|
|
active.show();
|
|
|
newAddress(0);
|
...
|
...
|
@@ -199,6 +201,8 @@ function newAddress(id) { |
|
|
$telCode = $addressManage.find('.inp[name="tel-code"]');
|
|
|
$tel = $addressManage.find('.inp[name="tel"]');
|
|
|
|
|
|
var validate = validateForm();
|
|
|
|
|
|
code = $province.data("areacode") + '';
|
|
|
codeId = !!code && code.match(addressCodeReg);
|
|
|
|
...
|
...
|
@@ -271,6 +275,18 @@ function newAddress(id) { |
|
|
}
|
|
|
}
|
|
|
});
|
|
|
$name.on('blur', function() {
|
|
|
validate.name($name.val());
|
|
|
});
|
|
|
$address.on('blur', function() {
|
|
|
validate.address($address.val());
|
|
|
});
|
|
|
$phone.on('blur', function() {
|
|
|
validate.mobile($phone.val());
|
|
|
});
|
|
|
$tel.on('blur', function() {
|
|
|
validate.tel($telCode.val(), $tel.val());
|
|
|
})
|
|
|
}
|
|
|
/**
|
|
|
* @description: 改函数会返回地址信息
|
...
|
...
|
@@ -362,11 +378,11 @@ function saveAddress(id) { |
|
|
telCode = $telCode.val(),
|
|
|
tel = $tel.val();
|
|
|
|
|
|
var $err_name = $name.siblings('.error'),
|
|
|
$err_province = $province.siblings('.error'),
|
|
|
$err_address = $address.siblings('.error'),
|
|
|
$err_phone = $phone.siblings('.error'),
|
|
|
$err_tel = $tel.siblings('.error');
|
|
|
// var $err_name = $name.siblings('.error'),
|
|
|
// $err_province = $province.siblings('.error'),
|
|
|
// $err_address = $address.siblings('.error'),
|
|
|
// $err_phone = $phone.siblings('.error'),
|
|
|
// $err_tel = $tel.siblings('.error');
|
|
|
|
|
|
var postData = {
|
|
|
orderCode: id,
|
...
|
...
|
@@ -377,49 +393,9 @@ function saveAddress(id) { |
|
|
phoneCode: telCode,
|
|
|
phoneNum: tel
|
|
|
};
|
|
|
|
|
|
var nameReg = /^[\u4e00-\u9fa5]{2,5}$/;
|
|
|
var addressReg = /^[\s\S]{2,100}$/;
|
|
|
var phoneReg = /^(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
|
|
|
var telCodeReg = /^[0-9]{3,5}$/;
|
|
|
var telReg = /^[0-9]{5,10}$/;
|
|
|
|
|
|
if (!nameReg.test(name)) {
|
|
|
$err_name.find('b').html('真实姓名至少2个中文,最多5个中文');
|
|
|
$err_name.show();
|
|
|
return;
|
|
|
} else {
|
|
|
$err_name.hide();
|
|
|
}
|
|
|
if (province === '0' || city === '0' || county === '0') {
|
|
|
$err_province.show();
|
|
|
return;
|
|
|
} else {
|
|
|
$err_province.hide();
|
|
|
}
|
|
|
if (!addressReg.test(address)) {
|
|
|
$err_address.find('b').html('你输入的地址格式不正确');
|
|
|
$err_address.show();
|
|
|
return;
|
|
|
} else {
|
|
|
$err_address.hide();
|
|
|
}
|
|
|
if (!phoneReg.test(phone)) {
|
|
|
$err_phone.find('b').html('你输入的联系电话格式不正确');
|
|
|
$err_phone.show();
|
|
|
return;
|
|
|
} else {
|
|
|
$err_phone.hide();
|
|
|
}
|
|
|
|
|
|
if ((!!telCode && !telCodeReg.test(telCode)) || (!!tel && !telReg.test(tel)) ||
|
|
|
(telCodeReg.test(telCode) && !telReg.test(tel)) ||
|
|
|
(!telCodeReg.test(telCode) && telReg.test(tel))) {
|
|
|
$err_tel.find('b').html('你输入的电话格式不正确');
|
|
|
$err_tel.show();
|
|
|
var validate = validateForm();
|
|
|
if (!validate.name(name) || !validate.city(province, city, county) || !validate.address(address) || !validate.mobile(phone) || !validate.tel(telCode, tel)) {
|
|
|
return;
|
|
|
} else {
|
|
|
$err_tel.hide();
|
|
|
}
|
|
|
|
|
|
$.ajax({
|
...
|
...
|
@@ -438,3 +414,89 @@ function saveAddress(id) { |
|
|
}
|
|
|
})
|
|
|
}
|
|
|
function validateForm() {
|
|
|
var $err_name = $name.siblings('.error'),
|
|
|
$err_province = $province.siblings('.error'),
|
|
|
$err_address = $address.siblings('.error'),
|
|
|
$err_phone = $phone.siblings('.error'),
|
|
|
$err_tel = $tel.siblings('.error');
|
|
|
|
|
|
var nameReg = /^[\u4e00-\u9fa5]{2,5}$/;
|
|
|
var addressReg = /^[a-zA-Z0-9-#()\u4e00-\u9fa5]+$/;
|
|
|
var phoneReg = /^(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
|
|
|
var telCodeReg = /^[0-9]{3,5}$/;
|
|
|
var telReg = /^[0-9]{5,10}$/;
|
|
|
var _right_html = '<i class="order-icon icon-right"></i>';
|
|
|
var _error_html = '<i class="order-icon icon-error"></i><b></b>';
|
|
|
|
|
|
return {
|
|
|
name: function(name) {
|
|
|
if (!nameReg.test(name)) {
|
|
|
$err_name.html(_error_html);
|
|
|
$err_name.find('b').html('真实姓名至少2个中文,最多5个中文');
|
|
|
$err_name.show();
|
|
|
return false;
|
|
|
} else {
|
|
|
$err_name.html(_right_html).show();
|
|
|
return true;
|
|
|
}
|
|
|
},
|
|
|
city: function(province, city, county) {
|
|
|
if (province === '0' || city === '0' || county === '0') {
|
|
|
$err_province.html(_error_html);
|
|
|
$err_province.find('b').html('请填写完整的省市区信息');
|
|
|
$err_province.show();
|
|
|
return false;
|
|
|
} else {
|
|
|
$err_province.html(_right_html).show();
|
|
|
return true;
|
|
|
}
|
|
|
},
|
|
|
address: function(address) {
|
|
|
if (!addressReg.test(address)) {
|
|
|
var message = '详细地址不能为空';
|
|
|
if ($.trim(address) !== '') {
|
|
|
message = '只能包含数字、字母、汉字、#、-、()及其组合';
|
|
|
}
|
|
|
$err_address.html(_error_html);
|
|
|
$err_address.find('b').html(message);
|
|
|
$err_address.show();
|
|
|
return false;
|
|
|
} else {
|
|
|
$err_address.html(_right_html).show();
|
|
|
return true;
|
|
|
}
|
|
|
},
|
|
|
mobile: function(phone) {
|
|
|
if (!phoneReg.test(phone)) {
|
|
|
var message = '手机号码不能为空';
|
|
|
if ($.trim(phone) !== '') {
|
|
|
message = '你输入的联系电话格式不正确';
|
|
|
}
|
|
|
$err_phone.html(_error_html);
|
|
|
$err_phone.find('b').html(message);
|
|
|
$err_phone.show();
|
|
|
return false;
|
|
|
} else {
|
|
|
$err_phone.html(_right_html).show();
|
|
|
return true;
|
|
|
}
|
|
|
},
|
|
|
tel: function(telCode, tel) {
|
|
|
if(telCode === '' && tel === ''){
|
|
|
_right_html = '';
|
|
|
}
|
|
|
if ((!!telCode && !telCodeReg.test(telCode)) || (!!tel && !telReg.test(tel)) ||
|
|
|
(telCodeReg.test(telCode) && !telReg.test(tel)) ||
|
|
|
(!telCodeReg.test(telCode) && telReg.test(tel))) {
|
|
|
$err_tel.html(_error_html);
|
|
|
$err_tel.find('b').html('你输入的电话格式不正确');
|
|
|
$err_tel.show();
|
|
|
return false;
|
|
|
} else {
|
|
|
$err_tel.html(_right_html).show();
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|