From e9799a5b4b9f221447cba49e8fbf7bea6b6c0c42 Mon Sep 17 00:00:00 2001 From: Tevin <tingquanren@163.com> Date: Wed, 09 Apr 2025 20:25:41 +0800 Subject: [PATCH] 实现微信获取头像组件(小程序原生组件) --- forms/chinaArea/ChinaLocations.js | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) diff --git a/forms/chinaArea/ChinaLocations.js b/forms/chinaArea/ChinaLocations.js index ff1efb2..ee602ce 100644 --- a/forms/chinaArea/ChinaLocations.js +++ b/forms/chinaArea/ChinaLocations.js @@ -27,7 +27,7 @@ success: response => { locationRes = response.data; readyCallbacks.forEach(callback => callback()); - } + }, }); export class ChinaLocations { @@ -213,8 +213,16 @@ 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 = ''; // 省 @@ -238,6 +246,6 @@ callback(area); }); } -}; +} export const $locations = new ChinaLocations(); \ No newline at end of file -- Gitblit v1.9.1