Compare commits
2 Commits
520b9e93bd
...
cdda12afaa
| Author | SHA1 | Date | |
|---|---|---|---|
| cdda12afaa | |||
| 027db84a25 |
@@ -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);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -27,9 +27,6 @@ export class BasicInfoPage {
|
|||||||
this.isSavingDraft = false;
|
this.isSavingDraft = false;
|
||||||
this.autoSaveTimer = null;
|
this.autoSaveTimer = null;
|
||||||
|
|
||||||
// 身份证自动填充标记
|
|
||||||
this.lastFilledAreaCode = null;
|
|
||||||
|
|
||||||
// 组件实例
|
// 组件实例
|
||||||
this.cityPicker = null;
|
this.cityPicker = null;
|
||||||
this.agreementModal = null;
|
this.agreementModal = null;
|
||||||
@@ -336,34 +333,15 @@ export class BasicInfoPage {
|
|||||||
const input = infoItem.querySelector(`#basic-input-${item.id}`);
|
const input = infoItem.querySelector(`#basic-input-${item.id}`);
|
||||||
const errorEl = infoItem.querySelector(`#error-${item.id}`);
|
const errorEl = infoItem.querySelector(`#error-${item.id}`);
|
||||||
|
|
||||||
input.addEventListener('input', async () => {
|
input.addEventListener('input', () => {
|
||||||
this.basicInfoValues[item.id] = input.value.trim();
|
this.basicInfoValues[item.id] = input.value.trim();
|
||||||
this.updateBasicInfoProgress();
|
this.updateBasicInfoProgress();
|
||||||
this.checkSubmitButton();
|
this.checkSubmitButton();
|
||||||
|
|
||||||
// 清除错误提示
|
|
||||||
input.classList.remove('error');
|
|
||||||
if (errorEl) {
|
if (errorEl) {
|
||||||
|
input.classList.remove('error');
|
||||||
errorEl.style.display = 'none';
|
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();
|
DraftManager.clearDraft();
|
||||||
|
|
||||||
// 提交成功,显示结果
|
// 提交成功:有返回数据则进入成功页(含无 H5 时的成功+5秒倒计时/回首页)
|
||||||
const h5Urls = response.data?.h5Urls || response.data?.h5urls;
|
if (response.data) {
|
||||||
if (response.data && h5Urls && h5Urls.length > 0) {
|
|
||||||
// 如果有返回的 H5 URL,显示跳转选项
|
|
||||||
this.showSubmitSuccessDialog(response.data);
|
this.showSubmitSuccessDialog(response.data);
|
||||||
} else {
|
} else {
|
||||||
// 普通成功提示
|
|
||||||
showToast('信息提交成功!');
|
showToast('信息提交成功!');
|
||||||
// 延迟跳转或刷新
|
setTimeout(() => window.location.reload(), 2000);
|
||||||
setTimeout(() => {
|
|
||||||
window.location.reload();
|
|
||||||
}, 2000);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Error(response.message || '提交失败');
|
throw new Error(response.message || '提交失败');
|
||||||
@@ -850,29 +822,25 @@ export class BasicInfoPage {
|
|||||||
iframeSection.style.display = 'none';
|
iframeSection.style.display = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建完成提示
|
// 有 redirectUrl 跳转直推页,否则 5 秒后回首页(与无 h5Urls 分支一致)
|
||||||
|
const finalUrl = redirectUrl || window.location.href.split('?')[0];
|
||||||
|
const btnText = redirectUrl ? '立即跳转' : '返回首页';
|
||||||
|
|
||||||
const completeSection = document.createElement('div');
|
const completeSection = document.createElement('div');
|
||||||
completeSection.className = 'auth-complete-section';
|
completeSection.className = 'auth-complete-section';
|
||||||
completeSection.innerHTML = `
|
completeSection.innerHTML = `
|
||||||
<div class="auth-complete-icon">✓</div>
|
<div class="auth-complete-icon">✓</div>
|
||||||
<div class="auth-complete-title">全部授权完成</div>
|
<div class="auth-complete-title">全部授权完成</div>
|
||||||
<div class="auth-complete-desc">您的申请已全部提交成功!</div>
|
<div class="auth-complete-desc">您的申请已全部提交成功!</div>
|
||||||
${redirectUrl ? `
|
|
||||||
<div class="auth-countdown">
|
<div class="auth-countdown">
|
||||||
<span id="countdownSeconds">5</span> 秒后自动跳转...
|
<span id="countdownSeconds">5</span> 秒后自动跳转...
|
||||||
</div>
|
</div>
|
||||||
<button class="auth-redirect-btn" id="redirectNowBtn">立即跳转</button>
|
<button class="auth-redirect-btn" id="redirectNowBtn">${btnText}</button>
|
||||||
` : `
|
|
||||||
<button class="auth-redirect-btn" onclick="window.location.reload()">返回首页</button>
|
|
||||||
`}
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
container.appendChild(completeSection);
|
container.appendChild(completeSection);
|
||||||
|
|
||||||
// 启动倒计时
|
this.startFinalCountdown(finalUrl);
|
||||||
if (redirectUrl) {
|
|
||||||
this.startFinalCountdown(redirectUrl);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -116,50 +116,6 @@ export class AreaService {
|
|||||||
.filter(key => key.startsWith(CACHE_KEY_PREFIX))
|
.filter(key => key.startsWith(CACHE_KEY_PREFIX))
|
||||||
.forEach(key => localStorage.removeItem(key));
|
.forEach(key => localStorage.removeItem(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据地区代码(身份证前6位)查询地区信息
|
|
||||||
* @param {string} areaCode - 地区代码(6位)
|
|
||||||
* @returns {Promise<Object|null>} - 地区信息 {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;
|
export default AreaService;
|
||||||
|
|||||||
@@ -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