From cdda12afaa0add6f4d0708a885f0cd0c75a03e5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=9D=E5=B0=98?= <237809796@qq.com> Date: Fri, 30 Jan 2026 13:48:53 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=EF=BC=9A=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E8=BA=AB=E4=BB=BD=E8=AF=81=E8=87=AA=E5=8A=A8=E5=A1=AB=E5=85=85?= =?UTF-8?q?=E5=9C=B0=E5=8C=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/js/pages/basic-info.page.js | 60 ++++++++------------------------- src/js/services/area.service.js | 44 ------------------------ 2 files changed, 14 insertions(+), 90 deletions(-) diff --git a/src/js/pages/basic-info.page.js b/src/js/pages/basic-info.page.js index 0d462d7..9ec0153 100644 --- a/src/js/pages/basic-info.page.js +++ b/src/js/pages/basic-info.page.js @@ -27,9 +27,6 @@ export class BasicInfoPage { this.isSavingDraft = false; this.autoSaveTimer = null; - // 身份证自动填充标记 - this.lastFilledAreaCode = null; - // 组件实例 this.cityPicker = null; this.agreementModal = null; @@ -336,34 +333,15 @@ export class BasicInfoPage { const input = infoItem.querySelector(`#basic-input-${item.id}`); const errorEl = infoItem.querySelector(`#error-${item.id}`); - input.addEventListener('input', async () => { + input.addEventListener('input', () => { this.basicInfoValues[item.id] = input.value.trim(); this.updateBasicInfoProgress(); this.checkSubmitButton(); - // 清除错误提示 - input.classList.remove('error'); if (errorEl) { + input.classList.remove('error'); errorEl.style.display = 'none'; } - - // 身份证输入到6位时,自动填充地区 - if (item.id === 'idCard' && input.value.trim().length >= 6) { - const areaCode = Validator.extractAreaCode(input.value); - console.log('[BasicInfoPage] 身份证输入,提取地区代码:', areaCode); - - if (areaCode && areaCode !== this.lastFilledAreaCode) { - console.log('[BasicInfoPage] 查询地区信息...'); - const areaInfo = await AreaService.getAreaByCode(areaCode); - console.log('[BasicInfoPage] 查询结果:', areaInfo); - - if (areaInfo) { - this.handleCityConfirm(areaInfo); - this.lastFilledAreaCode = areaCode; - console.log('[BasicInfoPage] 地区自动填充成功'); - } - } - } }); } }); @@ -636,18 +614,12 @@ export class BasicInfoPage { // 清除草稿 DraftManager.clearDraft(); - // 提交成功,显示结果 - const h5Urls = response.data?.h5Urls || response.data?.h5urls; - if (response.data && h5Urls && h5Urls.length > 0) { - // 如果有返回的 H5 URL,显示跳转选项 + // 提交成功:有返回数据则进入成功页(含无 H5 时的成功+5秒倒计时/回首页) + if (response.data) { this.showSubmitSuccessDialog(response.data); } else { - // 普通成功提示 showToast('信息提交成功!'); - // 延迟跳转或刷新 - setTimeout(() => { - window.location.reload(); - }, 2000); + setTimeout(() => window.location.reload(), 2000); } } else { throw new Error(response.message || '提交失败'); @@ -850,29 +822,25 @@ export class BasicInfoPage { iframeSection.style.display = 'none'; } - // 创建完成提示 + // 有 redirectUrl 跳转直推页,否则 5 秒后回首页(与无 h5Urls 分支一致) + const finalUrl = redirectUrl || window.location.href.split('?')[0]; + const btnText = redirectUrl ? '立即跳转' : '返回首页'; + const completeSection = document.createElement('div'); completeSection.className = 'auth-complete-section'; completeSection.innerHTML = `
全部授权完成
您的申请已全部提交成功!
- ${redirectUrl ? ` -
- 5 秒后自动跳转... -
- - ` : ` - - `} +
+ 5 秒后自动跳转... +
+ `; container.appendChild(completeSection); - // 启动倒计时 - if (redirectUrl) { - this.startFinalCountdown(redirectUrl); - } + this.startFinalCountdown(finalUrl); } /** diff --git a/src/js/services/area.service.js b/src/js/services/area.service.js index 9fdbec3..ecc6ff8 100644 --- a/src/js/services/area.service.js +++ b/src/js/services/area.service.js @@ -116,50 +116,6 @@ export class AreaService { .filter(key => key.startsWith(CACHE_KEY_PREFIX)) .forEach(key => localStorage.removeItem(key)); } - - /** - * 根据地区代码(身份证前6位)查询地区信息 - * @param {string} areaCode - 地区代码(6位) - * @returns {Promise} - 地区信息 {province, city, district, value},如果未找到则返回 null - */ - static async getAreaByCode(areaCode) { - if (!areaCode || areaCode.length < 6) { - return null; - } - - try { - const provincecode = areaCode.substring(0, 2); - - // 并行查询省列表和该省的市区列表 - const [provinces, areas] = await Promise.all([ - this.getProvinces(), - this.getAreaList(provincecode) - ]); - - // 查找省、市、区 - const province = provinces.find(p => p.code === provincecode); - const city = areas.find(a => a.code === areaCode.substring(0, 4)); - const district = areas.find(a => a.code === areaCode); - - // 至少要有省份才返回 - if (province) { - return { - province: province.name, - city: city ? city.name : '', - district: district ? district.name : '', - provinceCode: province.code, - cityCode: city ? city.code : '', - districtCode: district ? district.code : '', - value: city ? city.name : province.name // 只返回市名或省名 - }; - } - - return null; - } catch (error) { - console.error('[AreaService] 根据代码查询地区失败:', error); - return null; - } - } } export default AreaService;