From 027db84a25ece5ee166b44bf8389900281952b82 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:47:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9AAPI=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=94=AF=E6=8C=81=E5=90=8C=E7=AB=99=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E5=92=8C=E5=AE=89=E5=85=A8=E5=8C=BA=E5=9F=9F=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- basic-info.css | 9 ++++----- index.html | 2 +- src/js/config/api.config.js | 4 +++- src/js/core/api.js | 21 +++++++++++++++++---- src/js/utils/validator.js | 20 -------------------- 5 files changed, 25 insertions(+), 31 deletions(-) diff --git a/basic-info.css b/basic-info.css index 57143ec..a1747be 100644 --- a/basic-info.css +++ b/basic-info.css @@ -15,7 +15,7 @@ body { .basic-info-container { min-height: 100vh; padding: 16px; - padding-bottom: 100px; + padding-bottom: calc(130px + env(safe-area-inset-bottom, 0px)); } /* 顶部卡片 */ @@ -547,14 +547,13 @@ body { transform: scale(0.98); } -/* 底部按钮 */ +/* 底部按钮:贴底并预留安全区,避免被系统栏/手势区遮挡 */ .button-section { position: fixed; - bottom: 20px; + bottom: 0; left: 0; width: 100%; - padding: 16px; - padding-bottom: calc(8px + env(safe-area-inset-bottom)); + padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px)); background-color: #fff; box-shadow: 0 -2px 4px 0 rgba(0, 0, 0, 0.08); z-index: 100; diff --git a/index.html b/index.html index 70bd568..3f73703 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ - 薇钱包 + 百雅融 diff --git a/src/js/config/api.config.js b/src/js/config/api.config.js index ba4b765..4e6acbf 100644 --- a/src/js/config/api.config.js +++ b/src/js/config/api.config.js @@ -8,7 +8,9 @@ export const API_CONFIG = { // BASE_URL: 'http://localhost:8071', // 生产环境 URL(如需切换,取消注释并注释掉上面的) - BASE_URL: 'https://flux.1216.top', + // BASE_URL: 'https://flux.1216.top', + + BASE_URL: '', // API 端点配置 ENDPOINTS: { diff --git a/src/js/core/api.js b/src/js/core/api.js index 57447b6..264719f 100644 --- a/src/js/core/api.js +++ b/src/js/core/api.js @@ -7,6 +7,17 @@ import { API_CONFIG, DEBUG_CONFIG } from '../config/index.js'; import { UserCache } from './user-cache.js'; export class ApiClient { + /** + * 拼接请求 URL(BASE_URL 为空时使用当前页同源,便于同站部署) + * @param {string} endpoint - 路径,如 /api/partnerh5/area_list + * @returns {string} - 完整 URL 或相对路径 + */ + static getRequestUrl(endpoint) { + const base = API_CONFIG.BASE_URL; + if (base) return base.replace(/\/$/, '') + endpoint; + return endpoint; + } + /** * 构建查询参数 * @param {Object} params - 参数对象 @@ -42,7 +53,7 @@ export class ApiClient { * @returns {Promise} - 响应数据 */ static async post(endpoint, data = {}) { - const url = API_CONFIG.BASE_URL + endpoint; + const url = this.getRequestUrl(endpoint); const headers = this.getHeaders('application/json'); try { @@ -75,7 +86,7 @@ export class ApiClient { * @returns {Promise} - 响应数据 */ static async xpost(endpoint, data = {}) { - const url = API_CONFIG.BASE_URL + endpoint; + const url = this.getRequestUrl(endpoint); const headers = this.getHeaders('application/x-www-form-urlencoded'); try { @@ -108,9 +119,11 @@ export class ApiClient { * @returns {Promise} - 响应数据 */ static async get(endpoint, params = {}) { - const url = new URL(API_CONFIG.BASE_URL + endpoint); + const baseUrl = this.getRequestUrl(endpoint); + const url = baseUrl.startsWith('http') + ? new URL(baseUrl) + : new URL(baseUrl, window.location.origin); - // 添加查询参数 Object.entries(params).forEach(([key, value]) => { url.searchParams.append(key, value); }); diff --git a/src/js/utils/validator.js b/src/js/utils/validator.js index dca1f2a..c44431d 100644 --- a/src/js/utils/validator.js +++ b/src/js/utils/validator.js @@ -96,26 +96,6 @@ export class Validator { return idCard[17].toUpperCase() === checkCode; } - /** - * 从身份证号提取地区代码 - * @param {string} idCard - 身份证号 - * @returns {string|null} - 地区代码(前6位),如果无效则返回 null - */ - static extractAreaCode(idCard) { - if (!idCard) { - return null; - } - - const idCardStr = idCard.trim(); - - // 身份证号前6位是地区代码 - if (idCardStr.length >= 6) { - return idCardStr.substring(0, 6); - } - - return null; - } - /** * 验证短信验证码 * @param {string} code - 验证码