From cee6b25a3dc6111b1ef9c8ce16dfd44d66760ea4 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Mon, 18 Aug 2025 18:00:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 6 ++ src/api/wallet.js | 9 ++- src/utils/appBridge.js | 10 +-- src/utils/env.js | 5 ++ src/utils/http.js | 8 ++- src/utils/userStore.js | 117 +++++++++++++++++++++++++++++++++++ src/views/ApplyView.vue | 43 +++++++++++-- src/views/HostCenterView.vue | 13 ++-- src/views/MessageView.vue | 48 +++++++++++--- 9 files changed, 228 insertions(+), 31 deletions(-) create mode 100644 src/utils/userStore.js diff --git a/.env.development b/.env.development index 29b8483..662b718 100644 --- a/.env.development +++ b/.env.development @@ -2,3 +2,9 @@ VITE_NODE_ENV=development VITE_API_BASE_URL=https://api.likeichat.com VITE_APP_TITLE=Likei H5 (Development) + +# 普通用户 +VITE_USER_AUTH=5439442DA903907EF23975732147F0D4.djIlM0ExOTU0MDU5NzkzOTYzMzkzMDI1JTNBTElLRUklM0ExNzU4MDIxMTM0NTM2JTNBMTc1NTQyOTEzNDUzNg== + +# 代理用户 8826603 +# VITE_USER_AUTH=747E27BE38B21A129CE41BB1F80EA924.djIlM0ExOTU3MzU2MTM4NTIzMDY2MzY5JTNBTElLRUklM0ExNzU4MDk3MDg4NDA0JTNBMTc1NTUwNTA4ODQwNA== diff --git a/src/api/wallet.js b/src/api/wallet.js index b78b9ab..c43e4eb 100644 --- a/src/api/wallet.js +++ b/src/api/wallet.js @@ -137,13 +137,12 @@ export function sendTeamApplyJoin(data) { /** * 获取团队申请记录 - * @param {Object} params - 查询参数 - * @param {string} params.teamId - 团队ID - * @param {string} params.status - 状态 (WAIT/AGREE/REJECT) + * @param {string} teamId - 团队ID + * @param {string} status - 状态 (WAIT/AGREE/REJECT) * @returns {Promise} 返回申请记录列表 */ -export function getTeamApplyRecord(params) { - return get('/team/user/apply/record', { params }) +export function getTeamApplyRecord(teamId, status) { + return get(`/team/user/apply/record?teamId=${teamId}&status=${status}`) } /** diff --git a/src/utils/appBridge.js b/src/utils/appBridge.js index 75424a6..cbf8d15 100644 --- a/src/utils/appBridge.js +++ b/src/utils/appBridge.js @@ -3,6 +3,8 @@ * 用于H5页面与原生APP之间的通信 */ +import {COMMON_HEADERS} from "@/utils/http.js"; + /** * 检测是否为iOS系统 * @returns {boolean} @@ -182,10 +184,10 @@ export function connectApplication(renderFun) { // 开发环境可以提供模拟数据 if (process.env.NODE_ENV === 'development') { const mockAccess = JSON.stringify({ - 'Authorization': 'Bearer 5439442DA903907EF23975732147F0D4.djIlM0ExOTU0MDU5NzkzOTYzMzkzMDI1JTNBTElLRUklM0ExNzU4MDIxMTM0NTM2JTNBMTc1NTQyOTEzNDUzNg==', - 'Req-Lang': 'en', - 'Req-App-Intel': 'build=1.0;version=2.1;channel=official;Req-Imei=mock-imei', - 'Req-Sys-Origin': 'origin=LIKEI;originChild=LIKEI' + 'Authorization': COMMON_HEADERS.authorization, + 'Req-Lang': COMMON_HEADERS['req-lang'], + 'Req-App-Intel': COMMON_HEADERS['req-app-intel'], + 'Req-Sys-Origin': COMMON_HEADERS['req-sys-origin'] }) setTimeout(() => renderFun(mockAccess), 100) } diff --git a/src/utils/env.js b/src/utils/env.js index e643b42..53ff5be 100644 --- a/src/utils/env.js +++ b/src/utils/env.js @@ -8,6 +8,11 @@ export const ENV_TYPES = { TEST: 'test' } +// 获取当前用户Token +export function getUserAuth() { + return import.meta.env.VITE_USER_AUTH +} + // 获取当前环境 export function getCurrentEnv() { return import.meta.env.VITE_NODE_ENV || import.meta.env.MODE || ENV_TYPES.DEVELOPMENT diff --git a/src/utils/http.js b/src/utils/http.js index 7372041..b4f9dd5 100644 --- a/src/utils/http.js +++ b/src/utils/http.js @@ -1,5 +1,5 @@ // HTTP请求配置 -import { getApiBaseUrl, getCurrentEnv, isDebugMode } from './env.js' +import {getApiBaseUrl, getCurrentEnv, getUserAuth, isDebugMode} from './env.js' const API_BASE_URL = getApiBaseUrl() const NODE_ENV = getCurrentEnv() @@ -11,9 +11,10 @@ if (DEBUG_MODE) { console.log('🔗 API Base URL:', API_BASE_URL) } +const token = getUserAuth() // 默认公共请求头配置 let COMMON_HEADERS = { - 'authorization': 'Bearer 5439442DA903907EF23975732147F0D4.djIlM0ExOTU0MDU5NzkzOTYzMzkzMDI1JTNBTElLRUklM0ExNzU4MDIxMTM0NTM2JTNBMTc1NTQyOTEzNDUzNg==', + 'authorization': `Bearer ${token}`, 'req-app-intel': 'version=1.0.0;build=1;model=SM-G9550;sysVersion=9;channel=Google', 'req-client': 'Android', 'req-imei': '8fa54d728ab449e04f9292329ed44bda', @@ -81,6 +82,9 @@ export function setHeadersFromApp(headerInfo) { updateCommonHeaders(updatedHeaders) } +// 在http.js中添加导出 +export { COMMON_HEADERS } + /** * 通用HTTP请求函数 * @param {string} url - 请求URL diff --git a/src/utils/userStore.js b/src/utils/userStore.js new file mode 100644 index 0000000..9d04c94 --- /dev/null +++ b/src/utils/userStore.js @@ -0,0 +1,117 @@ +/** + * 用户信息存储 + */ + +// 用户信息缓存 +let userProfileCache = null +let teamInfoCache = null + +/** + * 设置用户信息缓存 + * @param {Object} memberProfile - 用户资料 + * @param {Object} teamInfo - 团队信息 + */ +export function setUserInfo(memberProfile, teamInfo = null) { + userProfileCache = memberProfile + teamInfoCache = teamInfo + + // 可选:存储到localStorage以便持久化 + if (memberProfile) { + localStorage.setItem('userProfile', JSON.stringify(memberProfile)) + } + if (teamInfo) { + localStorage.setItem('teamInfo', JSON.stringify(teamInfo)) + } +} + +/** + * 获取用户信息缓存 + * @returns {Object|null} 用户资料 + */ +export function getUserProfile() { + if (userProfileCache) { + return userProfileCache + } + + // 从localStorage恢复 + const stored = localStorage.getItem('userProfile') + if (stored) { + try { + userProfileCache = JSON.parse(stored) + return userProfileCache + } catch (error) { + console.error('解析用户缓存失败:', error) + } + } + + return null +} + +/** + * 获取团队信息缓存 + * @returns {Object|null} 团队信息 + */ +export function getTeamInfo() { + if (teamInfoCache) { + return teamInfoCache + } + + // 从localStorage恢复 + const stored = localStorage.getItem('teamInfo') + if (stored) { + try { + teamInfoCache = JSON.parse(stored) + return teamInfoCache + } catch (error) { + console.error('解析团队缓存失败:', error) + } + } + + return null +} + +/** + * 清除用户信息缓存 + */ +export function clearUserProfile() { + userProfileCache = null + teamInfoCache = null + localStorage.removeItem('userProfile') + localStorage.removeItem('teamInfo') +} + +/** + * 获取用户ID + * @returns {string|null} + */ +export function getUserId() { + const profile = getUserProfile() + return profile?.id || null +} + +/** + * 获取TeamID + * @returns {string|null} + */ +export function getTeamId() { + const profile = getTeamInfo() + return profile?.id || null +} + +/** + * 获取用户昵称 + * @returns {string|null} + */ +export function getUserNickname() { + const profile = getUserProfile() + return profile?.userNickname || null +} + +/** + * 获取用户账号 + * @returns {string|null} + */ +export function getUserAccount() { + const profile = getUserProfile() + return profile?.account || null +} diff --git a/src/views/ApplyView.vue b/src/views/ApplyView.vue index 983d3d3..b0aaa79 100644 --- a/src/views/ApplyView.vue +++ b/src/views/ApplyView.vue @@ -18,6 +18,7 @@ type="text" placeholder="Please enter the agent ID" class="agent-input" + @input="onAgentIdChange" /> @@ -28,12 +29,18 @@ + + +
+

