building-sign/public/static/manager/js/common/address.js

44 lines
1.3 KiB
JavaScript
Executable File
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

let province = $('#input-province').val();
let city = $('#input-city').val();
let county = $('#input-county').val();
let _width = 200;
let _height = 34;
province = province ? province : '110000';
city = city ? city : '110100';
county = county ? county : '110101';
if ($('#target').length > 0) {
if ($('#target').data('width') != undefined) {
_width = $('#target').data('width');
}
if ($('#target').data('height') != undefined) {
_height = $('#target').data('height');
}
}
var picker =iPicker.create("#target", {
width: _width,
height: _height,
data: {
// 此处以通过 jquery 库获取本地数据源为例
source: Promise.resolve($.getJSON("/static/js/iPicker/area.json"))
},
onSelect: (code, name, all) => {
// 返回参数均为数组形式
// console.log( code );
// console.log( name );
// console.log( all );
let len = code.length;
if (len === 3) {
$('#input-province').val(code[0]);
$('#input-city').val(code[1]);
$('#input-county').val(code[2]);
$('#input-province-text').val(name[0]);
$('#input-city-text').val(name[1]);
$('#input-county-text').val(name[2]);
}
},
selected: [province, city, county],
})