...
|
...
|
@@ -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);
|
|
|
}
|
|
|
};
|
|
|
|
...
|
...
|
|