Authored by hongweigao

地址新增修改

... ... @@ -67,6 +67,9 @@
},
{
key: 'areaCode'
},
{
key: 'streets'
}
]
}, {
... ... @@ -143,7 +146,7 @@
let query = {
uid: uid,
address: _.trim(params.address || ''),
area_code: _.trim(params.areaCode || ''),
area_code: _.trim(params.streets || ''),
consignee: _.trim(params.addressName || ''),
email: _.trim(params.email || ''),
id: params.addrId === '0' ? null : params.addrId,
... ... @@ -152,8 +155,11 @@
zip_code: _.trim(params.zipCode || '')
};
let streets = _.trim(params.streets || '');
query.area_code = streets === 'all' ? _.trim(params.areaCode || '') : streets;
if (query.uid === '' || query.address === '' ||
query.area_code === '' || query.consignee === '' ||
query.area_code.length < 6 || query.consignee === '' ||
query.email === '' || query.zip_code === '') {
return {
... ...
... ... @@ -17,9 +17,9 @@ module.exports = {
cookieDomain: '.yohobuy.com',
domains: {
// test3
// singleApi: 'http://api-test3.yohops.com:9999/',
// api: 'http://api-test3.yohops.com:9999/',
// service: 'http://service-test3.yohops.com:9999/',
singleApi: 'http://api-test3.yohops.com:9999/',
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
// prod
// singleApi: 'http://single.yoho.cn/',
... ... @@ -27,9 +27,9 @@ module.exports = {
// service: 'http://service.yoho.cn/',
// gray
singleApi: 'http://single.gray.yohops.com/',
api: 'http://api.gray.yohops.com/',
service: 'http://service.gray.yohops.com/',
// singleApi: 'http://single.gray.yohops.com/',
// api: 'http://api.gray.yohops.com/',
// service: 'http://service.gray.yohops.com/',
// dev
// api: 'http://dev-api.yohops.com:9999/',
... ...
... ... @@ -36,6 +36,7 @@ var address = {
$('#province').val(0);
$('#city').val(0);
$('#areaCode').val(0).hide();
$('#streets').val(0).hide();
$('#btn-reset').hide();
$('#form-status').html('添加新地址');
},
... ... @@ -221,13 +222,9 @@ function blurAction(opt) {
}
if (opt.inputName === 'mobile') {
regular = /^1[3|4|5|8|7][0-9]{9}$/;
regular = /^[0-9]*$/;
if (opt.len !== 11) {
msg = '手机号码必须是11位的,请确认';
res = false;
domClass = 'form-info form-error';
} else if (regular.test(opt.val) === false) {
if (regular.test(opt.val) === false) {
msg = '您输入的手机号格式不正确';
res = false;
domClass = 'form-info form-error';
... ... @@ -353,8 +350,10 @@ $(document).ready(function() {
{
provinceDomId: 'province',
cityDomId: 'city',
areaDomId: 'areaCode'
}
areaDomId: 'areaCode',
streetsDomId: 'streets'
},
true
);
address.clearAddrForm();
... ...
... ... @@ -19,6 +19,9 @@ var address = {
// 地区的控件ID
areaDomId: 'areaCode',
// 乡镇、街道的控件ID
streetsDomId: 'streetsCode',
initDomIds: function(domOptions) {
var the = this;
... ... @@ -31,10 +34,13 @@ var address = {
if (domOptions.areaDomId !== undefined) {
the.areaDomId = domOptions.areaDomId;
}
if (domOptions.streetsDomId !== undefined) {
the.streetsDomId = domOptions.streetsDomId;
}
},
// 初始化地址数据
loadAreaData: function(pCode, toDomId, defaultValue, allCode) {
loadAreaData: function(pCode, toDomId, defaultValue, allCode, isAll) {
var the = this,
$toDom = $('#' + toDomId),
i = 0,
... ... @@ -43,7 +49,8 @@ var address = {
var active,
val,
nId,
selecter;
selecter,
selectAll;
$toDom.empty();
... ... @@ -67,10 +74,15 @@ var address = {
}
$toDom.append('<option value="0">' + defaultValue + '</option>');
if (toDomId === the.streetsDomId) {
allCode.length === 6 && isAll ? selectAll = 'selected' : selectAll = '';
$toDom.append('<option value="all"' + selectAll +'>*全部</option>');
}
for (i in jsonData.options) {
if (jsonData.options[i]) {
val = jsonData.options[i];
point = (toDomId === the.areaDomId && val.is_support === 'Y') ? '*' : '';
point = (toDomId === the.streetsDomId && val.is_support === 'Y') ? '*' : '';
nId = val.value;
selecter = '';
... ... @@ -117,6 +129,14 @@ var address = {
});
$('#' + the.areaDomId).change(function() {
var pCode = $('#' + the.areaDomId).val();
if (pCode === '0') {
return;
}
the.loadAreaData(pCode, the.streetsDomId, '请选择乡镇/街道', pCode);
$('#' + the.streetsDomId).show();
the.showAreaSel(domOptions.dispDomId);
});
... ... @@ -149,12 +169,12 @@ var address = {
}
},
loadAllData: function(areaCode, domOptions) {
var the = this;
loadAllData: function(areaCode, domOptions, isInit) {
var the = this,
isAll = isInit ? false : true;
the.initDomIds(domOptions);
areaCode += '';
if (areaCode < 91) {
the.loadAreaData(0, the.provinceDomId, '请选择省份', '');
$('#' + the.areaDomId).hide();
... ... @@ -168,9 +188,21 @@ var address = {
the.loadAreaData(0, the.provinceDomId, '请选择省份', areaCode);
the.loadAreaData(areaCode.substr(0, 2), the.cityDomId, '请选择城市', areaCode);
the.loadAreaData(areaCode.substr(0, 4), the.areaDomId, '请选择区县', areaCode);
the.loadAreaData(areaCode.substr(0, 6), the.streetsDomId, '请选择乡镇/街道', areaCode, isAll);
$('#' + this.areaDomId).show();
$('#' + this.streetsDomId).show();
} else if (areaCode.length === 9) {
the.loadAreaData(0, the.provinceDomId, '请选择省份', areaCode);
the.loadAreaData(areaCode.substr(0, 2), the.cityDomId, '请选择城市', areaCode);
the.loadAreaData(areaCode.substr(0, 4), the.areaDomId, '请选择区县', areaCode);
the.loadAreaData(areaCode.substr(0, 6), the.streetsDomId, '请选择乡镇/街道', areaCode);
$('#' + this.areaDomId).show();
$('#' + this.streetsDomId).show();
}
if (isInit) {
the.bindAreaChange(domOptions);
}
the.bindAreaChange(domOptions);
}
};
... ...
... ... @@ -635,7 +635,12 @@
}
.form-group {
width: 130%;
width: 100%;
}
.form-group {
height: auto;
padding: 4px 0;
}
.add-address-detail {
... ...