diff --git a/.env b/.env index abad6b9..7d9be19 100644 --- a/.env +++ b/.env @@ -1,5 +1,5 @@ # 应用版本号 -VITE_APP_VERSION=1.0.1 +VITE_APP_VERSION=1.0.2 # 构建时间戳(会在构建时自动更新) VITE_BUILD_TIME="" diff --git a/src/views/ApplyView.vue b/src/views/ApplyView.vue index ba72761..21779fa 100644 --- a/src/views/ApplyView.vue +++ b/src/views/ApplyView.vue @@ -95,7 +95,7 @@ import { ref, onMounted } from 'vue' import { useRouter } from 'vue-router' import MobileHeader from '../components/MobileHeader.vue' -import { sendTeamApplyJoin, getWaitApplyRecord, cancelApply } from '../api/wallet.js' +import { sendTeamApplyJoin, getWaitApplyRecord, cancelApply, searchTeamByAccount } from '../api/wallet.js' import {showError, showWarning, showInfo, showSuccess} from "@/utils/toast.js"; import { ApiError } from '@/utils/http.js'; @@ -106,6 +106,7 @@ const errorMessage = ref('') const isLoading = ref(false) const showHelpModal = ref(false) const applyRecords = ref([]) +const searchedTeamInfo = ref(null) // 存储搜索到的团队信息 // 获取申请记录 const fetchApplyRecords = async () => { @@ -159,6 +160,43 @@ const handleCancelApply = async (record) => { } } +// 搜索团队账户 +const searchTeamAccount = async (account) => { + try { + console.debug('🔍 Searching team account:', account) + const response = await searchTeamByAccount(account) + + if (response.status && response.body && response.body.teamProfile) { + searchedTeamInfo.value = response.body + console.debug('✅ Team found:', response.body.teamProfile) + return response.body.teamProfile.id // 返回团队ID + } else { + searchedTeamInfo.value = null + throw new Error('Team not found or invalid account') + } + } catch (error) { + console.error('搜索团队失败:', error) + searchedTeamInfo.value = null + + if (error instanceof ApiError) { + if (error.type === 'business') { + switch (error.errorCode) { + case 6010: + throw new Error('Account not found or not an agent') + case 6001: + throw new Error('Invalid account format') + default: + throw new Error(error.errorMsg || 'Failed to search account') + } + } else { + throw new Error('Network error, please check your connection') + } + } else { + throw new Error('Failed to search account') + } + } +} + const submitApplication = async () => { if (!agentId.value.trim()) { errorMessage.value = 'Please enter agent ID' @@ -169,9 +207,19 @@ const submitApplication = async () => { errorMessage.value = '' try { + const teamId = await searchTeamAccount(agentId.value.trim()) + if (!teamId) { + errorMessage.value = 'Account not found or not an agent' + return + } + + console.debug('✅ Team ID found:', teamId) + + // 第二步:使用获取到的teamId提交申请 + console.debug('📝 Step 2: Submitting application...') const applicationData = { - teamId: agentId.value.trim(), - reason: `JOIN` + teamId: teamId, // 使用搜索获取的teamId + reason: 'JOIN' } const response = await sendTeamApplyJoin(applicationData) @@ -180,6 +228,7 @@ const submitApplication = async () => { showSuccess('Application submitted successfully!') await fetchApplyRecords() // 刷新申请记录 agentId.value = '' // 清空输入 + searchedTeamInfo.value = null // 清空搜索结果 } else { errorMessage.value = response.message || 'Application failed. Please try again.' }