// 地址表单初始化
FromInit('form.form-validation-address');
// 备案表单初始化
FromInit('form.form-validation-filing');
/**
* 地址返回处理
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-11-12
* @desc description
* @param {[object]} data [地址信息]
*/
function AddressModalHandle (data) {
// 参数处理
var logo = data.logo || null;
var alias = data.alias || null;
var name = data.name || null;
var tel = data.tel || null;
var province = data.province || null;
var city = data.city || null;
var county = data.county || null;
var address = data.address || null;
var province_city_county = data.province_city_county || null;
var lng = data.lng || null;
var lat = data.lat || null;
// 获取省市区的数组
var province_city_county_list = province_city_county.split(' ');
var province_city_county_obj = {
province_name: province_city_county_list.length > 0 ? province_city_county_list[0] : '',
city_name: province_city_county_list.length > 1 ? province_city_county_list[1] : '',
county_name: province_city_county_list.length > 2 ? province_city_county_list[2] : '',
}
data = Object.assign({}, data, province_city_county_obj);
if (name == null || tel == null || province == null || city == null || address == null) {
Prompt(window['lang_operate_params_error'] || '数据填写有误');
return false;
}
// 数据拼接
var html = '
';
html += '
';
if (logo != null) {
html += ' ';
}
html += '';
html += '' + province_city_county + ' ' + address + '(' + name + '-' + tel + ')';
if (alias != null) {
html += '' + alias + '';
}
html += '';
html += '
';
html += '
';
html += '编辑 ';
html += '移除';
html += '
';
html += '
';
// 数据处理
var value = SelfExtractionAddressValue();
// 弹层
var $popup_address = $('#popup-address-win');
// 操作类型(add, edit)
var form_type = $popup_address.attr('data-type') || 'add';
if (form_type == 'add') {
$('ul.address-list').append(html);
data['id'] = value.length;
value.push(data);
} else {
var form_index = $popup_address.attr('data-index') || 0;
data['id'] = form_index;
value.splice(form_index, 1, data);
$('ul.address-list').find('li').eq(form_index).replaceWith(html);
}
$popup_address.modal('close');
$('.self-extraction-address-value').val(encodeURIComponent(CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(JSON.stringify(value)))));
}
/**
* 获取自提地址
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-11-12
* @desc description
*/
function SelfExtractionAddressValue () {
var value = $('.self-extraction-address-value').val() || null;
return (value == null) ? [] : JSON.parse(CryptoJS.enc.Base64.parse(decodeURIComponent(value)).toString(CryptoJS.enc.Utf8));
}
/**
* 备案信息返回处理
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-11-12
* @desc description
* @param {[object]} data [地址信息]
*/
function FilingModalHandle (data) {
// 参数处理
var icon = data.icon || null;
var name = data.name || null;
var show_name = data.show_name || null;
var url = data.url || null;
if (name == null || show_name == null) {
Prompt(window['lang_operate_params_error'] || '数据填写有误');
return false;
}
// 数据拼接
var html = '
';
html += '
';
if (icon != null) {
html += ' ';
}
html += '';
html += '' + name + '(' + show_name + ')';
if (url != null) {
html += ' ' + url + '';
}
html += '';
html += '
');
}
$this.parent().html(icon_html);
});
// 添加域名
$(document).on('click', '.domain-submit-add', function () {
var please_select_tip = $(this).data('please-select-tips') || '请选择...';
var select_html = '';
var json = $(this).data('json') || null;
if (json != null) {
json = JSON.parse(CryptoJS.enc.Base64.parse(decodeURIComponent(json)).toString(CryptoJS.enc.Utf8));
for (var i in json) {
select_html += '';
}
}
var form_name = $(this).data('form-name');
var index = parseInt(Math.random() * 1000001);
var html = `