日志恢复
This commit is contained in:
parent
7edae63a8b
commit
cc83356a21
@ -44,11 +44,11 @@ const route = useRoute()
|
||||
const handleBack = () => {
|
||||
if (props.isHomePage && isInApp()) {
|
||||
// 首页且在APP中:关闭页面
|
||||
console.debug('首页返回:关闭页面')
|
||||
console.log('首页返回:关闭页面')
|
||||
closePage()
|
||||
} else {
|
||||
// 非首页或浏览器环境:正常返回
|
||||
console.debug('正常返回')
|
||||
console.log('正常返回')
|
||||
router.go(-1)
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ export function connectApplication(renderFun) {
|
||||
|
||||
try {
|
||||
if (ios()) {
|
||||
console.debug('ios access detected')
|
||||
console.log('ios access detected')
|
||||
// iOS可能需要特殊处理,这里先使用通用方法
|
||||
if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.getAccessOrigin) {
|
||||
window.webkit.messageHandlers.getAccessOrigin.postMessage({})
|
||||
@ -101,17 +101,17 @@ export function connectApplication(renderFun) {
|
||||
renderFun(window.app.getAccessOrigin())
|
||||
}
|
||||
} else if (android()) {
|
||||
console.debug('Flutter Android WebView 检测')
|
||||
console.debug('window.app 对象:', window.app)
|
||||
console.log('Flutter Android WebView 检测')
|
||||
console.log('window.app 对象:', window.app)
|
||||
|
||||
// 检查Flutter注入的接口
|
||||
if (window.app) {
|
||||
console.debug('window.app 的所有方法:')
|
||||
console.debug(Object.keys(window.app))
|
||||
console.log('window.app 的所有方法:')
|
||||
console.log(Object.keys(window.app))
|
||||
|
||||
// 检查具体的方法
|
||||
console.debug('getAccessOrigin 方法存在?', typeof window.app.getAccessOrigin)
|
||||
console.debug('getAccessOrigin 是函数?', typeof window.app.getAccessOrigin === 'function')
|
||||
console.log('getAccessOrigin 方法存在?', typeof window.app.getAccessOrigin)
|
||||
console.log('getAccessOrigin 是函数?', typeof window.app.getAccessOrigin === 'function')
|
||||
}
|
||||
|
||||
// 等待Flutter注入完成
|
||||
@ -121,13 +121,13 @@ export function connectApplication(renderFun) {
|
||||
|
||||
const checkInterface = () => {
|
||||
attempts++;
|
||||
console.debug(`尝试第 ${attempts} 次检查Flutter接口...`)
|
||||
console.log(`尝试第 ${attempts} 次检查Flutter接口...`)
|
||||
|
||||
if (window.app && window.app.getAccessOrigin && typeof window.app.getAccessOrigin === 'function') {
|
||||
console.debug('Flutter接口检测成功,调用 getAccessOrigin')
|
||||
console.log('Flutter接口检测成功,调用 getAccessOrigin')
|
||||
try {
|
||||
const result = window.app.getAccessOrigin()
|
||||
console.debug('getAccessOrigin 返回结果:', result)
|
||||
console.log('getAccessOrigin 返回结果:', result)
|
||||
renderFun(result)
|
||||
} catch (error) {
|
||||
console.error('调用 getAccessOrigin 出错:', error)
|
||||
@ -155,13 +155,13 @@ export function connectApplication(renderFun) {
|
||||
if (window.app) {
|
||||
waitForFlutterInterface()
|
||||
} else {
|
||||
console.debug('等待Flutter注入window.app...')
|
||||
console.log('等待Flutter注入window.app...')
|
||||
// 监听window.app的创建
|
||||
let checkCount = 0
|
||||
const checkApp = () => {
|
||||
checkCount++
|
||||
if (window.app) {
|
||||
console.debug('检测到window.app,开始连接')
|
||||
console.log('检测到window.app,开始连接')
|
||||
waitForFlutterInterface()
|
||||
} else if (checkCount < 50) {
|
||||
setTimeout(checkApp, 100)
|
||||
@ -176,7 +176,7 @@ export function connectApplication(renderFun) {
|
||||
checkApp()
|
||||
}
|
||||
} else {
|
||||
console.debug('非移动设备环境')
|
||||
console.log('非移动设备环境')
|
||||
// 非APP环境,可能是浏览器调试
|
||||
console.warn('Not in APP environment, using mock data for development')
|
||||
// 开发环境可以提供模拟数据
|
||||
@ -278,9 +278,9 @@ export function setHttpHeaders(headerInfo) {
|
||||
console.error('Failed to update HTTP headers:', error)
|
||||
})
|
||||
|
||||
console.debug('🔑 Authorization token set:', headerInfo.authorization)
|
||||
console.debug('🌍 Language set:', headerInfo.reqLang)
|
||||
console.debug('📱 App info:', {
|
||||
console.log('🔑 Authorization token set:', headerInfo.authorization)
|
||||
console.log('🌍 Language set:', headerInfo.reqLang)
|
||||
console.log('📱 App info:', {
|
||||
version: headerInfo.appVersion,
|
||||
build: headerInfo.buildVersion,
|
||||
channel: headerInfo.appChannel,
|
||||
|
||||
@ -155,74 +155,74 @@ const identities = [
|
||||
// 连接APP并获取认证信息
|
||||
const connectToApp = async () => {
|
||||
console.group('🔗 APP Connection Process')
|
||||
console.debug('🚀 Starting APP connection...')
|
||||
console.log('🚀 Starting APP connection...')
|
||||
|
||||
if (!isInApp()) {
|
||||
console.warn('⚠️ Not running in APP environment')
|
||||
console.debug('🌐 Browser environment detected')
|
||||
console.debug('📱 APP Bridge objects:')
|
||||
console.debug(' - window.app:', !!window.app)
|
||||
console.debug(' - window.webkit:', !!window.webkit)
|
||||
console.log('🌐 Browser environment detected')
|
||||
console.log('📱 APP Bridge objects:')
|
||||
console.log(' - window.app:', !!window.app)
|
||||
console.log(' - window.webkit:', !!window.webkit)
|
||||
|
||||
// 非APP环境,直接执行后续逻辑
|
||||
appConnected.value = true
|
||||
console.debug('✅ Skipping APP connection, proceeding with team entry')
|
||||
console.log('✅ Skipping APP connection, proceeding with team entry')
|
||||
await fetchTeamEntry()
|
||||
console.groupEnd()
|
||||
return
|
||||
}
|
||||
|
||||
console.debug('📱 APP environment detected')
|
||||
console.debug('🔍 Checking APP bridge availability:')
|
||||
console.debug(' - window.app:', !!window.app)
|
||||
console.debug(' - window.webkit:', !!window.webkit)
|
||||
console.log('📱 APP environment detected')
|
||||
console.log('🔍 Checking APP bridge availability:')
|
||||
console.log(' - window.app:', !!window.app)
|
||||
console.log(' - window.webkit:', !!window.webkit)
|
||||
|
||||
connectApplication(async (access) => {
|
||||
console.debug('📥 Received data from APP:')
|
||||
console.debug(' - Data type:', typeof access)
|
||||
console.debug(' - Data length:', access ? access.length : 0)
|
||||
console.debug(' - Raw data:', access)
|
||||
console.log('📥 Received data from APP:')
|
||||
console.log(' - Data type:', typeof access)
|
||||
console.log(' - Data length:', access ? access.length : 0)
|
||||
console.log(' - Raw data:', access)
|
||||
|
||||
const result = parseAccessOrigin(access)
|
||||
console.debug('🔍 Parsing result:')
|
||||
console.debug(' - Success:', result.success)
|
||||
console.log('🔍 Parsing result:')
|
||||
console.log(' - Success:', result.success)
|
||||
|
||||
if (result.success) {
|
||||
console.debug('✅ Access data parsed successfully')
|
||||
console.log('✅ Access data parsed successfully')
|
||||
|
||||
// 解析头部信息
|
||||
headerInfo.value = parseHeader(result.data)
|
||||
console.debug('📋 Parsed header info:')
|
||||
console.debug(' - Authorization:', headerInfo.value.authorization ? '✅ Present' : '❌ Missing')
|
||||
console.debug(' - Language:', headerInfo.value.reqLang)
|
||||
console.debug(' - App Version:', headerInfo.value.appVersion)
|
||||
console.debug(' - Build Version:', headerInfo.value.buildVersion)
|
||||
console.debug(' - System Origin:', headerInfo.value.sysOrigin)
|
||||
console.debug(' - Device ID:', headerInfo.value.reqImei ? '✅ Present' : '❌ Missing')
|
||||
console.log('📋 Parsed header info:')
|
||||
console.log(' - Authorization:', headerInfo.value.authorization ? '✅ Present' : '❌ Missing')
|
||||
console.log(' - Language:', headerInfo.value.reqLang)
|
||||
console.log(' - App Version:', headerInfo.value.appVersion)
|
||||
console.log(' - Build Version:', headerInfo.value.buildVersion)
|
||||
console.log(' - System Origin:', headerInfo.value.sysOrigin)
|
||||
console.log(' - Device ID:', headerInfo.value.reqImei ? '✅ Present' : '❌ Missing')
|
||||
|
||||
// 设置HTTP请求头
|
||||
console.debug('🔧 Setting HTTP headers...')
|
||||
console.log('🔧 Setting HTTP headers...')
|
||||
setHttpHeaders(headerInfo.value)
|
||||
|
||||
// 标记连接成功
|
||||
appConnected.value = true
|
||||
|
||||
console.debug('🎉 APP connection established successfully')
|
||||
console.log('🎉 APP connection established successfully')
|
||||
|
||||
// 连接成功后获取团队信息和银行余额
|
||||
console.debug('📊 Fetching team entry and bank balance...')
|
||||
console.log('📊 Fetching team entry and bank balance...')
|
||||
try {
|
||||
await fetchTeamEntry()
|
||||
console.debug('✅ Team entry fetched')
|
||||
console.log('✅ Team entry fetched')
|
||||
|
||||
fetchBankBalance()
|
||||
console.debug('✅ Bank balance fetch initiated')
|
||||
console.log('✅ Bank balance fetch initiated')
|
||||
} catch (error) {
|
||||
console.error('❌ Error in post-connection operations:', error)
|
||||
}
|
||||
} else {
|
||||
console.error('❌ Failed to parse access origin:', result.error)
|
||||
console.debug('🔄 Redirecting to error page...')
|
||||
console.log('🔄 Redirecting to error page...')
|
||||
// 可以显示错误提示或跳转到错误页面
|
||||
router.push({ path: '/not_app', query: { message: result.error }})
|
||||
}
|
||||
@ -230,7 +230,7 @@ const connectToApp = async () => {
|
||||
console.groupEnd()
|
||||
})
|
||||
|
||||
console.debug('⏳ Waiting for APP response...')
|
||||
console.log('⏳ Waiting for APP response...')
|
||||
}
|
||||
|
||||
// 获取银行余额
|
||||
@ -335,7 +335,7 @@ const checkUserIdentity = async (userId) => {
|
||||
|
||||
// 防止重复检查
|
||||
if (identityChecked.value) {
|
||||
console.debug('身份已检查,跳过')
|
||||
console.log('身份已检查,跳过')
|
||||
return
|
||||
}
|
||||
|
||||
@ -346,22 +346,22 @@ const checkUserIdentity = async (userId) => {
|
||||
if (response && response.status && response.body) {
|
||||
const { freightAgent, anchor, agent } = response.body
|
||||
|
||||
console.debug('用户身份权限:', { freightAgent, anchor, agent })
|
||||
console.log('用户身份权限:', { freightAgent, anchor, agent })
|
||||
|
||||
// 根据优先级判断:freightAgent > anchor > agent
|
||||
if (freightAgent) {
|
||||
console.debug('跳转到 coin-seller')
|
||||
console.log('跳转到 coin-seller')
|
||||
router.replace('/coin-seller')
|
||||
} else if (anchor) {
|
||||
console.debug('跳转到 agency-center')
|
||||
console.log('跳转到 agency-center')
|
||||
router.replace('/agency-center')
|
||||
} else if (agent) {
|
||||
// 保持在当前Host页面
|
||||
console.debug('保持在 host-center')
|
||||
console.log('保持在 host-center')
|
||||
currentIdentity.value = 'host'
|
||||
} else {
|
||||
// 如果没有任何权限,默认保持在Host页面
|
||||
console.debug('无特殊权限,保持在 host-center')
|
||||
console.log('无特殊权限,保持在 host-center')
|
||||
currentIdentity.value = 'host'
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user