...
|
...
|
@@ -8,6 +8,16 @@ const $ = require('yoho-jquery'), |
|
|
security = require('plugin/security'),
|
|
|
loading = require('plugin/loading');
|
|
|
|
|
|
let orderInfo;
|
|
|
|
|
|
if (window.queryString.refer === 'shopping') {
|
|
|
orderInfo = require('../cart/order-info').orderInfo;
|
|
|
}
|
|
|
|
|
|
if (window.queryString.refer === 'buynow') {
|
|
|
orderInfo = require('../cart/buynow/order-info').orderInfo;
|
|
|
}
|
|
|
|
|
|
const stringHandle = require('common/helpers/stringHandle');
|
|
|
|
|
|
let $addressForm = $('.edit-address'),
|
...
|
...
|
@@ -68,10 +78,25 @@ $usernameInput.bind('input propertychange', function() { |
|
|
}
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* 添加/编辑保存并设为默认地址
|
|
|
*/
|
|
|
const setDefault = (addressData) => {
|
|
|
let address = {
|
|
|
address_id: addressData.address_id,
|
|
|
consignee: addressData.consignee,
|
|
|
mobile: addressData.mobile,
|
|
|
address_info: `${addressData.area} ${addressData.address}`,
|
|
|
is_support: addressData.is_support
|
|
|
};
|
|
|
|
|
|
orderInfo('address_id', addressData.address_id);
|
|
|
orderInfo('address', address);
|
|
|
};
|
|
|
|
|
|
// 提交表单请求
|
|
|
$addressForm.on('submit', function() {
|
|
|
let username = $usernameInput.val().replace(/(^\s+)|(\s+$)/g, '');
|
|
|
let phone = $(this).find('[name="mobile"]').val();
|
|
|
|
|
|
if (isSubmiting) {
|
|
|
return false;
|
...
|
...
|
@@ -97,11 +122,6 @@ $addressForm.on('submit', function() { |
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if (!(/^[0-9]{11}$/.test(phone))) {
|
|
|
tip.show('请填写正确的手机号');
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if (!$(this).find('[name="area_code"]').val() || !$(this).find('[name="area"]').val() ||
|
|
|
$(this).find('[name="area_code"]').val().length < 6) {
|
|
|
tip.show('省市区不能为空');
|
...
|
...
|
@@ -130,11 +150,15 @@ $addressForm.on('submit', function() { |
|
|
loading.hideLoadingMask();
|
|
|
} else if (window.queryString) {
|
|
|
if (window.queryString.refer === 'buynow') {
|
|
|
window.location.href = '/cart/index/buynow/selectAddress?product_sku=' +
|
|
|
setDefault(res.data);
|
|
|
|
|
|
window.location.href = '/cart/index/buynow/orderensure?product_sku=' +
|
|
|
window.queryString.product_sku + '&buy_number=' +
|
|
|
window.queryString.buy_number;
|
|
|
} else if (window.queryString.refer === 'shopping') {
|
|
|
window.location.href = '/cart/index/new/selectAddress';
|
|
|
setDefault(res.data);
|
|
|
|
|
|
window.location.href = '/cart/index/new/orderEnsure?cartType=ordinary';
|
|
|
} else if (window.queryString.refer === 'modify') {
|
|
|
window.location.href = '/home/addressModify';
|
|
|
} else {
|
...
|
...
|
|