优化:字段名兼容性处理

This commit is contained in:
2026-01-27 22:28:13 +08:00
parent d1b2388616
commit f769373da1
16 changed files with 1076 additions and 59 deletions

View File

@@ -5,10 +5,10 @@
export const API_CONFIG = {
// 基础 URL - 开发环境
BASE_URL: 'http://localhost:8071',
// BASE_URL: 'http://localhost:8071',
// 生产环境 URL如需切换取消注释并注释掉上面的
// BASE_URL: 'https://flux.1216.top',
BASE_URL: 'https://flux.1216.top',
// API 端点配置
ENDPOINTS: {
@@ -20,18 +20,18 @@ export const API_CONFIG = {
JPUSH_LOGIN: '/zcore/jpush/login',
// 客户相关接口(使用 x-www-form-urlencoded 格式)
CUSTOMER_REGISTER: '/partnerh5/login',
CUSTOMER_REGISTER: '/api/partnerh5/login',
// 表单相关接口(使用 x-www-form-urlencoded 格式)
SUBMIT_FORM: '/partnerh5/submit',
SUBMIT_DRAFT_FORM: '/partnerh5/save_draft',
GET_DRAFT_FORM: '/partnerh5/get_draft',
SUBMIT_FORM: '/api/partnerh5/submit',
SUBMIT_DRAFT_FORM: '/api/partnerh5/save_draft',
GET_DRAFT_FORM: '/api/partnerh5/get_draft',
// 授权状态查询接口
CHECK_AUTH_STATUS: '/partnerh5/check_auth_status',
CHECK_AUTH_STATUS: '/api/partnerh5/check_auth_status',
// 区域数据接口
AREA_LIST: '/partnerh5/area_list',
AREA_LIST: '/api/partnerh5/area_list',
},
// 请求超时配置(毫秒)

View File

@@ -5,12 +5,15 @@
// ==================== 调试配置 ====================
export const DEBUG_CONFIG = {
// 调试模式开关
ENABLED: true,
// 调试模式开关(生产环境设为 false
ENABLED: false,
// 调试模式下的固定验证码
SMS_CODE: '123456',
// 调试模式下默认的短链代码
DEFAULT_SHORTCODE: 'sRh907',
// 是否启用详细日志
VERBOSE_LOGGING: true,
};
@@ -39,7 +42,9 @@ export const ASSET_CONFIG = {
'有公积金': 1, '无公积金': 2,
'有社保': 1, '无社保': 2,
'有信用卡': 1, '无信用卡': 2,
'有银行流水': 1, '无银行流水': 2
'有银行流水': 1, '无银行流水': 2,
'上班族': 1, '自由职业': 2, '企业主': 3, '公务员/国企': 4,
'700以上': 1, '650-700': 2, '600-650': 3, '无': 4
},
// 资产选项反向映射:数字值 → 中文
@@ -49,7 +54,9 @@ export const ASSET_CONFIG = {
fund: { 1: '有公积金', 2: '无公积金' },
social: { 1: '有社保', 2: '无社保' },
credit: { 1: '有信用卡', 2: '无信用卡' },
bank: { 1: '有银行流水', 2: '无银行流水' }
bank: { 1: '有银行流水', 2: '无银行流水' },
job: { 1: '上班族', 2: '自由职业', 3: '企业主', 4: '公务员/国企' },
zhima: { 1: '700以上', 2: '650-700', 3: '600-650', 4: '无' }
},
// 资产项配置列表
@@ -59,7 +66,9 @@ export const ASSET_CONFIG = {
{ id: 'fund', name: '公积金', options: ['有公积金', '无公积金'] },
{ id: 'social', name: '社保', options: ['有社保', '无社保'] },
{ id: 'credit', name: '信用卡', options: ['有信用卡', '无信用卡'] },
{ id: 'bank', name: '银行流水', options: ['有银行流水', '无银行流水'] }
{ id: 'bank', name: '银行流水', options: ['有银行流水', '无银行流水'] },
{ id: 'job', name: '职业', options: ['上班族', '自由职业', '企业主', '公务员/国企'] },
{ id: 'zhima', name: '芝麻分', options: ['700以上', '650-700', '600-650', '无'] }
],
// 进度金额配置
@@ -136,12 +145,6 @@ export const CACHE_CONFIG = {
USER_SESSION: 'flux_user_session',
FORM_ID: 'flux_form_id',
},
// 测试模式配置
TEST_MODE: {
ENABLED: true, // 是否启用测试模式
DEFAULT_SHORTCODE: 'sRh907', // 测试模式下默认的短链代码
},
};
// ==================== 验证规则配置 ====================

View File

@@ -35,6 +35,8 @@ export class DraftManager {
social: ASSET_CONFIG.VALUE_MAPPING[formData.assets.social] || 0,
credit: ASSET_CONFIG.VALUE_MAPPING[formData.assets.credit] || 0,
bank: ASSET_CONFIG.VALUE_MAPPING[formData.assets.bank] || 0,
job: ASSET_CONFIG.VALUE_MAPPING[formData.assets.job] || 0,
zhima: ASSET_CONFIG.VALUE_MAPPING[formData.assets.zhima] || 0,
realname: formData.basicInfo.name || '',
idcard: formData.basicInfo.idCard || '',
city: formData.basicInfo.city || '',
@@ -74,6 +76,12 @@ export class DraftManager {
if (serverData.bank && ASSET_CONFIG.REVERSE_MAPPING.bank[serverData.bank]) {
formData.assets.bank = ASSET_CONFIG.REVERSE_MAPPING.bank[serverData.bank];
}
if (serverData.job && ASSET_CONFIG.REVERSE_MAPPING.job[serverData.job]) {
formData.assets.job = ASSET_CONFIG.REVERSE_MAPPING.job[serverData.job];
}
if (serverData.zhima && ASSET_CONFIG.REVERSE_MAPPING.zhima[serverData.zhima]) {
formData.assets.zhima = ASSET_CONFIG.REVERSE_MAPPING.zhima[serverData.zhima];
}
// 转换基本信息
if (serverData.realname) {
@@ -95,21 +103,23 @@ export class DraftManager {
* @private
*/
static _getShortcode() {
// 测试模式下使用默认 shortcode
if (CACHE_CONFIG.TEST_MODE.ENABLED) {
console.log('[DraftManager] 测试模式,使用默认 shortcode:', CACHE_CONFIG.TEST_MODE.DEFAULT_SHORTCODE);
return CACHE_CONFIG.TEST_MODE.DEFAULT_SHORTCODE;
}
// 优先从 URL 获取
const params = new URLSearchParams(window.location.search);
const shortcode = params.get('code') || params.get('shortcode') || '';
if (!shortcode) {
console.warn('[DraftManager] URL 中未找到 code 或 shortcode 参数');
console.warn('[DraftManager] 当前 URL:', window.location.href);
if (shortcode) {
return shortcode;
}
return shortcode;
// URL 中没有,调试模式下使用默认 shortcode
if (DEBUG_CONFIG.ENABLED && DEBUG_CONFIG.DEFAULT_SHORTCODE) {
console.log('[DraftManager] URL 无 shortcode调试模式使用默认值:', DEBUG_CONFIG.DEFAULT_SHORTCODE);
return DEBUG_CONFIG.DEFAULT_SHORTCODE;
}
console.warn('[DraftManager] URL 中未找到 code 或 shortcode 参数');
console.warn('[DraftManager] 当前 URL:', window.location.href);
return '';
}
/**

View File

@@ -548,7 +548,7 @@ export class BasicInfoPage {
console.error('[BasicInfoPage] 当前 URL:', window.location.href);
console.error('[BasicInfoPage] 解决方案:');
console.error(' 1. 在 URL 中添加 ?code=your_shortcode');
console.error(' 2. 或启用试模式(CACHE_CONFIG.TEST_MODE.ENABLED = true');
console.error(' 2. 或启用试模式(DEBUG_CONFIG.ENABLED = true');
}
}
} catch (error) {
@@ -631,7 +631,8 @@ export class BasicInfoPage {
DraftManager.clearDraft();
// 提交成功,显示结果
if (response.data && response.data.h5Urls) {
const h5Urls = response.data?.h5Urls || response.data?.h5urls;
if (response.data && h5Urls && h5Urls.length > 0) {
// 如果有返回的 H5 URL显示跳转选项
this.showSubmitSuccessDialog(response.data);
} else {
@@ -657,10 +658,15 @@ export class BasicInfoPage {
/**
* 显示提交成功页面(授权流程)
* @param {Object} data - 返回数据 { formdataid, h5Urls, redirectUrl }
* @param {Object} data - 返回数据 { formdataid/formDataId/formid, h5Urls, redirectUrl }
*/
showSubmitSuccessDialog(data) {
const { formdataid, h5Urls, redirectUrl } = data;
// 兼容不同的字段名
const formdataid = data.formdataid || data.formDataId || data.formid || data.id;
const h5Urls = data.h5Urls || data.h5urls || [];
const redirectUrl = data.redirectUrl || data.redirecturl || '';
console.log('[BasicInfoPage] 授权流程数据:', { formdataid, h5Urls, redirectUrl });
// 隐藏表单相关的所有内容
const topCard = document.querySelector('.top-card');

View File

@@ -27,7 +27,8 @@ export class IndexPage {
this.oneClickLoginBtn = null; // 一键登录按钮
// 极光一键登录配置
this.jVerifyAppId = '80570da3ef331d9de547b4f1'; // 极光AppKey
// 注意:使用一键登录需要在极光控制台配置域名白名单,否则会出现跨域错误
this.jVerifyAppId = '80570da3ef331d9de547b4f1';
// 倒计时定时器
this.countdownTimer = null;

View File

@@ -112,9 +112,20 @@ export class AuthFlowService {
onStart(item, i);
}
// 切换 iframe
// 切换 iframe 或新窗口
if (onIframeChange && item.h5url) {
onIframeChange(item.h5url);
const targetUrl = item.h5url;
// 检查是否存在 Mixed Content 问题HTTPS 页面加载 HTTP 内容)
const isMixedContent = window.location.protocol === 'https:' && targetUrl.startsWith('http://');
if (isMixedContent) {
// HTTPS 页面无法在 iframe 中加载 HTTP 内容,改用新窗口打开
console.log('[AuthFlowService] 检测到 Mixed Content使用新窗口打开:', targetUrl);
onIframeChange(targetUrl, { useNewWindow: true });
} else {
onIframeChange(targetUrl);
}
}
// 轮询等待授权完成

View File

@@ -11,32 +11,40 @@ export class AuthService {
/**
* 客户注册或登录
* @param {string} phone - 手机号
* @param {Object} loanData - 借款数据
* @param {number} loanData.loanamount - 借款金额
* @param {number} loanData.repaymentperiod - 还款期数
* @param {string} loanData.loanpurpose - 借款用途
* @param {Object} loanData - 借款数据(支持 amount/period/purpose 或 loanamount/repaymentperiod/loanpurpose
* @param {number} [loanData.amount] - 借款金额(与 loanamount 二选一)
* @param {number} [loanData.period] - 还款期数(与 repaymentperiod 二选一)
* @param {string} [loanData.purpose] - 借款用途(与 loanpurpose 二选一)
* @returns {Promise<{success: boolean, message: string, data: Object}>} - 注册/登录结果
*/
static async registerOrLogin(phone, loanData) {
try {
const response = await ApiClient.xpost(API_CONFIG.ENDPOINTS.CUSTOMER_REGISTER, {
const loanamount = Number(loanData?.loanamount ?? loanData?.amount ?? 0) || 0;
const repaymentperiod = Number(loanData?.repaymentperiod ?? loanData?.period ?? 0) || 0;
const loanpurpose = (typeof (loanData?.loanpurpose ?? loanData?.purpose) === 'string')
? (loanData.loanpurpose ?? loanData.purpose).trim()
: '';
const payload = {
mobile: phone,
loanamount: loanData.loanamount,
repaymentperiod: loanData.repaymentperiod,
loanpurpose: loanData.loanpurpose
});
loanamount,
repaymentperiod,
loanpurpose
};
const response = await ApiClient.xpost(API_CONFIG.ENDPOINTS.CUSTOMER_REGISTER, payload);
if (response.retcode === 0) {
console.log('[AuthService] 后端返回数据:', response.result);
// 保存用户登录状态到缓存
// 保存用户登录状态到缓存formData 使用与接口一致的字段名,供 basic-info 恢复用)
const userData = {
...response.result,
customerid: response.result.customerid || response.result.customerId,
loginPhone: phone,
sessionid: response.result.sessionid || response.result.sessionId,
mobile: response.result.mobile,
formData: loanData
formData: { loanamount, repaymentperiod, loanpurpose }
};
console.log('[AuthService] 保存用户数据:', userData);