| | |
| | | success: response => { |
| | | locationRes = response.data; |
| | | readyCallbacks.forEach(callback => callback()); |
| | | } |
| | | }, |
| | | }); |
| | | |
| | | export class ChinaLocations { |
| | |
| | | if (typeof regions === 'string') { |
| | | regions = regions.split(','); |
| | | } |
| | | if (!regions || regions.length === 0 || !regions[0]) { |
| | | if (!regions || regions.length === 0 || !regions[0] || !regions[1]) { |
| | | callback(''); |
| | | return; |
| | | } |
| | | // 中文转编码 |
| | | if (!/^\d+$/.test(regions[0])) { |
| | | this.getRegionCodes(regions, regionsCode => { |
| | | this.getRegionsArea(regionsCode, callback); |
| | | }); |
| | | return; |
| | | } |
| | | let area = ''; |
| | | // 省 |
| | |
| | | callback(area); |
| | | }); |
| | | } |
| | | }; |
| | | } |
| | | |
| | | export const $locations = new ChinaLocations(); |