您已有在处理中的申请,请等待审核结果

+
@@ -80,13 +87,25 @@ const applyRecords = ref([]) // 获取申请记录 const fetchApplyRecords = async () => { + if (!agentId.value.trim()) return + try { - const response = await getTeamApplyRecord({}) + const response = await getTeamApplyRecord(agentId.value.trim(), 'WAIT') if (response.status && response.body) { applyRecords.value = response.body } } catch (error) { console.error('获取申请记录失败:', error) + applyRecords.value = [] + } +} + +// 用户输入ID后查询申请记录 +const onAgentIdChange = () => { + if (agentId.value.trim()) { + fetchApplyRecords() + } else { + applyRecords.value = [] } } @@ -150,10 +169,10 @@ const getStatusClass = (status) => { return classMap[status] || '' } -// 页面加载时获取申请记录 -onMounted(() => { - fetchApplyRecords() -}) +// 页面加载时不再自动获取申请记录 +// onMounted(() => { +// fetchApplyRecords() +// }) diff --git a/src/views/HostCenterView.vue b/src/views/HostCenterView.vue index 60c68d8..2df1dc3 100644 --- a/src/views/HostCenterView.vue +++ b/src/views/HostCenterView.vue @@ -135,6 +135,7 @@ import { useRouter } from 'vue-router' import MobileHeader from '../components/MobileHeader.vue' import { getBankBalance, getUserIdentity, getTeamEntry } from '../api/wallet.js' import { connectApplication, parseAccessOrigin, parseHeader, setHttpHeaders, isInApp } from '../utils/appBridge.js' +import { setUserInfo } from '../utils/userStore.js' const router = useRouter() @@ -146,13 +147,6 @@ const headerInfo = ref({}) const userProfile = ref(null) const identityChecked = ref(false) -// 身份选项(保留显示用,但不再用于切换) -const identities = [ - { label: 'Host', value: 'host' }, - { label: 'Agency', value: 'agency' }, - { label: 'Coin Seller', value: 'coin-seller' } -] - // 连接APP并获取认证信息 const connectToApp = async () => { console.group('🔗 APP Connection Process') @@ -291,8 +285,11 @@ const fetchTeamEntry = async () => { if (response && response.status && response.body) { userProfile.value = response.body - // 更新用户信息显示 + // 缓存用户信息 if (response.body.memberProfile) { + setUserInfo(response.body.memberProfile, response.body.teamProfile) + + // 更新用户信息显示 userInfo.userNickname = response.body.memberProfile.userNickname userInfo.account = response.body.memberProfile.account } diff --git a/src/views/MessageView.vue b/src/views/MessageView.vue index c168c88..509a6a8 100644 --- a/src/views/MessageView.vue +++ b/src/views/MessageView.vue @@ -17,11 +17,15 @@
- {{ message.name }} + {{ message.name?.charAt(0) || 'U' }}
-

