|
@@ -28,7 +28,7 @@ var html = $tpl.html(); |
|
@@ -28,7 +28,7 @@ var html = $tpl.html(); |
28
|
var active;
|
28
|
var active;
|
29
|
var dialogMessage = '<p class="message-title"><i class="order-icon {{messageIcon}}"></i>{{messageTitle}}</p><p class="message-summary">{{messageSummary}}</p>';
|
29
|
var dialogMessage = '<p class="message-title"><i class="order-icon {{messageIcon}}"></i>{{messageTitle}}</p><p class="message-summary">{{messageSummary}}</p>';
|
30
|
var $dialogEdit = $('#edit-dialog-tpl');
|
30
|
var $dialogEdit = $('#edit-dialog-tpl');
|
31
|
-var $addressManage, $province, $city, $county, $selectList, $name, $phone, $address, $telCode, $tel, isProvinceChecked = false;
|
31
|
+var $addressManage, $province, $city, $county, $street, $selectList, $name, $phone, $address, $telCode, $tel, isProvinceChecked = false;
|
32
|
|
32
|
|
33
|
function cancelFactory(id) {
|
33
|
function cancelFactory(id) {
|
34
|
var options = {
|
34
|
var options = {
|
|
@@ -260,6 +260,7 @@ function newAddress(id) { |
|
@@ -260,6 +260,7 @@ function newAddress(id) { |
260
|
$province = $addressManage.find('select[name="province"]');
|
260
|
$province = $addressManage.find('select[name="province"]');
|
261
|
$city = $addressManage.find('select[name="city"]');
|
261
|
$city = $addressManage.find('select[name="city"]');
|
262
|
$county = $addressManage.find('select[name="county"]');
|
262
|
$county = $addressManage.find('select[name="county"]');
|
|
|
263
|
+ $street = $addressManage.find('select[name="street"]');
|
263
|
$selectList = $addressManage.find('select[name="province"],select[name="city"]');
|
264
|
$selectList = $addressManage.find('select[name="province"],select[name="city"]');
|
264
|
$name = $addressManage.find('.inp[name="name"]');
|
265
|
$name = $addressManage.find('.inp[name="name"]');
|
265
|
$phone = $addressManage.find('.inp[name="phone"]');
|
266
|
$phone = $addressManage.find('.inp[name="phone"]');
|
|
@@ -298,26 +299,35 @@ function newAddress(id) { |
|
@@ -298,26 +299,35 @@ function newAddress(id) { |
298
|
getAddress({
|
299
|
getAddress({
|
299
|
id: cityId,
|
300
|
id: cityId,
|
300
|
type: 'getCounty',
|
301
|
type: 'getCounty',
|
|
|
302
|
+ selectId: '' + codeId[0] + codeId[1] + codeId[2]
|
|
|
303
|
+ }, function() {
|
|
|
304
|
+ var countyId = $county.val();
|
|
|
305
|
+
|
|
|
306
|
+ //如果获取的县有默认选中项则获取乡镇/街道
|
|
|
307
|
+ if (countyId !== '0') {
|
|
|
308
|
+ getAddress({
|
|
|
309
|
+ id: countyId,
|
|
|
310
|
+ type: 'getStreet',
|
301
|
selectId: code
|
311
|
selectId: code
|
302
|
});
|
312
|
});
|
303
|
}
|
313
|
}
|
304
|
});
|
314
|
});
|
|
|
315
|
+ }
|
|
|
316
|
+ });
|
305
|
} else {
|
317
|
} else {
|
306
|
$addressManage.find('select[name="city"]').html('<option value="0">请选择城市</option>');
|
318
|
$addressManage.find('select[name="city"]').html('<option value="0">请选择城市</option>');
|
307
|
$addressManage.find('select[name="county"]').html('<option value="0">请选择区县</option>');
|
319
|
$addressManage.find('select[name="county"]').html('<option value="0">请选择区县</option>');
|
|
|
320
|
+ $street.html('<option value="0">请选择乡镇/街道</option>');
|
308
|
}
|
321
|
}
|
309
|
});
|
322
|
});
|
310
|
|
323
|
|
311
|
// 发生change事件时获取下一级地址
|
324
|
// 发生change事件时获取下一级地址
|
312
|
$selectList.change(function() {
|
325
|
$selectList.change(function() {
|
313
|
-
|
|
|
314
|
var $this = $(this);
|
326
|
var $this = $(this);
|
315
|
|
327
|
|
316
|
if ($this.attr('name') === 'province') {
|
328
|
if ($this.attr('name') === 'province') {
|
317
|
-
|
|
|
318
|
if ($this.val() === '0') {
|
329
|
if ($this.val() === '0') {
|
319
|
$addressManage.find('select[name="city"]').html('<option value="0">请选择城市</option>');
|
330
|
$addressManage.find('select[name="city"]').html('<option value="0">请选择城市</option>');
|
320
|
- $addressManage.find('select[name="county"]').html('<option value="0">请选择区县</option>');
|
|
|
321
|
} else {
|
331
|
} else {
|
322
|
getAddress({
|
332
|
getAddress({
|
323
|
id: $this.val(),
|
333
|
id: $this.val(),
|
|
@@ -325,12 +335,12 @@ function newAddress(id) { |
|
@@ -325,12 +335,12 @@ function newAddress(id) { |
325
|
}, function() {
|
335
|
}, function() {
|
326
|
isProvinceChecked = true;
|
336
|
isProvinceChecked = true;
|
327
|
});
|
337
|
});
|
328
|
- $addressManage.find('select[name="county"]').html('<option value="0">请选择区县</option>');
|
|
|
329
|
}
|
338
|
}
|
|
|
339
|
+ $addressManage.find('select[name="county"]').html('<option value="0">请选择区县</option>');
|
|
|
340
|
+ $street.html('<option value="0">请选择乡镇/街道</option>');
|
330
|
}
|
341
|
}
|
331
|
|
342
|
|
332
|
if ($this.attr('name') === 'city' && isProvinceChecked) {
|
343
|
if ($this.attr('name') === 'city' && isProvinceChecked) {
|
333
|
-
|
|
|
334
|
if ($this.val() === '0') {
|
344
|
if ($this.val() === '0') {
|
335
|
$addressManage.find('select[name="county"]').html('<option value="0">请选择区县</option>');
|
345
|
$addressManage.find('select[name="county"]').html('<option value="0">请选择区县</option>');
|
336
|
} else {
|
346
|
} else {
|
|
@@ -339,8 +349,21 @@ function newAddress(id) { |
|
@@ -339,8 +349,21 @@ function newAddress(id) { |
339
|
type: 'getCounty'
|
349
|
type: 'getCounty'
|
340
|
});
|
350
|
});
|
341
|
}
|
351
|
}
|
|
|
352
|
+ $street.html('<option value="0">请选择乡镇/街道</option>');
|
|
|
353
|
+ }
|
|
|
354
|
+
|
|
|
355
|
+ if ($this.attr('name') === 'county' && isProvinceChecked) {
|
|
|
356
|
+ if ($this.val() === '0') {
|
|
|
357
|
+ $street.html('<option value="0">请选择乡镇/街道</option>');
|
|
|
358
|
+ } else {
|
|
|
359
|
+ getAddress({
|
|
|
360
|
+ id: $this.val(),
|
|
|
361
|
+ type: 'getStreet'
|
|
|
362
|
+ });
|
|
|
363
|
+ }
|
342
|
}
|
364
|
}
|
343
|
});
|
365
|
});
|
|
|
366
|
+
|
344
|
$name.on('blur', function() {
|
367
|
$name.on('blur', function() {
|
345
|
validate.name($.trim($name.val()));
|
368
|
validate.name($.trim($name.val()));
|
346
|
});
|
369
|
});
|
|
@@ -352,9 +375,9 @@ function newAddress(id) { |
|
@@ -352,9 +375,9 @@ function newAddress(id) { |
352
|
});
|
375
|
});
|
353
|
$tel.on('blur', function() {
|
376
|
$tel.on('blur', function() {
|
354
|
validate.tel($.trim($telCode.val()), $.trim($tel.val()));
|
377
|
validate.tel($.trim($telCode.val()), $.trim($tel.val()));
|
355
|
- })
|
|
|
356
|
- $county.on('change', function() {
|
|
|
357
|
- validate.city($province.val(), $city.val(),$county.val());
|
378
|
+ });
|
|
|
379
|
+ $street.on('change', function() {
|
|
|
380
|
+ validate.city($province.val(), $city.val(), $county.val(), $(this).val());
|
358
|
})
|
381
|
})
|
359
|
}
|
382
|
}
|
360
|
/**
|
383
|
/**
|
|
@@ -380,6 +403,8 @@ function getAddress(d, callback) { |
|
@@ -380,6 +403,8 @@ function getAddress(d, callback) { |
380
|
|
403
|
|
381
|
//url = 'getCounty';
|
404
|
//url = 'getCounty';
|
382
|
$obj = $county;
|
405
|
$obj = $county;
|
|
|
406
|
+ } else if (d.type === 'getStreet') {
|
|
|
407
|
+ $obj = $street;
|
383
|
}
|
408
|
}
|
384
|
|
409
|
|
385
|
$.ajax({
|
410
|
$.ajax({
|
|
@@ -402,11 +427,11 @@ function getAddress(d, callback) { |
|
@@ -402,11 +427,11 @@ function getAddress(d, callback) { |
402
|
|
427
|
|
403
|
// 构建select下拉选项
|
428
|
// 构建select下拉选项
|
404
|
function structureOption($obj, data, selectId) {
|
429
|
function structureOption($obj, data, selectId) {
|
405
|
-
|
|
|
406
|
var i,
|
430
|
var i,
|
407
|
optionHtml = '',
|
431
|
optionHtml = '',
|
408
|
defaultOption,
|
432
|
defaultOption,
|
409
|
isStar = '';
|
433
|
isStar = '';
|
|
|
434
|
+ var countyId;
|
410
|
|
435
|
|
411
|
for (i = 0; i < data.length; i++) {
|
436
|
for (i = 0; i < data.length; i++) {
|
412
|
|
437
|
|
|
@@ -431,6 +456,15 @@ function structureOption($obj, data, selectId) { |
|
@@ -431,6 +456,15 @@ function structureOption($obj, data, selectId) { |
431
|
|
456
|
|
432
|
} else if ($obj.attr('name') === 'county') {
|
457
|
} else if ($obj.attr('name') === 'county') {
|
433
|
defaultOption = '<option value="0">请选择区县</option>';
|
458
|
defaultOption = '<option value="0">请选择区县</option>';
|
|
|
459
|
+ } else if ($obj.attr('name') === 'street') {
|
|
|
460
|
+ selectId += '';
|
|
|
461
|
+ countyId = selectId.substr(0, 6);
|
|
|
462
|
+
|
|
|
463
|
+ defaultOption = '<option value="0">请选择乡镇/街道</option>';
|
|
|
464
|
+
|
|
|
465
|
+ if (countyId) {
|
|
|
466
|
+ defaultOption += '<option value="' + countyId + '">全部</option>';
|
|
|
467
|
+ }
|
434
|
}
|
468
|
}
|
435
|
|
469
|
|
436
|
$obj.html(defaultOption + optionHtml);
|
470
|
$obj.html(defaultOption + optionHtml);
|
|
@@ -442,6 +476,7 @@ function saveAddress(id) { |
|
@@ -442,6 +476,7 @@ function saveAddress(id) { |
442
|
province = $province.val(),
|
476
|
province = $province.val(),
|
443
|
city = $city.val(),
|
477
|
city = $city.val(),
|
444
|
county = $county.val(),
|
478
|
county = $county.val(),
|
|
|
479
|
+ street = $street.val(),
|
445
|
address = $address.val(),
|
480
|
address = $address.val(),
|
446
|
phone = $phone.val(),
|
481
|
phone = $phone.val(),
|
447
|
telCode = $telCode.val(),
|
482
|
telCode = $telCode.val(),
|
|
@@ -456,14 +491,14 @@ function saveAddress(id) { |
|
@@ -456,14 +491,14 @@ function saveAddress(id) { |
456
|
var postData = {
|
491
|
var postData = {
|
457
|
orderCode: id,
|
492
|
orderCode: id,
|
458
|
userName: name,
|
493
|
userName: name,
|
459
|
- areaCode: county,
|
494
|
+ areaCode: street,
|
460
|
address: address,
|
495
|
address: address,
|
461
|
mobile: phone,
|
496
|
mobile: phone,
|
462
|
phoneCode: telCode,
|
497
|
phoneCode: telCode,
|
463
|
phoneNum: tel
|
498
|
phoneNum: tel
|
464
|
};
|
499
|
};
|
465
|
var validate = validateForm();
|
500
|
var validate = validateForm();
|
466
|
- if (!validate.name(name) || !validate.city(province, city, county) || !validate.address(address) || !validate.mobile(phone) || !validate.tel(telCode, tel)) {
|
501
|
+ if (!validate.name(name) || !validate.city(province, city, county, street) || !validate.address(address) || !validate.mobile(phone) || !validate.tel(telCode, tel)) {
|
467
|
return;
|
502
|
return;
|
468
|
}
|
503
|
}
|
469
|
|
504
|
|
|
@@ -510,8 +545,8 @@ function validateForm() { |
|
@@ -510,8 +545,8 @@ function validateForm() { |
510
|
return true;
|
545
|
return true;
|
511
|
}
|
546
|
}
|
512
|
},
|
547
|
},
|
513
|
- city: function(province, city, county) {
|
|
|
514
|
- if (province === '0' || city === '0' || county === '0') {
|
548
|
+ city: function(province, city, county, street) {
|
|
|
549
|
+ if (province === '0' || city === '0' || county === '0' || street === '0') {
|
515
|
$err_province.html(_error_html);
|
550
|
$err_province.html(_error_html);
|
516
|
$err_province.find('b').html('请填写完整的省市区信息');
|
551
|
$err_province.find('b').html('请填写完整的省市区信息');
|
517
|
$err_province.show();
|
552
|
$err_province.show();
|