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)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取团队成员工作统计
|
||||
* @returns {Promise} 返回工作统计数据
|
||||
*/
|
||||
export function getTeamMemberWorkStatistics(dataType, memberId) {
|
||||
return get(`/team/member/work/statistics-now?dataType=${dataType}&memberId=${memberId}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化时间戳为可读格式
|
||||
* @param {number} timestamp - 时间戳(毫秒)
|
||||
|
||||
@ -95,7 +95,7 @@ export function connectApplication(renderFun) {
|
||||
|
||||
try {
|
||||
if (ios()) {
|
||||
console.log('ios access detected')
|
||||
console.debug('ios access detected')
|
||||
// iOS可能需要特殊处理,这里先使用通用方法
|
||||
if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.getAccessOrigin) {
|
||||
window.webkit.messageHandlers.getAccessOrigin.postMessage({})
|
||||
@ -103,17 +103,17 @@ export function connectApplication(renderFun) {
|
||||
renderFun(window.app.getAccessOrigin())
|
||||
}
|
||||
} else if (android()) {
|
||||
console.log('Flutter Android WebView 检测')
|
||||
console.log('window.app 对象:', window.app)
|
||||
console.debug('Flutter Android WebView 检测')
|
||||
console.debug('window.app 对象:', window.app)
|
||||
|
||||
// 检查Flutter注入的接口
|
||||
if (window.app) {
|
||||
console.log('window.app 的所有方法:')
|
||||
console.log(Object.keys(window.app))
|
||||
console.debug('window.app 的所有方法:')
|
||||
console.debug(Object.keys(window.app))
|
||||
|
||||
// 检查具体的方法
|
||||
console.log('getAccessOrigin 方法存在?', typeof window.app.getAccessOrigin)
|
||||
console.log('getAccessOrigin 是函数?', typeof window.app.getAccessOrigin === 'function')
|
||||
console.debug('getAccessOrigin 方法存在?', typeof window.app.getAccessOrigin)
|
||||
console.debug('getAccessOrigin 是函数?', typeof window.app.getAccessOrigin === 'function')
|
||||
}
|
||||
|
||||
// 等待Flutter注入完成
|
||||
@ -123,13 +123,13 @@ export function connectApplication(renderFun) {
|
||||
|
||||
const checkInterface = () => {
|
||||
attempts++;
|
||||
console.log(`尝试第 ${attempts} 次检查Flutter接口...`)
|
||||
console.debug(`尝试第 ${attempts} 次检查Flutter接口...`)
|
||||
|
||||
if (window.app && window.app.getAccessOrigin && typeof window.app.getAccessOrigin === 'function') {
|
||||
console.log('Flutter接口检测成功,调用 getAccessOrigin')
|
||||
console.debug('Flutter接口检测成功,调用 getAccessOrigin')
|
||||
try {
|
||||
const result = window.app.getAccessOrigin()
|
||||
console.log('getAccessOrigin 返回结果:', result)
|
||||
console.debug('getAccessOrigin 返回结果:', result)
|
||||
renderFun(result)
|
||||
} catch (error) {
|
||||
console.error('调用 getAccessOrigin 出错:', error)
|
||||
@ -157,13 +157,13 @@ export function connectApplication(renderFun) {
|
||||
if (window.app) {
|
||||
waitForFlutterInterface()
|
||||
} else {
|
||||
console.log('等待Flutter注入window.app...')
|
||||
console.debug('等待Flutter注入window.app...')
|
||||
// 监听window.app的创建
|
||||
let checkCount = 0
|
||||
const checkApp = () => {
|
||||
checkCount++
|
||||
if (window.app) {
|
||||
console.log('检测到window.app,开始连接')
|
||||
console.debug('检测到window.app,开始连接')
|
||||
waitForFlutterInterface()
|
||||
} else if (checkCount < 50) {
|
||||
setTimeout(checkApp, 100)
|
||||
@ -178,7 +178,7 @@ export function connectApplication(renderFun) {
|
||||
checkApp()
|
||||
}
|
||||
} else {
|
||||
console.log('非移动设备环境')
|
||||
console.debug('非移动设备环境')
|
||||
// 非APP环境,可能是浏览器调试
|
||||
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.log('🔑 Authorization token set:', headerInfo.authorization)
|
||||
console.log('🌍 Language set:', headerInfo.reqLang)
|
||||
console.log('📱 App info:', {
|
||||
console.debug('🔑 Authorization token set:', headerInfo.authorization)
|
||||
console.debug('🌍 Language set:', headerInfo.reqLang)
|
||||
console.debug('📱 App info:', {
|
||||
version: headerInfo.appVersion,
|
||||
build: headerInfo.buildVersion,
|
||||
channel: headerInfo.appChannel,
|
||||
|
||||
@ -33,7 +33,7 @@ export function updateCommonHeaders(headers) {
|
||||
...COMMON_HEADERS,
|
||||
...headers
|
||||
}
|
||||
console.log('🔄 Updated common headers:', COMMON_HEADERS)
|
||||
console.debug('🔄 Updated common headers:', COMMON_HEADERS)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -7,21 +7,21 @@
|
||||
<div class="search-section">
|
||||
<div class="search-box">
|
||||
<span class="search-icon">🔍</span>
|
||||
<input
|
||||
<input
|
||||
v-model="searchQuery"
|
||||
type="text"
|
||||
type="text"
|
||||
placeholder="Please enter the host ID"
|
||||
class="search-input"
|
||||
@keyup.enter="performSearch"
|
||||
/>
|
||||
<button
|
||||
v-if="searchQuery"
|
||||
<button
|
||||
v-if="searchQuery"
|
||||
@click="clearSearch"
|
||||
class="clear-btn"
|
||||
>
|
||||
×
|
||||
</button>
|
||||
<button
|
||||
<button
|
||||
class="action-btn"
|
||||
@click="searchQuery ? confirmUser : cancelSearch"
|
||||
>
|
||||
@ -32,17 +32,17 @@
|
||||
|
||||
<!-- 搜索结果 -->
|
||||
<div v-if="searchResults.length > 0" class="results-section">
|
||||
<div
|
||||
v-for="user in searchResults"
|
||||
<div
|
||||
v-for="user in searchResults"
|
||||
:key="user.id"
|
||||
class="user-item"
|
||||
@click="selectUser(user)"
|
||||
>
|
||||
<div class="user-info">
|
||||
<div class="user-avatar">
|
||||
<img
|
||||
v-if="user.userAvatar"
|
||||
:src="user.userAvatar"
|
||||
<img
|
||||
v-if="user.userAvatar"
|
||||
:src="user.userAvatar"
|
||||
:alt="user.name"
|
||||
class="avatar-image"
|
||||
@error="(e) => e.target.style.display = 'none'"
|
||||
@ -102,7 +102,7 @@ const mockUsers = [
|
||||
name: 'User1'
|
||||
},
|
||||
{
|
||||
id: '0987654321',
|
||||
id: '0987654321',
|
||||
name: 'Alice Johnson'
|
||||
},
|
||||
{
|
||||
@ -119,10 +119,10 @@ const performSearch = async () => {
|
||||
}
|
||||
|
||||
isSearching.value = true
|
||||
|
||||
|
||||
try {
|
||||
const response = await searchFreightUser(searchQuery.value.trim())
|
||||
|
||||
|
||||
if (response && response.status && response.body && response.body.userProfile) {
|
||||
const profile = response.body.userProfile
|
||||
searchResults.value = [{
|
||||
@ -175,9 +175,7 @@ const selectUser = (user) => {
|
||||
account: user.account,
|
||||
userAvatar: user.userAvatar
|
||||
})
|
||||
|
||||
console.log('Selected user:', user)
|
||||
|
||||
|
||||
// 返回上一页
|
||||
router.go(-1)
|
||||
}
|
||||
|
||||
@ -187,7 +187,6 @@ const fetchFreightBalance = async () => {
|
||||
|
||||
// 处理头像加载错误
|
||||
const handleAvatarError = () => {
|
||||
console.log('头像加载失败,使用默认显示')
|
||||
userInfo.value.userAvatar = null
|
||||
}
|
||||
|
||||
|
||||
@ -103,11 +103,10 @@ const checkUserRole = async () => {
|
||||
|
||||
try {
|
||||
const response = await userSalaryCheckExchange()
|
||||
console.log('sssss', response)
|
||||
if (response.status && response.body) {
|
||||
// 根据接口返回的role设置用户角色
|
||||
userRole.value = response.body.role || ''
|
||||
console.log('用户角色:', userRole.value)
|
||||
console.debug('用户角色:', userRole.value)
|
||||
|
||||
// 设置默认的用户类型
|
||||
if (userRole.value === 'TEAM_OWN') {
|
||||
@ -172,7 +171,6 @@ const exchangeCoins = async () => {
|
||||
amount: selectedCoinData.price,
|
||||
price: selectedCoinData.price
|
||||
})
|
||||
console.log('res', response)
|
||||
|
||||
if (response.status === true || response.errorCode === 0) {
|
||||
alert(`Successfully exchanged ${selectedCoinData.amount} coins for $${selectedCoinData.price}`)
|
||||
|
||||
@ -128,9 +128,9 @@
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
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 { setUserInfo } from '../utils/userStore.js'
|
||||
import {getUserId, setUserInfo} from '../utils/userStore.js'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
@ -145,27 +145,27 @@ const identityChecked = ref(false)
|
||||
// 连接APP并获取认证信息
|
||||
const connectToApp = async () => {
|
||||
console.group('🔗 APP Connection Process')
|
||||
console.log('🚀 Starting APP connection...')
|
||||
console.debug('🚀 Starting APP connection...')
|
||||
|
||||
if (!isInApp()) {
|
||||
console.warn('⚠️ Not running in APP environment')
|
||||
console.log('🌐 Browser environment detected')
|
||||
console.log('📱 APP Bridge objects:')
|
||||
console.log(' - window.app:', !!window.app)
|
||||
console.log(' - window.webkit:', !!window.webkit)
|
||||
console.debug('🌐 Browser environment detected')
|
||||
console.debug('📱 APP Bridge objects:')
|
||||
console.debug(' - window.app:', !!window.app)
|
||||
console.debug(' - window.webkit:', !!window.webkit)
|
||||
|
||||
// 非APP环境,直接执行后续逻辑
|
||||
appConnected.value = true
|
||||
console.log('✅ Skipping APP connection, proceeding with team entry')
|
||||
console.debug('✅ Skipping APP connection, proceeding with team entry')
|
||||
await fetchTeamEntry()
|
||||
console.groupEnd()
|
||||
return
|
||||
}
|
||||
|
||||
console.log('📱 APP environment detected')
|
||||
console.log('🔍 Checking APP bridge availability:')
|
||||
console.log(' - window.app:', !!window.app)
|
||||
console.log(' - window.webkit:', !!window.webkit)
|
||||
console.debug('📱 APP environment detected')
|
||||
console.debug('🔍 Checking APP bridge availability:')
|
||||
console.debug(' - window.app:', !!window.app)
|
||||
console.debug(' - window.webkit:', !!window.webkit)
|
||||
|
||||
connectApplication(async (access) => {
|
||||
const result = parseAccessOrigin(access)
|
||||
@ -175,28 +175,28 @@ const connectToApp = async () => {
|
||||
headerInfo.value = parseHeader(result.data)
|
||||
|
||||
// 设置HTTP请求头
|
||||
console.log('🔧 Setting HTTP headers...')
|
||||
console.debug('🔧 Setting HTTP headers...')
|
||||
setHttpHeaders(headerInfo.value)
|
||||
|
||||
// 标记连接成功
|
||||
appConnected.value = true
|
||||
|
||||
console.log('🎉 APP connection established successfully')
|
||||
console.debug('🎉 APP connection established successfully')
|
||||
|
||||
// 连接成功后获取团队信息和银行余额
|
||||
console.log('📊 Fetching team entry and bank balance...')
|
||||
try {
|
||||
await fetchTeamEntry()
|
||||
console.log('✅ Team entry fetched')
|
||||
console.debug('📊 Fetching team entry and bank balance...')
|
||||
const teamEntryResult = await fetchTeamEntry()
|
||||
console.debug('✅ Team entry fetched')
|
||||
if (teamEntryResult != null) {
|
||||
await fetchBankBalance()
|
||||
console.debug('✅ Bank balance fetch initiated')
|
||||
|
||||
fetchBankBalance()
|
||||
console.log('✅ Bank balance fetch initiated')
|
||||
} catch (error) {
|
||||
console.error('❌ Error in post-connection operations:', error)
|
||||
await fetchWorkStatistics()
|
||||
console.debug('✅ Work statistics fetch initiated')
|
||||
}
|
||||
} else {
|
||||
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 }})
|
||||
}
|
||||
@ -204,7 +204,7 @@ const connectToApp = async () => {
|
||||
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({
|
||||
name: 'User1',
|
||||
@ -301,7 +317,14 @@ const fetchTeamEntry = async () => {
|
||||
console.error('获取团队信息失败:', error)
|
||||
// HTTP 406错误通常表示NOT_TEAM_MEMBER
|
||||
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
|
||||
}
|
||||
}
|
||||
@ -317,7 +340,7 @@ const checkUserIdentity = async (userId) => {
|
||||
|
||||
// 防止重复检查
|
||||
if (identityChecked.value) {
|
||||
console.log('身份已检查,跳过')
|
||||
console.debug('身份已检查,跳过')
|
||||
return
|
||||
}
|
||||
|
||||
@ -328,22 +351,22 @@ const checkUserIdentity = async (userId) => {
|
||||
if (response && response.status && response.body) {
|
||||
const { freightAgent, anchor, agent } = response.body
|
||||
|
||||
console.log('用户身份权限:', { freightAgent, anchor, agent })
|
||||
console.debug('用户身份权限:', { freightAgent, anchor, agent })
|
||||
|
||||
// 根据优先级判断:freightAgent > anchor > agent
|
||||
if (freightAgent) {
|
||||
console.log('跳转到 coin-seller')
|
||||
console.debug('跳转到 coin-seller')
|
||||
router.replace('/coin-seller')
|
||||
} else if (agent) {
|
||||
console.log('跳转到 agency-center')
|
||||
console.debug('跳转到 agency-center')
|
||||
router.replace('/agency-center')
|
||||
} else if (anchor) {
|
||||
// 保持在当前Host页面
|
||||
console.log('保持在 host-center')
|
||||
console.debug('保持在 host-center')
|
||||
currentIdentity.value = 'host'
|
||||
} else {
|
||||
// 如果没有任何权限,默认保持在Host页面
|
||||
console.log('无特殊权限,保持在 host-center')
|
||||
console.debug('无特殊权限,保持在 host-center')
|
||||
currentIdentity.value = 'host'
|
||||
}
|
||||
}
|
||||
@ -367,6 +390,12 @@ const transfer = () => {
|
||||
onMounted(async () => {
|
||||
// 先连接APP获取认证信息
|
||||
await connectToApp()
|
||||
|
||||
// 如果不是APP环境,直接获取数据
|
||||
if (!isInApp()) {
|
||||
await fetchBankBalance()
|
||||
await fetchWorkStatistics()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@ -9,8 +9,8 @@
|
||||
<div v-if="!isLoadingRole && availableUserTypes.length > 1" class="user-type-selector">
|
||||
<label>搜索类型:</label>
|
||||
<div class="type-buttons">
|
||||
<button
|
||||
v-for="type in availableUserTypes"
|
||||
<button
|
||||
v-for="type in availableUserTypes"
|
||||
:key="type.value"
|
||||
@click="selectedUserType = type.value"
|
||||
:class="['type-btn', { active: selectedUserType === type.value }]"
|
||||
@ -19,16 +19,16 @@
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="search-box">
|
||||
<input
|
||||
<input
|
||||
v-model="searchQuery"
|
||||
type="text"
|
||||
type="text"
|
||||
placeholder="Search by ID or name"
|
||||
class="search-input"
|
||||
@keyup.enter="performSearch"
|
||||
/>
|
||||
<button
|
||||
<button
|
||||
v-if="searchQuery"
|
||||
@click="clearSearch"
|
||||
class="clear-btn"
|
||||
@ -49,8 +49,8 @@
|
||||
|
||||
<!-- 搜索结果 -->
|
||||
<div v-else-if="searchResults.length > 0" class="results-section">
|
||||
<div
|
||||
v-for="user in searchResults"
|
||||
<div
|
||||
v-for="user in searchResults"
|
||||
:key="user.id"
|
||||
class="user-item"
|
||||
>
|
||||
@ -217,15 +217,14 @@ const availableUserTypes = computed(() => {
|
||||
// 检查用户转账角色
|
||||
const checkUserRole = async () => {
|
||||
isLoadingRole.value = true
|
||||
|
||||
|
||||
try {
|
||||
const response = await userBankCheckTransfer()
|
||||
|
||||
|
||||
if (response.status && response.body) {
|
||||
// 根据接口返回的role设置用户角色
|
||||
userRole.value = response.body.role || ''
|
||||
console.log('用户角色:', userRole.value)
|
||||
|
||||
|
||||
// 设置默认的用户类型
|
||||
if (userRole.value === 'TEAM_OWN') {
|
||||
selectedUserType.value = 'ANCHOR' // TEAM_OWN 默认选择 ANCHOR
|
||||
@ -258,10 +257,10 @@ const performSearch = async () => {
|
||||
}
|
||||
|
||||
isSearching.value = true
|
||||
|
||||
|
||||
try {
|
||||
const response = await userBankSearchUserProfile(selectedUserType.value, searchQuery.value.trim())
|
||||
|
||||
|
||||
if (response.status && response.body) {
|
||||
// 根据新的API返回数据结构进行映射
|
||||
const user = {
|
||||
@ -312,9 +311,7 @@ const selectUser = (user) => {
|
||||
isAgency: user.isAgency,
|
||||
hasSalary: user.hasSalary
|
||||
})
|
||||
|
||||
console.log('Selected payee:', user)
|
||||
|
||||
|
||||
// 返回到 Transfer 页面
|
||||
router.push('/transfer')
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user