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 @@ + + +
您已有在处理中的申请,请等待审核结果
+