apply 增加search接口
This commit is contained in:
parent
fe957e4eb2
commit
55dba28d6c
2
.env
2
.env
@ -1,5 +1,5 @@
|
||||
# 应用版本号
|
||||
VITE_APP_VERSION=1.0.1
|
||||
VITE_APP_VERSION=1.0.2
|
||||
|
||||
# 构建时间戳(会在构建时自动更新)
|
||||
VITE_BUILD_TIME=""
|
||||
|
||||
@ -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.'
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user