mirror of
https://gitee.com/liuxioabin/fengketrade.git
synced 2026-04-17 21:03:17 +08:00
'登录调试'
This commit is contained in:
parent
639732e6d1
commit
9f46412131
199
frontend/App.vue
199
frontend/App.vue
@ -1,8 +1,14 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { onLaunch, onShow, onError } from '@dcloudio/uni-app';
|
import { onLaunch, onShow, onError } from '@dcloudio/uni-app';
|
||||||
import { ShoproInit } from './sheep';
|
import { ShoproInit } from './sheep';
|
||||||
|
import sheep from '@/sheep';
|
||||||
|
|
||||||
|
// 防止重复登录的标志
|
||||||
|
let isLoggingIn = false;
|
||||||
|
|
||||||
onLaunch(() => {
|
onLaunch(() => {
|
||||||
|
console.log('[App] 应用启动...');
|
||||||
|
|
||||||
// 隐藏原生导航栏 使用自定义底部导航
|
// 隐藏原生导航栏 使用自定义底部导航
|
||||||
uni.hideTabBar({
|
uni.hideTabBar({
|
||||||
fail: () => {},
|
fail: () => {},
|
||||||
@ -10,6 +16,9 @@
|
|||||||
|
|
||||||
// 加载Shopro底层依赖
|
// 加载Shopro底层依赖
|
||||||
ShoproInit();
|
ShoproInit();
|
||||||
|
|
||||||
|
// 检测建行生活登录参数
|
||||||
|
checkCCBLogin();
|
||||||
});
|
});
|
||||||
|
|
||||||
onError((err) => {
|
onError((err) => {
|
||||||
@ -29,8 +38,198 @@
|
|||||||
});
|
});
|
||||||
// #endif
|
// #endif
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测URL中的建行登录参数并自动登录
|
||||||
|
* 建行跳转URL格式:url?platform=ccblife&channel=mbs&ccbParamSJ=xxx&CITYID=330100&USERCITYID=440100
|
||||||
|
*
|
||||||
|
* 逻辑:
|
||||||
|
* 1. 解析URL参数获取ccbParamSJ
|
||||||
|
* 2. 与本地存储的lastCcbParamSJ比较
|
||||||
|
* 3. 如果一致则无需重新登录
|
||||||
|
* 4. 如果不一致则需要切换用户(退出当前用户后重新登录)
|
||||||
|
*/
|
||||||
|
const checkCCBLogin = () => {
|
||||||
|
// #ifdef H5
|
||||||
|
console.log('[App] ========== 开始检测建行登录参数 ==========');
|
||||||
|
console.log('[App] 完整URL:', window.location.href);
|
||||||
|
console.log('[App] search:', window.location.search);
|
||||||
|
|
||||||
|
try {
|
||||||
|
let ccbParamSJ = null;
|
||||||
|
let platform = null;
|
||||||
|
let cityid = null;
|
||||||
|
|
||||||
|
// 优先从search中提取参数(建行标准格式:url?platform=ccblife&ccbParamSJ=xxx)
|
||||||
|
if (window.location.search) {
|
||||||
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
|
ccbParamSJ = urlParams.get('ccbParamSJ');
|
||||||
|
platform = urlParams.get('platform');
|
||||||
|
cityid = urlParams.get('CITYID') || urlParams.get('cityid');
|
||||||
|
console.log('[App] 从search中解析参数');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 备用:从hash中提取参数(UniApp内部跳转可能使用)
|
||||||
|
if (!ccbParamSJ && window.location.hash.includes('?')) {
|
||||||
|
const hashParts = window.location.hash.split('?');
|
||||||
|
if (hashParts.length > 1) {
|
||||||
|
const hashParams = new URLSearchParams(hashParts[1]);
|
||||||
|
ccbParamSJ = hashParams.get('ccbParamSJ');
|
||||||
|
platform = hashParams.get('platform');
|
||||||
|
cityid = hashParams.get('CITYID') || hashParams.get('cityid');
|
||||||
|
console.log('[App] 从hash中解析参数');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('[App] ====== 参数解析结果 ======');
|
||||||
|
console.log('[App] platform:', platform);
|
||||||
|
console.log('[App] CITYID:', cityid);
|
||||||
|
console.log('[App] 当前ccbParamSJ:', ccbParamSJ ? ccbParamSJ.substring(0, 50) + '...' : 'null');
|
||||||
|
|
||||||
|
// 获取上次保存的ccbParamSJ
|
||||||
|
const lastCcbParamSJ = uni.getStorageSync('lastCcbParamSJ') || null;
|
||||||
|
console.log('[App] 上次ccbParamSJ:', lastCcbParamSJ ? lastCcbParamSJ.substring(0, 50) + '...' : 'null');
|
||||||
|
|
||||||
|
// 判断参数是否变化
|
||||||
|
const isParamChanged = ccbParamSJ && (lastCcbParamSJ !== ccbParamSJ);
|
||||||
|
const isFirstTime = ccbParamSJ && !lastCcbParamSJ;
|
||||||
|
|
||||||
|
console.log('[App] 是否首次登录:', isFirstTime);
|
||||||
|
console.log('[App] 参数是否变化:', isParamChanged);
|
||||||
|
console.log('[App] ===========================');
|
||||||
|
|
||||||
|
// 如果有建行参数
|
||||||
|
if (ccbParamSJ && platform === 'ccblife') {
|
||||||
|
|
||||||
|
// 如果参数未变化,无需重新登录
|
||||||
|
if (!isParamChanged && !isFirstTime) {
|
||||||
|
console.log('[App] ℹ️ ccbParamSJ未变化,无需重新登录,跳过');
|
||||||
|
// 清除URL参数
|
||||||
|
const cleanUrl = window.location.origin + window.location.pathname + '#/pages/index/index';
|
||||||
|
window.history.replaceState({}, '', cleanUrl);
|
||||||
|
console.log('[App] ========== 检测完成 ==========');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 参数变化了,需要切换用户
|
||||||
|
if (isParamChanged) {
|
||||||
|
console.log('[App] 🔄🔄🔄 检测到ccbParamSJ变化,需要切换用户!');
|
||||||
|
} else {
|
||||||
|
console.log('[App] 🆕 首次登录');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 🔒 防止重复调用:检查是否正在登录中
|
||||||
|
if (isLoggingIn) {
|
||||||
|
console.log('[App] ⚠️ 已有登录流程正在执行,跳过重复调用');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置登录中标志
|
||||||
|
isLoggingIn = true;
|
||||||
|
console.log('[App] 🔒 设置登录锁定标志');
|
||||||
|
|
||||||
|
// 延迟执行登录,确保依赖已初始化
|
||||||
|
setTimeout(async () => {
|
||||||
|
try {
|
||||||
|
console.log('[App] 开始执行登录流程...');
|
||||||
|
|
||||||
|
// 如果是切换用户,先退出当前用户
|
||||||
|
const userStore = sheep.$store('user');
|
||||||
|
if (isParamChanged && userStore && userStore.isLogin) {
|
||||||
|
console.log('[App] 退出当前用户,准备切换...');
|
||||||
|
await userStore.logout();
|
||||||
|
uni.removeStorageSync('token');
|
||||||
|
uni.removeStorageSync('userInfo');
|
||||||
|
console.log('[App] 当前用户已退出');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 显示loading
|
||||||
|
const loadingTitle = isParamChanged ? '切换用户中...' : '建行登录中...';
|
||||||
|
uni.showLoading({
|
||||||
|
title: loadingTitle,
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// 调用建行登录API(只传三个参数)
|
||||||
|
console.log('[App] 调用登录API,参数:', {
|
||||||
|
ccbParamSJ: ccbParamSJ.substring(0, 30) + '...',
|
||||||
|
cityid: cityid || '360100',
|
||||||
|
CITYID: cityid || '360100'
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await sheep.$api.third.ccbLogin({
|
||||||
|
ccbParamSJ: ccbParamSJ,
|
||||||
|
cityid: cityid || '360100',
|
||||||
|
CITYID: cityid || '360100'
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('[App] 登录API返回:', result);
|
||||||
|
|
||||||
|
uni.hideLoading();
|
||||||
|
|
||||||
|
if (result.code === 1) {
|
||||||
|
console.log('[App] ✅✅✅ 建行登录成功!');
|
||||||
|
console.log('[App] Token:', result.data.token?.substring(0, 20) + '...');
|
||||||
|
console.log('[App] 用户信息:', result.data.user_info);
|
||||||
|
|
||||||
|
// 设置token和用户信息
|
||||||
|
sheep.$store('user').setToken(result.data.token);
|
||||||
|
uni.setStorageSync('userInfo', result.data.user_info);
|
||||||
|
|
||||||
|
// 🔑 关键:保存当前的ccbParamSJ到本地存储
|
||||||
|
uni.setStorageSync('lastCcbParamSJ', ccbParamSJ);
|
||||||
|
console.log('[App] ✅ 已保存ccbParamSJ到本地存储');
|
||||||
|
|
||||||
|
// 显示欢迎提示
|
||||||
|
uni.showToast({
|
||||||
|
title: `登录成功`,
|
||||||
|
icon: 'success',
|
||||||
|
duration: 2000
|
||||||
|
});
|
||||||
|
|
||||||
|
// 清除URL中的敏感参数,保留干净的URL
|
||||||
|
const cleanUrl = window.location.origin + window.location.pathname + '#/pages/index/index';
|
||||||
|
window.history.replaceState({}, '', cleanUrl);
|
||||||
|
console.log('[App] URL参数已清除');
|
||||||
|
|
||||||
|
} else {
|
||||||
|
throw new Error(result.msg || '登录失败');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('[App] ❌❌❌ 建行登录失败:', error);
|
||||||
|
uni.hideLoading();
|
||||||
|
|
||||||
|
uni.showModal({
|
||||||
|
title: isParamChanged ? '切换用户失败' : '登录失败',
|
||||||
|
content: error.message || error.msg || '请检查网络连接',
|
||||||
|
showCancel: false,
|
||||||
|
complete: () => {
|
||||||
|
// 登录失败后也清除URL参数
|
||||||
|
const cleanUrl = window.location.origin + window.location.pathname + '#/pages/index/index';
|
||||||
|
window.history.replaceState({}, '', cleanUrl);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
// 🔓 无论成功失败,都释放登录锁
|
||||||
|
isLoggingIn = false;
|
||||||
|
console.log('[App] 🔓 释放登录锁定标志');
|
||||||
|
}
|
||||||
|
}, 1200); // 延迟1200ms,确保Shopro和API已加载完成
|
||||||
|
} else {
|
||||||
|
console.log('[App] ℹ️ 未检测到建行登录参数');
|
||||||
|
if (ccbParamSJ && platform !== 'ccblife') {
|
||||||
|
console.warn('[App] ⚠️ 发现ccbParamSJ但platform不是ccblife:', platform);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('[App] ❌ 参数解析错误:', error);
|
||||||
|
}
|
||||||
|
console.log('[App] ========== 检测完成 ==========');
|
||||||
|
// #endif
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
@import '@/sheep/scss/index.scss';
|
@import '@/sheep/scss/index.scss';
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "Shopro",
|
"name" : "Shopro",
|
||||||
"appid" : "__UNI__E99FC80",
|
"appid" : "__UNI__A0E4D3E",
|
||||||
"description" : "Shopro是由SheepJS团队开发,使用Uniapp+Vue3技术驱动的在线商城系统,内含诸多功能与丰富的活动,期待您的使用和反馈。",
|
"description" : "Shopro是由SheepJS团队开发,使用Uniapp+Vue3技术驱动的在线商城系统,内含诸多功能与丰富的活动,期待您的使用和反馈。",
|
||||||
"versionName" : "3.1.0",
|
"versionName" : "3.1.0",
|
||||||
"versionCode" : 310,
|
"versionCode" : 310,
|
||||||
|
|||||||
@ -61,6 +61,18 @@
|
|||||||
"navigationBarTitleText": "登录"
|
"navigationBarTitleText": "登录"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/user/mock-login",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "测试登录",
|
||||||
|
"navigationStyle": "custom"
|
||||||
|
},
|
||||||
|
"meta": {
|
||||||
|
"auth": false,
|
||||||
|
"title": "测试登录",
|
||||||
|
"group": "测试"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/index/search",
|
"path": "pages/index/search",
|
||||||
"style": {
|
"style": {
|
||||||
|
|||||||
@ -27,87 +27,6 @@
|
|||||||
const template = computed(() => sheep.$store('app').template.user);
|
const template = computed(() => sheep.$store('app').template.user);
|
||||||
const isLogin = computed(() => sheep.$store('user').isLogin);
|
const isLogin = computed(() => sheep.$store('user').isLogin);
|
||||||
|
|
||||||
// 建行生活自动登录(测试用)
|
|
||||||
const testCcbLogin = async () => {
|
|
||||||
// 检查是否已登录
|
|
||||||
if (isLogin.value) {
|
|
||||||
console.log('[User] 用户已登录,跳过建行测试登录');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 测试用的固定加密参数
|
|
||||||
const testCcbParam = {
|
|
||||||
ccbParamSJ: "ZWVlRURYQndmYlpJOGpMRWRPRWEwRjVCZk82NjQxam1sL0l0d0NWMm9lUDdURld3MDRXamlNSGcva29COXBoZkVHKytHbHpSeUM3VkNESkUvTXYrOHFGYkhZWXo4d1NmanZuN0kvODF6TEo1OU9UbTZhS29MSUw3NjQzTGRKQWtrUHhyQi92TEVscWZzVWhlbVBpMVhHbHV2Z2RheXczK0VDL0J5N0g5aWNNR1ZPbFpWN0w4RHlNMGcrY09ZdWF2RUwzN2xheUNqUXdNV1dkR0F6RmlKL1V4b0NyMUhQM2R0Ui9ld0Vicll4eFdFeTFvUEthQ3Z5Vy9MajZxNFhQZTlrSjdTQVh1UjFyOWZGYjdMa003LzZpNnVSd2hWSnBCZ1h0WnRwU1VQb3UxSmh1UG00ejdleW9SUVMrOUJ2bW5VcVJBZnM0dy9RWEIwRlhwOGtLZW5rQ3RPK2xjdHlmTzE2cnU5UXJleHhmT2Y1ZXZwNjh3Qy9aTWVCTnoxZng4OXI2YWd5NUFWbmE2bzUwOVJES2tCZElhaG5JZll2eURPa2lyeTBqS0pBdGptSkRIRWFhcjUvaTlTVXkrbVdIbklmdDNsZE4rbWRnMWE0R0tzZmpqNUpDcll2VkFvQ0tBWklIc3FRL21admtrSDBqWEhYZ0ZrMjk2MWJ3eExSNGI=",
|
|
||||||
cityid: "360100",
|
|
||||||
CITYID: "360100"
|
|
||||||
};
|
|
||||||
|
|
||||||
console.log('[User] 开始建行测试登录...');
|
|
||||||
|
|
||||||
// 显示加载提示
|
|
||||||
uni.showLoading({
|
|
||||||
title: '建行登录中...',
|
|
||||||
mask: true
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 调用建行登录API
|
|
||||||
const result = await sheep.$api.third.ccbLogin(testCcbParam);
|
|
||||||
|
|
||||||
uni.hideLoading();
|
|
||||||
|
|
||||||
if (result.code === 1) {
|
|
||||||
console.log('[User] 登录接口返回成功,开始更新状态...');
|
|
||||||
|
|
||||||
// 🔑 关键:使用setToken方法更新登录状态
|
|
||||||
// 这会同时:
|
|
||||||
// 1. 设置isLogin = true
|
|
||||||
// 2. 保存token到storage
|
|
||||||
// 3. 自动调用loginAfter()更新用户信息
|
|
||||||
sheep.$store('user').setToken(result.data.token);
|
|
||||||
|
|
||||||
// 也保存userInfo到storage(可选,setToken会自动获取)
|
|
||||||
uni.setStorageSync('userInfo', result.data.user_info);
|
|
||||||
|
|
||||||
console.log('[User] ✅ 建行测试登录成功');
|
|
||||||
console.log('[User] 登录状态已更新:', sheep.$store('user').isLogin);
|
|
||||||
|
|
||||||
// 显示欢迎提示
|
|
||||||
uni.showToast({
|
|
||||||
title: `欢迎 ${result.data.user_info?.nickname || ''}`,
|
|
||||||
icon: 'success',
|
|
||||||
duration: 2000
|
|
||||||
});
|
|
||||||
|
|
||||||
// 等待状态更新完成后刷新页面
|
|
||||||
setTimeout(() => {
|
|
||||||
console.log('[User] 刷新页面数据...');
|
|
||||||
sheep.$store('user').updateUserData();
|
|
||||||
}, 100);
|
|
||||||
} else {
|
|
||||||
throw new Error(result.msg || '登录失败');
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('[User] ❌ 建行测试登录失败:', error);
|
|
||||||
|
|
||||||
uni.hideLoading();
|
|
||||||
|
|
||||||
uni.showModal({
|
|
||||||
title: '登录失败',
|
|
||||||
content: error.message || error.msg || '请检查网络连接',
|
|
||||||
showCancel: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 页面挂载时自动登录(仅用于测试)
|
|
||||||
onMounted(() => {
|
|
||||||
// 延迟500ms执行,确保页面渲染完成
|
|
||||||
setTimeout(() => {
|
|
||||||
testCcbLogin();
|
|
||||||
}, 500);
|
|
||||||
});
|
|
||||||
|
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
sheep.$store('user').updateUserData();
|
sheep.$store('user').updateUserData();
|
||||||
});
|
});
|
||||||
|
|||||||
265
frontend/pages/user/mock-login.vue
Normal file
265
frontend/pages/user/mock-login.vue
Normal file
@ -0,0 +1,265 @@
|
|||||||
|
<template>
|
||||||
|
<view class="mock-login-page">
|
||||||
|
<view class="header">
|
||||||
|
<text class="title">建行生活测试登录</text>
|
||||||
|
<text class="subtitle">请选择测试用户</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="user-list">
|
||||||
|
<!-- 用户1 -->
|
||||||
|
<view class="user-card" @click="selectUser(1)">
|
||||||
|
<view class="user-avatar">
|
||||||
|
<text class="avatar-text">1</text>
|
||||||
|
</view>
|
||||||
|
<view class="user-info">
|
||||||
|
<text class="user-name">测试用户1</text>
|
||||||
|
<text class="user-mobile">138****0001</text>
|
||||||
|
<text class="user-id">ID: user_test_001</text>
|
||||||
|
</view>
|
||||||
|
<view class="arrow">
|
||||||
|
<text class="arrow-icon">→</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 用户2 -->
|
||||||
|
<view class="user-card" @click="selectUser(2)">
|
||||||
|
<view class="user-avatar user-avatar-2">
|
||||||
|
<text class="avatar-text">2</text>
|
||||||
|
</view>
|
||||||
|
<view class="user-info">
|
||||||
|
<text class="user-name">测试用户2</text>
|
||||||
|
<text class="user-mobile">138****0002</text>
|
||||||
|
<text class="user-id">ID: user_test_002</text>
|
||||||
|
</view>
|
||||||
|
<view class="arrow">
|
||||||
|
<text class="arrow-icon">→</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="tips">
|
||||||
|
<text class="tips-text">💡 提示:点击用户卡片后将模拟建行生活跳转</text>
|
||||||
|
<text class="tips-detail">URL格式:url?platform=ccblife&channel=mbs&ccbParamSJ=xxx&CITYID=xxx&USERCITYID=xxx</text>
|
||||||
|
<text class="tips-detail">App.vue 将自动检测参数并完成登录</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import sheep from '@/sheep';
|
||||||
|
|
||||||
|
// 两个测试用户的参数 (完全按照建行生活跳转URL格式)
|
||||||
|
const users = {
|
||||||
|
1: {
|
||||||
|
name: '测试用户1',
|
||||||
|
mobile: '138****0001',
|
||||||
|
params: {
|
||||||
|
platform: 'ccblife', // 建行生活平台标识
|
||||||
|
channel: 'mbs', // 渠道标识(可选)
|
||||||
|
ccbParamSJ: "ZWVlRURYQndmYlpJOGpMRWRPRWEwRjVCZk82NjQxam1sL0l0d0NWMm9lUDdURld3MDRXamlNSGcva29COXBoZkVHKytHbHpSeUM3VkNESkUvTXYrOHFGYkhZWXo4d1NmanZuN0kvODF6TEo1OU9UbTZhS29MSUw3NjQzTGRKQWtrUHhyQi92TEVscWZzVWhlbVBpMVhHbHV2Z2RheXczK0VDL0J5N0g5aWNNR1ZPbFpWN0w4RHlNMGcrY09ZdWF2RUwzN2xheUNqUXdNV1dkR0F6RmlKL1V4b0NyMUhQM2R0Ui9ld0Vicll4eFdFeTFvUEthQ3Z5Vy9MajZxNFhQZTlrSjdTQVh1UjFyOWZGYjdMa003LzZpNnVSd2hWSnBCZ1h0WnRwU1VQb3UxSmh1UG00ejdleW9SUVMrOUJ2bW5VcVJBZnM0dy9RWEIwRlhwOGtLZW5rQ3RPK2xjdHlmTzE2cnU5UXJleHhmT2Y1ZXZwNjh3Qy9aTWVCTnoxZng4OXI2YWd5NUFWbmE2bzUwOVJES2tCZElhaG5JZll2eURPa2lyeTBqS0pBdGptSkRIRWFhcjUvaTlTVXkrbVdIbklmdDNsZE4rbWRnMWE0R0tzZmpqNUpDcll2VkFvQ0tBWklIc3FRL21admtrSDBqWEhYZ0ZrMjk2MWJ3eExSNGI=",
|
||||||
|
CITYID: '330100', // 用户选择城市代码
|
||||||
|
USERCITYID: '440100' // 用户定位城市代码
|
||||||
|
}
|
||||||
|
},
|
||||||
|
2: {
|
||||||
|
name: '测试用户2',
|
||||||
|
mobile: '138****0002',
|
||||||
|
params: {
|
||||||
|
platform: 'ccblife',
|
||||||
|
channel: 'mbs',
|
||||||
|
ccbParamSJ: "SWQ5aGhCT2xReWZNOVZ3Vk51SVVQSFRIZXpuZkxVZU5MbTR1d0tWdzRzcXFKRGFJUE9TdzZwUE1LVkY4eWhRYXhoWmwvVFJEcXV0TitqS2NHOGlUcU1VWWxLc1E4TTBkcXh5aFMvNFZvUzdrOTEzcm9oTVNZeG1Ta2ZNOURJblRUSExTTWt1UXZIbGpKZktlVkRVb0V0Nk5xQVh4a2wxd3lYb2toWWhUSVd3Y0xZcmhJZnVDNVFVQTdQWDB3RVlWek55azRKV1dFWDJVN0h3OTNOTTFjaTZ4NmpramRsQXVPMVl0bURqN2lsbUovVWdSWG8ydVpldDMzTnlKWE9xUEJyWG41aVVTK3Q5WlFCbnFSRnVEbVE2OTFjdHZZbWVoTElaclpraE5nb0R4ME1QbVpJc0FDcVE4YWpqSkxBdWF2RTh4RDZ5eTIvOXN1dGtZR3dQTCtJZ1VvcVE3WlVmdGlZTVRaNWhEYlFLUDIyMjVtTjVrSUZreE9JUzFKdXBxQ3pQS1B5UTFNYnk5NE5QdExqMEdxOC85bW1XQ1RleGZBQmJleG82UnNoV3RDUlRhTjZDTFVFOHZ0THppdWhzNEtyMjhnalRzVndkbUdudHFXdVp4RDgxRUhieEhydmxocklIUUZNb0tlMmtaeEI4OXhGbkxoNHZHUFJNMFVKMGc=",
|
||||||
|
CITYID: '330100',
|
||||||
|
USERCITYID: '440100'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 选择用户并跳转到首页(携带参数) - 模拟建行生活跳转
|
||||||
|
const selectUser = (userId) => {
|
||||||
|
console.log(`[MockLogin] 选择用户${userId}`);
|
||||||
|
|
||||||
|
const user = users[userId];
|
||||||
|
|
||||||
|
if (!user) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '用户数据错误',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`[MockLogin] 模拟建行生活跳转,携带用户${userId}的参数`);
|
||||||
|
console.log(`[MockLogin] 用户信息:`, user);
|
||||||
|
|
||||||
|
// 构造完整的URL参数串(按照建行文档格式)
|
||||||
|
// 格式:url?platform=ccblife&channel=mbs&ccbParamSJ=xxxxxx&CITYID=330100&USERCITYID=440100
|
||||||
|
const params = new URLSearchParams(user.params);
|
||||||
|
|
||||||
|
// #ifdef H5
|
||||||
|
// H5环境:直接修改URL并刷新整个应用(模拟建行App跳转)
|
||||||
|
const baseUrl = window.location.origin + window.location.pathname;
|
||||||
|
const newUrl = `${baseUrl}?${params.toString()}#/pages/index/index`;
|
||||||
|
|
||||||
|
console.log('[MockLogin] 完整跳转URL:', newUrl);
|
||||||
|
console.log('[MockLogin] 参数详情:', {
|
||||||
|
platform: user.params.platform,
|
||||||
|
channel: user.params.channel,
|
||||||
|
ccbParamSJ: user.params.ccbParamSJ.substring(0, 50) + '...',
|
||||||
|
CITYID: user.params.CITYID,
|
||||||
|
USERCITYID: user.params.USERCITYID
|
||||||
|
});
|
||||||
|
|
||||||
|
// 显示提示
|
||||||
|
uni.showToast({
|
||||||
|
title: '正在跳转...',
|
||||||
|
icon: 'loading',
|
||||||
|
duration: 500
|
||||||
|
});
|
||||||
|
|
||||||
|
// 延迟跳转,让用户看到提示
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.href = newUrl;
|
||||||
|
}, 500);
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
// #ifndef H5
|
||||||
|
// 非H5环境:使用uni.reLaunch
|
||||||
|
uni.reLaunch({
|
||||||
|
url: `/pages/index/index?${params.toString()}`
|
||||||
|
});
|
||||||
|
// #endif
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.mock-login-page {
|
||||||
|
min-height: 100vh;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
padding: 40rpx 30rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 80rpx;
|
||||||
|
margin-top: 80rpx;
|
||||||
|
|
||||||
|
.title {
|
||||||
|
display: block;
|
||||||
|
font-size: 48rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #ffffff;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subtitle {
|
||||||
|
display: block;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-list {
|
||||||
|
.user-card {
|
||||||
|
background: #ffffff;
|
||||||
|
border-radius: 20rpx;
|
||||||
|
padding: 30rpx;
|
||||||
|
margin-bottom: 30rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
box-shadow: 0 8rpx 20rpx rgba(0, 0, 0, 0.1);
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
transform: scale(0.98);
|
||||||
|
box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-avatar {
|
||||||
|
width: 100rpx;
|
||||||
|
height: 100rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
overflow: hidden;
|
||||||
|
margin-right: 30rpx;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
|
.avatar-text {
|
||||||
|
font-size: 44rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-avatar-2 {
|
||||||
|
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-info {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
.user-name {
|
||||||
|
font-size: 32rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #333333;
|
||||||
|
margin-bottom: 10rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-mobile {
|
||||||
|
font-size: 26rpx;
|
||||||
|
color: #666666;
|
||||||
|
margin-bottom: 8rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-id {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #999999;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.arrow {
|
||||||
|
width: 40rpx;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
.arrow-icon {
|
||||||
|
font-size: 40rpx;
|
||||||
|
color: #999999;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.tips {
|
||||||
|
margin-top: 60rpx;
|
||||||
|
padding: 30rpx;
|
||||||
|
background: rgba(255, 255, 255, 0.2);
|
||||||
|
border-radius: 16rpx;
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
|
||||||
|
.tips-text {
|
||||||
|
display: block;
|
||||||
|
font-size: 26rpx;
|
||||||
|
color: #ffffff;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 1.6;
|
||||||
|
margin-bottom: 16rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tips-detail {
|
||||||
|
display: block;
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.85);
|
||||||
|
text-align: center;
|
||||||
|
line-height: 1.5;
|
||||||
|
margin-bottom: 8rpx;
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
@ -48,8 +48,8 @@ const CcbLifePlatform = {
|
|||||||
// 如果在建行App内,初始化JSBridge
|
// 如果在建行App内,初始化JSBridge
|
||||||
if (this.isInCcbApp) {
|
if (this.isInCcbApp) {
|
||||||
this.setupBridge();
|
this.setupBridge();
|
||||||
// 自动登录
|
// ⚠️ 自动登录已禁用,改用App.vue中的checkCCBLogin统一处理
|
||||||
this.autoLogin();
|
// this.autoLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('[CcbLife] 初始化完成, 是否在建行App内:', this.isInCcbApp);
|
console.log('[CcbLife] 初始化完成, 是否在建行App内:', this.isInCcbApp);
|
||||||
@ -490,8 +490,14 @@ const CcbLifePlatform = {
|
|||||||
/**
|
/**
|
||||||
* 处理URL跳转登录
|
* 处理URL跳转登录
|
||||||
* 建行App通过URL携带加密参数跳转到H5时调用
|
* 建行App通过URL携带加密参数跳转到H5时调用
|
||||||
|
*
|
||||||
|
* ⚠️ 注意:此方法已禁用,改用App.vue中的checkCCBLogin统一处理
|
||||||
|
* 原因:App.vue实现了更完善的逻辑(ccbParamSJ比较、用户切换、防重复调用)
|
||||||
*/
|
*/
|
||||||
async handleUrlLogin() {
|
async handleUrlLogin() {
|
||||||
|
console.log('[CcbLife] handleUrlLogin被调用,但已禁用(改用App.vue统一处理)');
|
||||||
|
return; // 🔒 禁用此方法,避免与App.vue重复调用
|
||||||
|
|
||||||
const params = this.getUrlParams();
|
const params = this.getUrlParams();
|
||||||
|
|
||||||
// 如果有ccbParamSJ参数,说明是从建行跳转过来的
|
// 如果有ccbParamSJ参数,说明是从建行跳转过来的
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user