{{ message.name }}

-

ID: {{ message.id }}

+

{{ message.name || 'Unknown User' }}

+

ID: {{ message.account || message.userId }}

+

+ {{ message.countryName }} ({{ message.countryCode }}) +

+

{{ new Date(message.createTime).toLocaleString() }}

@@ -48,6 +52,7 @@ import { ref, onMounted } from 'vue' import { useRouter } from 'vue-router' import MobileHeader from '../components/MobileHeader.vue' import { getApplyRecord } from '../api/teamBill.js' +import {getTeamId, getTeamInfo, getUserId} from "@/utils/userStore.js"; const router = useRouter() const loading = ref(false) @@ -67,10 +72,29 @@ const mockMessages = [ const fetchMessages = async () => { loading.value = true try { - const response = await getApplyRecord('1954059793963393025', 'WAIT') // 调用真实接口 - loading.value = false + const response = await getApplyRecord(getTeamId(), 'WAIT') + + if (response.status && response.body) { + // 根据新的接口结构映射数据 + messages.value = response.body.map(item => ({ + id: item.id, + reason: item.reason, + teamId: item.teamId, + status: item.status, + createTime: item.createTime, + // 用户信息映射 + userId: item.createUserProfile.id, + account: item.createUserProfile.account, + name: item.createUserProfile.userNickname, + avatar: item.createUserProfile.userAvatar, + userSex: item.createUserProfile.userSex, + age: item.createUserProfile.age, + countryName: item.createUserProfile.countryName, + countryCode: item.createUserProfile.countryCode + })) + } } catch (error) { - + console.error('获取消息失败:', error) } finally { loading.value = false } @@ -189,11 +213,21 @@ onMounted(() => { } .user-details p { - margin: 0; + margin: 0 0 2px 0; font-size: 14px; color: #666; } +.country-info { + font-size: 12px !important; + color: #8B5CF6 !important; +} + +.apply-time { + font-size: 12px !important; + color: #999 !important; +} + .action-buttons { display: flex; gap: 8px;