优化:API配置支持同站部署和安全区域适配
This commit is contained in:
@@ -15,7 +15,7 @@ body {
|
|||||||
.basic-info-container {
|
.basic-info-container {
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
padding-bottom: 100px;
|
padding-bottom: calc(130px + env(safe-area-inset-bottom, 0px));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 顶部卡片 */
|
/* 顶部卡片 */
|
||||||
@@ -547,14 +547,13 @@ body {
|
|||||||
transform: scale(0.98);
|
transform: scale(0.98);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 底部按钮 */
|
/* 底部按钮:贴底并预留安全区,避免被系统栏/手势区遮挡 */
|
||||||
.button-section {
|
.button-section {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 20px;
|
bottom: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 16px;
|
padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
|
||||||
padding-bottom: calc(8px + env(safe-area-inset-bottom));
|
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
box-shadow: 0 -2px 4px 0 rgba(0, 0, 0, 0.08);
|
box-shadow: 0 -2px 4px 0 rgba(0, 0, 0, 0.08);
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||||
<title>薇钱包</title>
|
<title>百雅融</title>
|
||||||
<link rel="stylesheet" href="style.css">
|
<link rel="stylesheet" href="style.css">
|
||||||
<link rel="stylesheet" href="./src/css/components/one-click-login.css">
|
<link rel="stylesheet" href="./src/css/components/one-click-login.css">
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ export const API_CONFIG = {
|
|||||||
// BASE_URL: 'http://localhost:8071',
|
// BASE_URL: 'http://localhost:8071',
|
||||||
|
|
||||||
// 生产环境 URL(如需切换,取消注释并注释掉上面的)
|
// 生产环境 URL(如需切换,取消注释并注释掉上面的)
|
||||||
BASE_URL: 'https://flux.1216.top',
|
// BASE_URL: 'https://flux.1216.top',
|
||||||
|
|
||||||
|
BASE_URL: '',
|
||||||
|
|
||||||
// API 端点配置
|
// API 端点配置
|
||||||
ENDPOINTS: {
|
ENDPOINTS: {
|
||||||
|
|||||||
@@ -7,6 +7,17 @@ import { API_CONFIG, DEBUG_CONFIG } from '../config/index.js';
|
|||||||
import { UserCache } from './user-cache.js';
|
import { UserCache } from './user-cache.js';
|
||||||
|
|
||||||
export class ApiClient {
|
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 - 参数对象
|
* @param {Object} params - 参数对象
|
||||||
@@ -42,7 +53,7 @@ export class ApiClient {
|
|||||||
* @returns {Promise<Object>} - 响应数据
|
* @returns {Promise<Object>} - 响应数据
|
||||||
*/
|
*/
|
||||||
static async post(endpoint, data = {}) {
|
static async post(endpoint, data = {}) {
|
||||||
const url = API_CONFIG.BASE_URL + endpoint;
|
const url = this.getRequestUrl(endpoint);
|
||||||
const headers = this.getHeaders('application/json');
|
const headers = this.getHeaders('application/json');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -75,7 +86,7 @@ export class ApiClient {
|
|||||||
* @returns {Promise<Object>} - 响应数据
|
* @returns {Promise<Object>} - 响应数据
|
||||||
*/
|
*/
|
||||||
static async xpost(endpoint, data = {}) {
|
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');
|
const headers = this.getHeaders('application/x-www-form-urlencoded');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -108,9 +119,11 @@ export class ApiClient {
|
|||||||
* @returns {Promise<Object>} - 响应数据
|
* @returns {Promise<Object>} - 响应数据
|
||||||
*/
|
*/
|
||||||
static async get(endpoint, params = {}) {
|
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]) => {
|
Object.entries(params).forEach(([key, value]) => {
|
||||||
url.searchParams.append(key, value);
|
url.searchParams.append(key, value);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -96,26 +96,6 @@ export class Validator {
|
|||||||
return idCard[17].toUpperCase() === checkCode;
|
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 - 验证码
|
* @param {string} code - 验证码
|
||||||
|
|||||||
Reference in New Issue
Block a user