apply 页面调整

This commit is contained in:
tianfeng 2025-08-18 16:29:15 +08:00
parent 35130d8c01
commit f8b852e00d
4 changed files with 193 additions and 348 deletions

View File

@ -135,6 +135,17 @@ export function sendTeamApplyJoin(data) {
return post('/team/user/apply', data)
}
/**
* 获取团队申请记录
* @param {Object} params - 查询参数
* @param {string} params.teamId - 团队ID
* @param {string} params.status - 状态 (WAIT/AGREE/REJECT)
* @returns {Promise} 返回申请记录列表
*/
export function getTeamApplyRecord(params) {
return get('/team/user/apply/record', { params })
}
/**
* 格式化时间戳为可读格式
* @param {number} timestamp - 时间戳毫秒

View File

@ -53,11 +53,12 @@
</div>
<div class="salary-content">
<div class="salary-item">
<!--暂时禁用后面补充-->
<!-- <div class="salary-item">
<p class="salary-label">History Salary:</p>
<p class="salary-amount">${{ salaryInfo.historySalary }}</p>
</div>
<div class="salary-separator"></div>
<div class="salary-separator"></div>-->
<div class="salary-item">
<p class="salary-label">Current Salary:</p>
<p class="salary-amount">${{ salaryInfo.currentSalary }}</p>
@ -154,6 +155,7 @@ import { ref, reactive, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import MobileHeader from '../components/MobileHeader.vue'
import { get } from '../utils/http.js'
import {getBankBalance} from "@/api/wallet.js";
const router = useRouter()
@ -173,13 +175,6 @@ const salaryInfo = reactive({
currentSalary: 12345
})
//
const identities = [
{ label: 'Host', value: 'host' },
{ label: 'Agency', value: 'agency' },
{ label: 'Coin Seller', value: 'coin-seller' }
]
//
const userInfo = reactive({
name: 'User1',
@ -203,23 +198,6 @@ const teamBillInfo = reactive({
status: 'Pending'
})
//
const handleIdentityChange = (identity) => {
switch (identity) {
case 'host':
router.push('/host-center')
break
case 'coin-seller':
router.push('/coin-seller')
break
case 'agency':
default:
//
currentIdentity.value = identity
break
}
}
//
const goToNotification = () => {
router.push('/message')
@ -237,10 +215,6 @@ const goToTeamMember = () => {
router.push('/team-member')
}
const goToPlatformPolicy = () => {
router.push('/platform-policy')
}
const exchangeGoldCoins = () => {
router.push('/exchange-gold-coins')
}
@ -275,9 +249,30 @@ const fetchTeamMemberCount = async () => {
}
}
//
const fetchBankBalance = async () => {
try {
const response = await getBankBalance()
if (response.status && typeof response.body === 'number') {
// 2
salaryInfo.currentSalary = response.body.toFixed(2)
} else {
salaryInfo.currentSalary = 0.00
}
} catch (error) {
console.error('Failed to fetch bank balance:', error)
salaryInfo.currentSalary = 0.00
//
alert('Failed to load balance. Please try again.')
}
}
//
onMounted(() => {
fetchTeamMemberCount()
fetchBankBalance()
})
</script>
@ -714,29 +709,6 @@ onMounted(() => {
color: #1F2937;
}
/* Platform Policy 链接 */
.policy-link {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 16px;
margin-top: 12px;
background-color: #f8f9fa;
border-radius: 8px;
cursor: pointer;
transition: all 0.2s;
border: 1px solid #e9ecef;
}
.policy-link:hover {
background-color: #e9ecef;
border-color: #8B5CF6;
}
.policy-link:active {
transform: scale(0.98);
}
.policy-link span:first-child {
font-size: 14px;
font-weight: 500;

View File

@ -1,5 +1,5 @@
<template>
<div class="apply-view gradient-background-circles">
<div class="apply-view">
<MobileHeader title="Apply to join the team" :showHelp="true" @help="showHelp" />
<div class="content">
@ -12,40 +12,18 @@
<!-- 申请表单 -->
<div class="application-form">
<div class="input-group">
<label for="agentId">Apply ID:</label>
<div class="input-container">
<input
id="agentId"
v-model="agentId"
type="text"
placeholder="Please enter the agent ID"
class="agent-input"
@input="clearError"
/>
</div>
<label>Apply ID:</label>
<input
v-model="agentId"
type="text"
placeholder="Please enter the agent ID"
class="agent-input"
/>
</div>
<!-- 错误提示 -->
<div v-if="errorMessage" class="error-message">
<span>{{ errorMessage }}</span>
</div>
<!-- 搜索到的代理信息 -->
<div v-if="agentInfo" class="agent-info">
<div class="agent-card">
<div class="agent-avatar">
<img v-if="agentInfo.userAvatar" :src="agentInfo.userAvatar" :alt="agentInfo.userNickname" />
<span v-else>{{ agentInfo.userNickname?.charAt(0) || 'A' }}</span>
</div>
<div class="agent-details">
<h4>{{ agentInfo.userNickname || 'Agent' }}</h4>
<p>ID: {{ agentInfo.account }}</p>
<div class="agent-tags">
<span class="tag">🏢 Agent</span>
<span v-if="agentInfo.countryName" class="tag">🌍 {{ agentInfo.countryName }}</span>
</div>
</div>
</div>
{{ errorMessage }}
</div>
<!-- 申请按钮 -->
@ -54,15 +32,24 @@
@click="submitApplication"
:disabled="!agentId.trim() || isLoading"
>
<span v-if="isLoading">Applying...</span>
<span v-else>Apply</span>
{{ isLoading ? 'Applying...' : 'Apply' }}
</button>
</div>
</div>
<!-- 加载状态 -->
<div v-if="isSearching" class="loading-state">
<div class="loading-spinner"></div>
<p>Searching agent...</p>
<!-- 申请记录 -->
<div v-if="applyRecords.length > 0" class="records-section">
<h3>Application Records</h3>
<div class="record-list">
<div v-for="record in applyRecords" :key="record.id" class="record-item">
<div class="record-info">
<p class="record-reason">{{ record.reason }}</p>
<p class="record-time">{{ new Date(record.createTime).toLocaleString() }}</p>
</div>
<span :class="['record-status', getStatusClass(record.status)]">
{{ getStatusText(record.status) }}
</span>
</div>
</div>
</div>
@ -70,16 +57,7 @@
<div v-if="showHelpModal" class="help-modal" @click="closeHelp">
<div class="help-content" @click.stop>
<h3>Application Help</h3>
<div class="help-text">
<p><strong>How to apply:</strong></p>
<ul>
<li>Enter your agent's ID in the input field</li>
<li>The system will search and verify the agent</li>
<li>Click "Apply" to submit your application</li>
<li>Wait for the agent to approve your application</li>
</ul>
<p><strong>Note:</strong> After approval, your income will be managed by your agent.</p>
</div>
<p>Enter your agent's ID and click Apply to submit your application.</p>
<button class="close-btn" @click="closeHelp">Got it</button>
</div>
</div>
@ -87,104 +65,52 @@
</template>
<script setup>
import { ref, watch } from 'vue'
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import MobileHeader from '../components/MobileHeader.vue'
import { searchTeamByAccount, sendTeamApplyJoin } from '../api/wallet.js'
import { sendTeamApplyJoin, getTeamApplyRecord } from '../api/wallet.js'
const router = useRouter()
//
const agentId = ref('')
const agentInfo = ref(null)
const errorMessage = ref('')
const isSearching = ref(false)
const isLoading = ref(false)
const showHelpModal = ref(false)
const applyRecords = ref([])
//
let searchTimeout = null
// ID
watch(agentId, (newValue) => {
if (searchTimeout) {
clearTimeout(searchTimeout)
}
if (newValue.trim()) {
searchTimeout = setTimeout(() => {
searchAgent(newValue.trim())
}, 500) // 500ms
} else {
agentInfo.value = null
errorMessage.value = ''
}
})
//
const searchAgent = async (account) => {
if (!account) return
isSearching.value = true
errorMessage.value = ''
agentInfo.value = null
//
const fetchApplyRecords = async () => {
try {
const response = await searchTeamByAccount(account)
const response = await getTeamApplyRecord({})
if (response.status && response.body) {
//
agentInfo.value = {
account: account,
userNickname: response.body.teamName || 'Agent Team',
userAvatar: response.body.teamAvatar || '',
countryName: response.body.countryName || '',
teamId: response.body.teamId,
agentId: response.body.agentId
}
} else {
errorMessage.value = 'Agent not found. Please check the ID and try again.'
applyRecords.value = response.body
}
} catch (error) {
console.error('搜索代理失败:', error)
errorMessage.value = 'Failed to search agent. Please try again.'
} finally {
isSearching.value = false
console.error('获取申请记录失败:', error)
}
}
//
const clearError = () => {
errorMessage.value = ''
}
//
const submitApplication = async () => {
if (!agentId.value.trim()) {
errorMessage.value = 'Please enter agent ID'
return
}
if (!agentInfo.value) {
errorMessage.value = 'Please wait for agent verification'
return
}
isLoading.value = true
errorMessage.value = ''
try {
const applicationData = {
teamId: agentInfo.value.teamId,
reason: `Application to join team under agent ${agentId.value}`
teamId: agentId.value.trim(),
reason: `JOIN`
}
const response = await sendTeamApplyJoin(applicationData)
if (response.status) {
//
alert('Application submitted successfully! Please wait for approval.')
router.go(-1) //
alert('Application submitted successfully!')
await fetchApplyRecords() //
agentId.value = '' //
} else {
errorMessage.value = response.message || 'Application failed. Please try again.'
}
@ -196,37 +122,56 @@ const submitApplication = async () => {
}
}
//
const showHelp = () => {
showHelpModal.value = true
}
//
const closeHelp = () => {
showHelpModal.value = false
}
//
const getStatusText = (status) => {
const statusMap = {
'WAIT': 'Pending',
'AGREE': 'Approved',
'REJECT': 'Rejected'
}
return statusMap[status] || status
}
//
const getStatusClass = (status) => {
const classMap = {
'WAIT': 'status-pending',
'AGREE': 'status-approved',
'REJECT': 'status-rejected'
}
return classMap[status] || ''
}
//
onMounted(() => {
fetchApplyRecords()
})
</script>
<style scoped>
.apply-view {
font-family: -apple-system, BlinkMacSystemFont, sans-serif;
min-height: 100vh;
/*background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);*/
background-color: #f5f5f5;
}
.content {
padding: 20px 16px;
position: relative;
z-index: 2;
}
/* 申请说明 */
.reminder-section {
background-color: rgba(255, 255, 255, 0.95);
background-color: white;
padding: 20px;
border-radius: 12px;
margin-bottom: 24px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
border-radius: 8px;
margin-bottom: 20px;
}
.reminder-section h3 {
@ -243,12 +188,10 @@ const closeHelp = () => {
color: #666;
}
/* 申请表单 */
.application-form {
background-color: rgba(255, 255, 255, 0.95);
padding: 24px;
border-radius: 12px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
background-color: white;
padding: 20px;
border-radius: 8px;
}
.input-group {
@ -263,18 +206,12 @@ const closeHelp = () => {
margin-bottom: 8px;
}
.input-container {
position: relative;
}
.agent-input {
width: 100%;
padding: 16px;
border: 2px solid #e0e0e0;
border-radius: 12px;
padding: 12px;
border: 1px solid #ddd;
border-radius: 6px;
font-size: 16px;
background-color: white;
transition: border-color 0.2s;
box-sizing: border-box;
}
@ -283,100 +220,26 @@ const closeHelp = () => {
border-color: #8B5CF6;
}
.agent-input::placeholder {
color: #999;
}
/* 错误信息 */
.error-message {
margin-bottom: 16px;
padding: 12px;
background-color: #FEE2E2;
border: 1px solid #FECACA;
border-radius: 8px;
border-radius: 6px;
color: #DC2626;
font-size: 14px;
}
/* 代理信息 */
.agent-info {
margin-bottom: 24px;
}
.agent-card {
display: flex;
align-items: center;
background-color: #F8FAFC;
padding: 16px;
border-radius: 12px;
border: 2px solid #E2E8F0;
}
.agent-avatar {
width: 50px;
height: 50px;
border-radius: 25px;
background-color: #8B5CF6;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 18px;
font-weight: 600;
margin-right: 12px;
overflow: hidden;
}
.agent-avatar img {
width: 100%;
height: 100%;
object-fit: cover;
}
.agent-details h4 {
margin: 0 0 4px 0;
font-size: 16px;
font-weight: 600;
color: #333;
}
.agent-details p {
margin: 0 0 8px 0;
font-size: 14px;
color: #666;
}
.agent-tags {
display: flex;
gap: 6px;
flex-wrap: wrap;
}
.tag {
padding: 4px 8px;
border-radius: 12px;
font-size: 11px;
font-weight: 600;
background-color: #E0E7FF;
color: #5B21B6;
}
/* 申请按钮 */
.apply-btn {
width: 100%;
padding: 16px;
padding: 14px;
background-color: #8B5CF6;
color: white;
border: none;
border-radius: 12px;
border-radius: 6px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: background-color 0.2s;
}
.apply-btn:hover:not(:disabled) {
background-color: #7C3AED;
}
.apply-btn:disabled {
@ -384,39 +247,6 @@ const closeHelp = () => {
cursor: not-allowed;
}
.apply-btn:active:not(:disabled) {
transform: scale(0.98);
}
/* 加载状态 */
.loading-state {
text-align: center;
padding: 20px;
margin-top: 20px;
}
.loading-spinner {
width: 32px;
height: 32px;
border: 3px solid rgba(255, 255, 255, 0.3);
border-top: 3px solid white;
border-radius: 50%;
animation: spin 1s linear infinite;
margin: 0 auto 12px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.loading-state p {
margin: 0;
color: white;
font-size: 14px;
}
/* 帮助弹窗 */
.help-modal {
position: fixed;
top: 0;
@ -433,55 +263,102 @@ const closeHelp = () => {
.help-content {
background-color: white;
padding: 24px;
border-radius: 16px;
max-width: 400px;
padding: 20px;
border-radius: 8px;
max-width: 300px;
width: 100%;
max-height: 80vh;
overflow-y: auto;
}
.help-content h3 {
margin: 0 0 16px 0;
margin: 0 0 12px 0;
font-size: 18px;
font-weight: 600;
color: #333;
text-align: center;
}
.help-text {
margin-bottom: 20px;
.help-content p {
margin: 0 0 16px 0;
color: #666;
line-height: 1.5;
}
.help-text p {
margin: 0 0 12px 0;
}
.help-text ul {
margin: 8px 0;
padding-left: 20px;
}
.help-text li {
margin-bottom: 6px;
}
.close-btn {
width: 100%;
padding: 12px;
padding: 10px;
background-color: #8B5CF6;
color: white;
border: none;
border-radius: 8px;
font-size: 16px;
border-radius: 6px;
font-size: 14px;
font-weight: 600;
cursor: pointer;
}
.close-btn:active {
background-color: #7C3AED;
.records-section {
background-color: white;
padding: 20px;
border-radius: 8px;
margin-top: 20px;
}
.records-section h3 {
margin: 0 0 16px 0;
font-size: 16px;
font-weight: 600;
color: #333;
}
.record-list {
display: flex;
flex-direction: column;
gap: 12px;
}
.record-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px;
border: 1px solid #e0e0e0;
border-radius: 6px;
}
.record-info {
flex: 1;
}
.record-reason {
margin: 0 0 4px 0;
font-size: 14px;
color: #333;
}
.record-time {
margin: 0;
font-size: 12px;
color: #666;
}
.record-status {
padding: 4px 8px;
border-radius: 4px;
font-size: 12px;
font-weight: 600;
}
.status-pending {
background-color: #FEF3C7;
color: #D97706;
}
.status-approved {
background-color: #D1FAE5;
color: #059669;
}
.status-rejected {
background-color: #FEE2E2;
color: #DC2626;
}
</style>

View File

@ -52,11 +52,12 @@
</div>
<div class="salary-content">
<div class="salary-item">
<!--暂时禁用后面补充-->
<!-- <div class="salary-item">
<p class="salary-label">History Salary:</p>
<p class="salary-amount">${{ salaryInfo.hostSalary }}</p>
</div>
<div class="salary-separator"></div>
<div class="salary-separator"></div>-->
<div class="salary-item">
<p class="salary-label">Current Salary:</p>
<p class="salary-amount">${{ salaryInfo.currentSalary }}</p>
@ -178,27 +179,11 @@ const connectToApp = async () => {
console.log(' - window.webkit:', !!window.webkit)
connectApplication(async (access) => {
console.log('📥 Received data from APP:')
console.log(' - Data type:', typeof access)
console.log(' - Data length:', access ? access.length : 0)
console.log(' - Raw data:', access)
const result = parseAccessOrigin(access)
console.log('🔍 Parsing result:')
console.log(' - Success:', result.success)
if (result.success) {
console.log('✅ Access data parsed successfully')
//
headerInfo.value = parseHeader(result.data)
console.log('📋 Parsed header info:')
console.log(' - Authorization:', headerInfo.value.authorization ? '✅ Present' : '❌ Missing')
console.log(' - Language:', headerInfo.value.reqLang)
console.log(' - App Version:', headerInfo.value.appVersion)
console.log(' - Build Version:', headerInfo.value.buildVersion)
console.log(' - System Origin:', headerInfo.value.sysOrigin)
console.log(' - Device ID:', headerInfo.value.reqImei ? '✅ Present' : '❌ Missing')
// HTTP
console.log('🔧 Setting HTTP headers...')
@ -322,6 +307,11 @@ const fetchTeamEntry = async () => {
}
} catch (error) {
console.error('获取团队信息失败:', error)
// HTTP 406NOT_TEAM_MEMBER
if (error.message && error.message.includes('406')) {
await router.push('/apply')
return
}
}
return null
}
@ -385,11 +375,6 @@ const transfer = () => {
onMounted(async () => {
// APP
await connectToApp()
// APP
if (!isInApp()) {
fetchBankBalance()
}
})
</script>