bd 页面优化
This commit is contained in:
parent
6b0265dc3a
commit
1175f019cb
@ -55,8 +55,7 @@ export const ROLE_PERMISSIONS = {
|
|||||||
PAGES.TRANSFER, // 转账功能
|
PAGES.TRANSFER, // 转账功能
|
||||||
PAGES.EXCHANGE, // 兑换功能
|
PAGES.EXCHANGE, // 兑换功能
|
||||||
PAGES.MESSAGE, // 消息功能
|
PAGES.MESSAGE, // 消息功能
|
||||||
PAGES.PERSONAL_SALARY, // 个人薪资查看
|
'/team-member'
|
||||||
PAGES.AGENCY_CENTER, // 可以查看代理页面
|
|
||||||
],
|
],
|
||||||
|
|
||||||
// Anchor (主播)
|
// Anchor (主播)
|
||||||
|
|||||||
@ -83,103 +83,25 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, reactive, onMounted } from 'vue'
|
import { ref } 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 { getUserIdentity, getTeamEntry } from '../api/wallet.js'
|
import { getUserIdentity, getTeamEntry } from '../api/wallet.js'
|
||||||
import {getAgentMonthLastTarget, getAgentMonthTarget, getTeamMemberCount} from '../api/teamBill.js'
|
import {getAgentMonthLastTarget, getAgentMonthTarget, getTeamMemberCount} from '../api/teamBill.js'
|
||||||
import { connectApplication, parseAccessOrigin, parseHeader, setHttpHeaders, isInApp } from '../utils/appBridge.js'
|
|
||||||
import { setUserInfo } from '../utils/userStore.js'
|
import { setUserInfo } from '../utils/userStore.js'
|
||||||
import { get } from '../utils/http.js'
|
|
||||||
import { getTeamId } from '@/utils/userStore.js'
|
import { getTeamId } from '@/utils/userStore.js'
|
||||||
|
import {usePageInitializationWithConfig} from "@/utils/pageConfig.js";
|
||||||
|
import {isInApp} from "@/utils/appBridge.js";
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
// 当前身份
|
// 当前身份
|
||||||
const currentIdentity = ref('bd')
|
const currentIdentity = ref('bd')
|
||||||
const loading = ref(false)
|
|
||||||
const appConnected = ref(false)
|
|
||||||
const headerInfo = ref({})
|
|
||||||
const userProfile = ref(null)
|
const userProfile = ref(null)
|
||||||
const identityChecked = ref(false)
|
const identityChecked = ref(false)
|
||||||
const teamMemberCount = ref(0)
|
const teamMemberCount = ref(0)
|
||||||
const loadingMemberCount = ref(false)
|
const loadingMemberCount = ref(false)
|
||||||
|
|
||||||
// 连接APP并获取认证信息
|
|
||||||
const connectToApp = async () => {
|
|
||||||
console.group('🔗 APP Connection Process')
|
|
||||||
console.debug('🚀 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)
|
|
||||||
|
|
||||||
// 非APP环境,直接执行后续逻辑
|
|
||||||
appConnected.value = true
|
|
||||||
console.debug('✅ 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)
|
|
||||||
|
|
||||||
connectApplication(async (access) => {
|
|
||||||
const result = parseAccessOrigin(access)
|
|
||||||
|
|
||||||
if (result.success) {
|
|
||||||
// 解析头部信息
|
|
||||||
headerInfo.value = parseHeader(result.data)
|
|
||||||
|
|
||||||
// 设置HTTP请求头
|
|
||||||
console.debug('🔧 Setting HTTP headers...')
|
|
||||||
await setHttpHeaders(headerInfo.value)
|
|
||||||
|
|
||||||
// 标记连接成功
|
|
||||||
appConnected.value = true
|
|
||||||
|
|
||||||
console.debug('🎉 APP connection established successfully')
|
|
||||||
|
|
||||||
// 连接成功后获取团队信息
|
|
||||||
console.debug('📊 Fetching team entry...')
|
|
||||||
const teamEntryResult = await fetchTeamEntry()
|
|
||||||
console.debug('✅ Team entry fetched')
|
|
||||||
if (teamEntryResult != null) {
|
|
||||||
await fetchTeamMemberCount()
|
|
||||||
console.debug('✅ Team member count fetch initiated')
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.error('❌ Failed to parse access origin:', result.error)
|
|
||||||
console.debug('🔄 Redirecting to error page...')
|
|
||||||
router.push({ path: '/not_app', query: { message: result.error }})
|
|
||||||
}
|
|
||||||
|
|
||||||
console.groupEnd()
|
|
||||||
})
|
|
||||||
|
|
||||||
console.debug('⏳ Waiting for APP response...')
|
|
||||||
console.groupEnd()
|
|
||||||
}
|
|
||||||
|
|
||||||
// 用户信息
|
|
||||||
const userInfo = reactive({
|
|
||||||
userNickname: '',
|
|
||||||
id: '',
|
|
||||||
userAvatar: '',
|
|
||||||
})
|
|
||||||
|
|
||||||
// 薪资信息
|
|
||||||
const salaryInfo = reactive({
|
|
||||||
lastMonth: '',
|
|
||||||
thisMonth: ''
|
|
||||||
})
|
|
||||||
|
|
||||||
// 获取团队成员数量
|
// 获取团队成员数量
|
||||||
const fetchTeamMemberCount = async () => {
|
const fetchTeamMemberCount = async () => {
|
||||||
try {
|
try {
|
||||||
@ -320,28 +242,19 @@ const transfer = () => {
|
|||||||
router.push('/transfer')
|
router.push('/transfer')
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理头像图片加载失败
|
const {
|
||||||
const handleImageError = (event) => {
|
appConnected,
|
||||||
// 图片加载失败时,清空userAvatar,显示占位符
|
userInfo,
|
||||||
userInfo.userAvatar = ''
|
salaryInfo,
|
||||||
}
|
handleImageError,
|
||||||
|
getAvatarPlaceholder
|
||||||
// 获取头像占位符(用户名首字母)
|
} = usePageInitializationWithConfig('BD_CENTER', {
|
||||||
const getAvatarPlaceholder = () => {
|
onDataLoaded: () => {
|
||||||
if (userInfo.name && userInfo.name.length > 0) {
|
getAgentMonth()
|
||||||
return userInfo.name.charAt(0).toUpperCase()
|
fetchTeamMemberCount()
|
||||||
}
|
}
|
||||||
return 'U' // 默认显示 'U'
|
|
||||||
}
|
|
||||||
|
|
||||||
// 页面加载时先连接APP,然后获取数据
|
|
||||||
onMounted(async () => {
|
|
||||||
// 先连接APP获取认证信息
|
|
||||||
await connectToApp()
|
|
||||||
await fetchTeamEntry()
|
|
||||||
await getAgentMonth()
|
|
||||||
await fetchTeamMemberCount()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user