console.log处理
This commit is contained in:
parent
b45bb649f1
commit
a45e34c15d
@ -174,6 +174,14 @@ export function processUserApply(data) {
|
|||||||
return post('/team/process/user/apply', data)
|
return post('/team/process/user/apply', data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取团队成员工作统计
|
||||||
|
* @returns {Promise} 返回工作统计数据
|
||||||
|
*/
|
||||||
|
export function getTeamMemberWorkStatistics(dataType, memberId) {
|
||||||
|
return get(`/team/member/work/statistics-now?dataType=${dataType}&memberId=${memberId}`)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 格式化时间戳为可读格式
|
* 格式化时间戳为可读格式
|
||||||
* @param {number} timestamp - 时间戳(毫秒)
|
* @param {number} timestamp - 时间戳(毫秒)
|
||||||
|
|||||||
@ -95,7 +95,7 @@ export function connectApplication(renderFun) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (ios()) {
|
if (ios()) {
|
||||||
console.log('ios access detected')
|
console.debug('ios access detected')
|
||||||
// iOS可能需要特殊处理,这里先使用通用方法
|
// iOS可能需要特殊处理,这里先使用通用方法
|
||||||
if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.getAccessOrigin) {
|
if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.getAccessOrigin) {
|
||||||
window.webkit.messageHandlers.getAccessOrigin.postMessage({})
|
window.webkit.messageHandlers.getAccessOrigin.postMessage({})
|
||||||
@ -103,17 +103,17 @@ export function connectApplication(renderFun) {
|
|||||||
renderFun(window.app.getAccessOrigin())
|
renderFun(window.app.getAccessOrigin())
|
||||||
}
|
}
|
||||||
} else if (android()) {
|
} else if (android()) {
|
||||||
console.log('Flutter Android WebView 检测')
|
console.debug('Flutter Android WebView 检测')
|
||||||
console.log('window.app 对象:', window.app)
|
console.debug('window.app 对象:', window.app)
|
||||||
|
|
||||||
// 检查Flutter注入的接口
|
// 检查Flutter注入的接口
|
||||||
if (window.app) {
|
if (window.app) {
|
||||||
console.log('window.app 的所有方法:')
|
console.debug('window.app 的所有方法:')
|
||||||
console.log(Object.keys(window.app))
|
console.debug(Object.keys(window.app))
|
||||||
|
|
||||||
// 检查具体的方法
|
// 检查具体的方法
|
||||||
console.log('getAccessOrigin 方法存在?', typeof window.app.getAccessOrigin)
|
console.debug('getAccessOrigin 方法存在?', typeof window.app.getAccessOrigin)
|
||||||
console.log('getAccessOrigin 是函数?', typeof window.app.getAccessOrigin === 'function')
|
console.debug('getAccessOrigin 是函数?', typeof window.app.getAccessOrigin === 'function')
|
||||||
}
|
}
|
||||||
|
|
||||||
// 等待Flutter注入完成
|
// 等待Flutter注入完成
|
||||||
@ -123,13 +123,13 @@ export function connectApplication(renderFun) {
|
|||||||
|
|
||||||
const checkInterface = () => {
|
const checkInterface = () => {
|
||||||
attempts++;
|
attempts++;
|
||||||
console.log(`尝试第 ${attempts} 次检查Flutter接口...`)
|
console.debug(`尝试第 ${attempts} 次检查Flutter接口...`)
|
||||||
|
|
||||||
if (window.app && window.app.getAccessOrigin && typeof window.app.getAccessOrigin === 'function') {
|
if (window.app && window.app.getAccessOrigin && typeof window.app.getAccessOrigin === 'function') {
|
||||||
console.log('Flutter接口检测成功,调用 getAccessOrigin')
|
console.debug('Flutter接口检测成功,调用 getAccessOrigin')
|
||||||
try {
|
try {
|
||||||
const result = window.app.getAccessOrigin()
|
const result = window.app.getAccessOrigin()
|
||||||
console.log('getAccessOrigin 返回结果:', result)
|
console.debug('getAccessOrigin 返回结果:', result)
|
||||||
renderFun(result)
|
renderFun(result)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('调用 getAccessOrigin 出错:', error)
|
console.error('调用 getAccessOrigin 出错:', error)
|
||||||
@ -157,13 +157,13 @@ export function connectApplication(renderFun) {
|
|||||||
if (window.app) {
|
if (window.app) {
|
||||||
waitForFlutterInterface()
|
waitForFlutterInterface()
|
||||||
} else {
|
} else {
|
||||||
console.log('等待Flutter注入window.app...')
|
console.debug('等待Flutter注入window.app...')
|
||||||
// 监听window.app的创建
|
// 监听window.app的创建
|
||||||
let checkCount = 0
|
let checkCount = 0
|
||||||
const checkApp = () => {
|
const checkApp = () => {
|
||||||
checkCount++
|
checkCount++
|
||||||
if (window.app) {
|
if (window.app) {
|
||||||
console.log('检测到window.app,开始连接')
|
console.debug('检测到window.app,开始连接')
|
||||||
waitForFlutterInterface()
|
waitForFlutterInterface()
|
||||||
} else if (checkCount < 50) {
|
} else if (checkCount < 50) {
|
||||||
setTimeout(checkApp, 100)
|
setTimeout(checkApp, 100)
|
||||||
@ -178,7 +178,7 @@ export function connectApplication(renderFun) {
|
|||||||
checkApp()
|
checkApp()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('非移动设备环境')
|
console.debug('非移动设备环境')
|
||||||
// 非APP环境,可能是浏览器调试
|
// 非APP环境,可能是浏览器调试
|
||||||
console.warn('Not in APP environment, using mock data for development')
|
console.warn('Not in APP environment, using mock data for development')
|
||||||
// 开发环境可以提供模拟数据
|
// 开发环境可以提供模拟数据
|
||||||
@ -280,9 +280,9 @@ export function setHttpHeaders(headerInfo) {
|
|||||||
console.error('Failed to update HTTP headers:', error)
|
console.error('Failed to update HTTP headers:', error)
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log('🔑 Authorization token set:', headerInfo.authorization)
|
console.debug('🔑 Authorization token set:', headerInfo.authorization)
|
||||||
console.log('🌍 Language set:', headerInfo.reqLang)
|
console.debug('🌍 Language set:', headerInfo.reqLang)
|
||||||
console.log('📱 App info:', {
|
console.debug('📱 App info:', {
|
||||||
version: headerInfo.appVersion,
|
version: headerInfo.appVersion,
|
||||||
build: headerInfo.buildVersion,
|
build: headerInfo.buildVersion,
|
||||||
channel: headerInfo.appChannel,
|
channel: headerInfo.appChannel,
|
||||||
|
|||||||
@ -33,7 +33,7 @@ export function updateCommonHeaders(headers) {
|
|||||||
...COMMON_HEADERS,
|
...COMMON_HEADERS,
|
||||||
...headers
|
...headers
|
||||||
}
|
}
|
||||||
console.log('🔄 Updated common headers:', COMMON_HEADERS)
|
console.debug('🔄 Updated common headers:', COMMON_HEADERS)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -176,8 +176,6 @@ const selectUser = (user) => {
|
|||||||
userAvatar: user.userAvatar
|
userAvatar: user.userAvatar
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log('Selected user:', user)
|
|
||||||
|
|
||||||
// 返回上一页
|
// 返回上一页
|
||||||
router.go(-1)
|
router.go(-1)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -187,7 +187,6 @@ const fetchFreightBalance = async () => {
|
|||||||
|
|
||||||
// 处理头像加载错误
|
// 处理头像加载错误
|
||||||
const handleAvatarError = () => {
|
const handleAvatarError = () => {
|
||||||
console.log('头像加载失败,使用默认显示')
|
|
||||||
userInfo.value.userAvatar = null
|
userInfo.value.userAvatar = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -103,11 +103,10 @@ const checkUserRole = async () => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await userSalaryCheckExchange()
|
const response = await userSalaryCheckExchange()
|
||||||
console.log('sssss', response)
|
|
||||||
if (response.status && response.body) {
|
if (response.status && response.body) {
|
||||||
// 根据接口返回的role设置用户角色
|
// 根据接口返回的role设置用户角色
|
||||||
userRole.value = response.body.role || ''
|
userRole.value = response.body.role || ''
|
||||||
console.log('用户角色:', userRole.value)
|
console.debug('用户角色:', userRole.value)
|
||||||
|
|
||||||
// 设置默认的用户类型
|
// 设置默认的用户类型
|
||||||
if (userRole.value === 'TEAM_OWN') {
|
if (userRole.value === 'TEAM_OWN') {
|
||||||
@ -172,7 +171,6 @@ const exchangeCoins = async () => {
|
|||||||
amount: selectedCoinData.price,
|
amount: selectedCoinData.price,
|
||||||
price: selectedCoinData.price
|
price: selectedCoinData.price
|
||||||
})
|
})
|
||||||
console.log('res', response)
|
|
||||||
|
|
||||||
if (response.status === true || response.errorCode === 0) {
|
if (response.status === true || response.errorCode === 0) {
|
||||||
alert(`Successfully exchanged ${selectedCoinData.amount} coins for $${selectedCoinData.price}`)
|
alert(`Successfully exchanged ${selectedCoinData.amount} coins for $${selectedCoinData.price}`)
|
||||||
|
|||||||
@ -128,9 +128,9 @@
|
|||||||
import { ref, reactive, onMounted } from 'vue'
|
import { ref, reactive, onMounted } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import MobileHeader from '../components/MobileHeader.vue'
|
import MobileHeader from '../components/MobileHeader.vue'
|
||||||
import { getBankBalance, getUserIdentity, getTeamEntry } from '../api/wallet.js'
|
import { getBankBalance, getUserIdentity, getTeamEntry, getTeamMemberWorkStatistics } from '../api/wallet.js'
|
||||||
import { connectApplication, parseAccessOrigin, parseHeader, setHttpHeaders, isInApp } from '../utils/appBridge.js'
|
import { connectApplication, parseAccessOrigin, parseHeader, setHttpHeaders, isInApp } from '../utils/appBridge.js'
|
||||||
import { setUserInfo } from '../utils/userStore.js'
|
import {getUserId, setUserInfo} from '../utils/userStore.js'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
@ -145,27 +145,27 @@ const identityChecked = ref(false)
|
|||||||
// 连接APP并获取认证信息
|
// 连接APP并获取认证信息
|
||||||
const connectToApp = async () => {
|
const connectToApp = async () => {
|
||||||
console.group('🔗 APP Connection Process')
|
console.group('🔗 APP Connection Process')
|
||||||
console.log('🚀 Starting APP connection...')
|
console.debug('🚀 Starting APP connection...')
|
||||||
|
|
||||||
if (!isInApp()) {
|
if (!isInApp()) {
|
||||||
console.warn('⚠️ Not running in APP environment')
|
console.warn('⚠️ Not running in APP environment')
|
||||||
console.log('🌐 Browser environment detected')
|
console.debug('🌐 Browser environment detected')
|
||||||
console.log('📱 APP Bridge objects:')
|
console.debug('📱 APP Bridge objects:')
|
||||||
console.log(' - window.app:', !!window.app)
|
console.debug(' - window.app:', !!window.app)
|
||||||
console.log(' - window.webkit:', !!window.webkit)
|
console.debug(' - window.webkit:', !!window.webkit)
|
||||||
|
|
||||||
// 非APP环境,直接执行后续逻辑
|
// 非APP环境,直接执行后续逻辑
|
||||||
appConnected.value = true
|
appConnected.value = true
|
||||||
console.log('✅ Skipping APP connection, proceeding with team entry')
|
console.debug('✅ Skipping APP connection, proceeding with team entry')
|
||||||
await fetchTeamEntry()
|
await fetchTeamEntry()
|
||||||
console.groupEnd()
|
console.groupEnd()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('📱 APP environment detected')
|
console.debug('📱 APP environment detected')
|
||||||
console.log('🔍 Checking APP bridge availability:')
|
console.debug('🔍 Checking APP bridge availability:')
|
||||||
console.log(' - window.app:', !!window.app)
|
console.debug(' - window.app:', !!window.app)
|
||||||
console.log(' - window.webkit:', !!window.webkit)
|
console.debug(' - window.webkit:', !!window.webkit)
|
||||||
|
|
||||||
connectApplication(async (access) => {
|
connectApplication(async (access) => {
|
||||||
const result = parseAccessOrigin(access)
|
const result = parseAccessOrigin(access)
|
||||||
@ -175,28 +175,28 @@ const connectToApp = async () => {
|
|||||||
headerInfo.value = parseHeader(result.data)
|
headerInfo.value = parseHeader(result.data)
|
||||||
|
|
||||||
// 设置HTTP请求头
|
// 设置HTTP请求头
|
||||||
console.log('🔧 Setting HTTP headers...')
|
console.debug('🔧 Setting HTTP headers...')
|
||||||
setHttpHeaders(headerInfo.value)
|
setHttpHeaders(headerInfo.value)
|
||||||
|
|
||||||
// 标记连接成功
|
// 标记连接成功
|
||||||
appConnected.value = true
|
appConnected.value = true
|
||||||
|
|
||||||
console.log('🎉 APP connection established successfully')
|
console.debug('🎉 APP connection established successfully')
|
||||||
|
|
||||||
// 连接成功后获取团队信息和银行余额
|
// 连接成功后获取团队信息和银行余额
|
||||||
console.log('📊 Fetching team entry and bank balance...')
|
console.debug('📊 Fetching team entry and bank balance...')
|
||||||
try {
|
const teamEntryResult = await fetchTeamEntry()
|
||||||
await fetchTeamEntry()
|
console.debug('✅ Team entry fetched')
|
||||||
console.log('✅ Team entry fetched')
|
if (teamEntryResult != null) {
|
||||||
|
await fetchBankBalance()
|
||||||
|
console.debug('✅ Bank balance fetch initiated')
|
||||||
|
|
||||||
fetchBankBalance()
|
await fetchWorkStatistics()
|
||||||
console.log('✅ Bank balance fetch initiated')
|
console.debug('✅ Work statistics fetch initiated')
|
||||||
} catch (error) {
|
|
||||||
console.error('❌ Error in post-connection operations:', error)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.error('❌ Failed to parse access origin:', result.error)
|
console.error('❌ Failed to parse access origin:', result.error)
|
||||||
console.log('🔄 Redirecting to error page...')
|
console.debug('🔄 Redirecting to error page...')
|
||||||
// 可以显示错误提示或跳转到错误页面
|
// 可以显示错误提示或跳转到错误页面
|
||||||
router.push({ path: '/not_app', query: { message: result.error }})
|
router.push({ path: '/not_app', query: { message: result.error }})
|
||||||
}
|
}
|
||||||
@ -204,7 +204,7 @@ const connectToApp = async () => {
|
|||||||
console.groupEnd()
|
console.groupEnd()
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log('⏳ Waiting for APP response...')
|
console.debug('⏳ Waiting for APP response...')
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取银行余额
|
// 获取银行余额
|
||||||
@ -230,6 +230,22 @@ const fetchBankBalance = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取工作统计数据
|
||||||
|
const fetchWorkStatistics = async () => {
|
||||||
|
try {
|
||||||
|
const response = await getTeamMemberWorkStatistics('DAILY', getUserId())
|
||||||
|
if (response.status && response.body) {
|
||||||
|
// 更新任务信息
|
||||||
|
taskInfo.anchorType = 'Chat' // 固定值
|
||||||
|
taskInfo.minutes = `${response.body.ownTime}/120` // ownTime/120
|
||||||
|
taskInfo.giftTask = response.body.acceptGiftValue || 0 // acceptGiftValue
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取工作统计失败:', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 用户信息
|
// 用户信息
|
||||||
const userInfo = reactive({
|
const userInfo = reactive({
|
||||||
name: 'User1',
|
name: 'User1',
|
||||||
@ -301,7 +317,14 @@ const fetchTeamEntry = async () => {
|
|||||||
console.error('获取团队信息失败:', error)
|
console.error('获取团队信息失败:', error)
|
||||||
// HTTP 406错误通常表示NOT_TEAM_MEMBER
|
// HTTP 406错误通常表示NOT_TEAM_MEMBER
|
||||||
if (error.message && error.message.includes('406')) {
|
if (error.message && error.message.includes('406')) {
|
||||||
// await router.push('/apply')
|
await router.push('/apply')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (error.message && error.message.includes('401')) {
|
||||||
|
await router.push({
|
||||||
|
path: '/not_app',
|
||||||
|
query: { message: error.message }
|
||||||
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -317,7 +340,7 @@ const checkUserIdentity = async (userId) => {
|
|||||||
|
|
||||||
// 防止重复检查
|
// 防止重复检查
|
||||||
if (identityChecked.value) {
|
if (identityChecked.value) {
|
||||||
console.log('身份已检查,跳过')
|
console.debug('身份已检查,跳过')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,22 +351,22 @@ const checkUserIdentity = async (userId) => {
|
|||||||
if (response && response.status && response.body) {
|
if (response && response.status && response.body) {
|
||||||
const { freightAgent, anchor, agent } = response.body
|
const { freightAgent, anchor, agent } = response.body
|
||||||
|
|
||||||
console.log('用户身份权限:', { freightAgent, anchor, agent })
|
console.debug('用户身份权限:', { freightAgent, anchor, agent })
|
||||||
|
|
||||||
// 根据优先级判断:freightAgent > anchor > agent
|
// 根据优先级判断:freightAgent > anchor > agent
|
||||||
if (freightAgent) {
|
if (freightAgent) {
|
||||||
console.log('跳转到 coin-seller')
|
console.debug('跳转到 coin-seller')
|
||||||
router.replace('/coin-seller')
|
router.replace('/coin-seller')
|
||||||
} else if (agent) {
|
} else if (agent) {
|
||||||
console.log('跳转到 agency-center')
|
console.debug('跳转到 agency-center')
|
||||||
router.replace('/agency-center')
|
router.replace('/agency-center')
|
||||||
} else if (anchor) {
|
} else if (anchor) {
|
||||||
// 保持在当前Host页面
|
// 保持在当前Host页面
|
||||||
console.log('保持在 host-center')
|
console.debug('保持在 host-center')
|
||||||
currentIdentity.value = 'host'
|
currentIdentity.value = 'host'
|
||||||
} else {
|
} else {
|
||||||
// 如果没有任何权限,默认保持在Host页面
|
// 如果没有任何权限,默认保持在Host页面
|
||||||
console.log('无特殊权限,保持在 host-center')
|
console.debug('无特殊权限,保持在 host-center')
|
||||||
currentIdentity.value = 'host'
|
currentIdentity.value = 'host'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -367,6 +390,12 @@ const transfer = () => {
|
|||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
// 先连接APP获取认证信息
|
// 先连接APP获取认证信息
|
||||||
await connectToApp()
|
await connectToApp()
|
||||||
|
|
||||||
|
// 如果不是APP环境,直接获取数据
|
||||||
|
if (!isInApp()) {
|
||||||
|
await fetchBankBalance()
|
||||||
|
await fetchWorkStatistics()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -224,7 +224,6 @@ const checkUserRole = async () => {
|
|||||||
if (response.status && response.body) {
|
if (response.status && response.body) {
|
||||||
// 根据接口返回的role设置用户角色
|
// 根据接口返回的role设置用户角色
|
||||||
userRole.value = response.body.role || ''
|
userRole.value = response.body.role || ''
|
||||||
console.log('用户角色:', userRole.value)
|
|
||||||
|
|
||||||
// 设置默认的用户类型
|
// 设置默认的用户类型
|
||||||
if (userRole.value === 'TEAM_OWN') {
|
if (userRole.value === 'TEAM_OWN') {
|
||||||
@ -313,8 +312,6 @@ const selectUser = (user) => {
|
|||||||
hasSalary: user.hasSalary
|
hasSalary: user.hasSalary
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log('Selected payee:', user)
|
|
||||||
|
|
||||||
// 返回到 Transfer 页面
|
// 返回到 Transfer 页面
|
||||||
router.push('/transfer')
|
router.push('/transfer')
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user