feat(我的代理): 获取我的代理数据

This commit is contained in:
hzj 2025-10-13 19:00:40 +08:00
parent b7861c6f87
commit 6e92db98a3
3 changed files with 35 additions and 9 deletions

13
src/api/host.js Normal file
View File

@ -0,0 +1,13 @@
import { get, post } from '../utils/http.js'
// 获取我的代理
export const getMyAgency = async () => {
try {
const response = await get(`/team/team-own/profile`)
return response
} catch (error) {
console.error('Failed to fetch get my agency:', error)
console.error('error:' + error.response.errorMsg)
throw error
}
}

View File

@ -33,7 +33,9 @@
<div style="margin-bottom: 4px; font-weight: 600"> <div style="margin-bottom: 4px; font-weight: 600">
{{ userInfo.userNickname || userInfo.name }} {{ userInfo.userNickname || userInfo.name }}
</div> </div>
<div style="font-size: 0.9em; color: rgba(0, 0, 0, 0.4)">ID: {{ userInfo.id }}</div> <div style="font-size: 0.9em; color: rgba(0, 0, 0, 0.4)">
ID: {{ userInfo.account }}
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -23,7 +23,7 @@
<!-- 用户信息 --> <!-- 用户信息 -->
<div style="display: flex; align-items: center"> <div style="display: flex; align-items: center">
<img <img
:src="avatarUrl || ''" :src="userInfo.userAvatar || ''"
alt="" alt=""
width="50px" width="50px"
style="aspect-ratio: 1/1; border-radius: 50%; object-fit: cover" style="aspect-ratio: 1/1; border-radius: 50%; object-fit: cover"
@ -31,9 +31,11 @@
/> />
<div style="flex: 1"> <div style="flex: 1">
<div style="margin-bottom: 4px; font-weight: 600"> <div style="margin-bottom: 4px; font-weight: 600">
{{ userInfo.name }} {{ userInfo.userNickname || '' }}
</div>
<div style="font-size: 0.9em; color: rgba(0, 0, 0, 0.4)">
ID: {{ userInfo.account }}
</div> </div>
<div style="font-size: 0.9em; color: rgba(0, 0, 0, 0.4)">ID: {{ userInfo.id }}</div>
</div> </div>
</div> </div>
<!-- 按钮 --> <!-- 按钮 -->
@ -47,18 +49,16 @@
</template> </template>
<script setup> <script setup>
import { reactive } from 'vue' import { onMounted, reactive, ref } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import MobileHeader from '../components/MobileHeader.vue' import MobileHeader from '../components/MobileHeader.vue'
import { showError } from '@/utils/toast.js' import { showError } from '@/utils/toast.js'
import { getMyAgency } from '@/api/host'
const router = useRouter() const router = useRouter()
// //
const userInfo = reactive({ const userInfo = ref({})
name: 'User1',
id: '1234567890',
})
const defaultAvatarUrl = (e) => { const defaultAvatarUrl = (e) => {
console.log('头像资源出错') console.log('头像资源出错')
@ -73,6 +73,17 @@ const leaveAgent = () => {
// //
} }
} }
const getMyAgencyInfo = async () => {
const resAgencyInfo = await getMyAgency()
if (resAgencyInfo.status && resAgencyInfo.body) {
userInfo.value = resAgencyInfo.body
}
}
onMounted(() => {
getMyAgencyInfo()
})
</script> </script>
<style scoped> <style scoped>