apply 增加search接口

This commit is contained in:
tianfeng 2025-08-21 17:29:37 +08:00
parent fe957e4eb2
commit 55dba28d6c
2 changed files with 53 additions and 4 deletions

2
.env
View File

@ -1,5 +1,5 @@
# 应用版本号
VITE_APP_VERSION=1.0.1
VITE_APP_VERSION=1.0.2
# 构建时间戳(会在构建时自动更新)
VITE_BUILD_TIME=""

View File

@ -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.'
}