diff --git a/src/api/modules/agent/customerDetail.ts b/src/api/modules/agent/customerDetail.ts index a8fb5bb..7b248a0 100644 --- a/src/api/modules/agent/customerDetail.ts +++ b/src/api/modules/agent/customerDetail.ts @@ -1,6 +1,7 @@ -//获取代理客户列表接口 +// 获取代理客户详情接口 import { request } from '@/api'; +import type { GetCustomerDetailParams, CustomerDetailResponse } from '@/api/types/agent'; -export const getCustomerDetailApi = (params: any) => { - return request.get('/agent/getAgentUserDetail', {...params}) +export const getCustomerDetailApi = (params: GetCustomerDetailParams): Promise => { + return request.get('/agent/getAgentUserDetail', params); } diff --git a/src/api/modules/profile/personalCenter.ts b/src/api/modules/profile/personalCenter.ts index 07df0d3..e0c1003 100644 --- a/src/api/modules/profile/personalCenter.ts +++ b/src/api/modules/profile/personalCenter.ts @@ -1,40 +1,39 @@ import { request } from '@/api'; +import type { + UserInfo, + EditLangTypeParams, + BindMobileParams, + BindEmailParams, + EditUsernameParams, + UpdatePwdByCaptchaParams +} from '@/api/types/profile'; // 获取用户信息 -export async function getUserInfoApi() { - return request.get('/user/getUserInfo'); +export async function getUserInfoApi(): Promise { + return request.get('/user/getUserInfo'); } // 修改语言类型 -export async function editLangTypeApi(lang_type: number) { - return request.post('/user/editLangType', { lang_type }); +export async function editLangTypeApi(params: EditLangTypeParams): Promise { + return request.post('/user/editLangType', params); } // 绑定手机号 -export async function bindMobileApi(data: { mobile: string; code: string }) { +export async function bindMobileApi(data: BindMobileParams): Promise { return request.post('/user/bindMobile', data); } // 绑定邮箱 -export async function bindEmailApi(data: { email: string; code: string }) { +export async function bindEmailApi(data: BindEmailParams): Promise { return request.post('/user/bindEmail', data); } // 修改用户名 -export async function editUsernameApi(data: { user_id: number; username: string }) { +export async function editUsernameApi(data: EditUsernameParams): Promise { return request.post('/user/editUser', data); } - -// 短信验证码修改密码 // 验证码修改密码(统一接口) -export async function updatePwdByCaptchaApi(data: { - reg_type: number; - email?: string; - mobile?: string; - code: string; - login_password1: string; - login_password2: string; -}) { +export async function updatePwdByCaptchaApi(data: UpdatePwdByCaptchaParams): Promise { return request.post('/user/editLoginPass', data); } \ No newline at end of file diff --git a/src/api/types/agent.d.ts b/src/api/types/agent.d.ts new file mode 100644 index 0000000..12af70c --- /dev/null +++ b/src/api/types/agent.d.ts @@ -0,0 +1,83 @@ +// 代理客户详情相关类型定义 + +// 角色映射类型 +export type RoleType = 1 | 2 | 3 | 4 | 5 | 6 + +// 角色名称映射 +export const ROLE_MAP: Record = { + 1: '平台', + 2: '承包商', + 3: '特殊做市商', + 4: '普通做市商', + 5: '代理', + 6: '用户', +} + +// 用户信息类型 +export interface CustomerUserInfo { + id: string | number + email: string + mobile: string + role_id: RoleType + capital_amount: string | number + total_recharge_amount: string | number + history_transfer_amount: string | number + created_at: string +} + +// 交易账户钱包信息类型 +export interface AccountWallet { + amount: string | number + lever: string | number +} + +// 交易账户类型 +export interface Account { + account_id: string | number + account_name: string + wallets_trade: AccountWallet + collect_data: string | number + created_at: string +} + +// 客户详情响应类型 +export interface CustomerDetailResponse { + user: CustomerUserInfo + accounts: Account[] +} + +// 获取客户详情参数类型 +export interface GetCustomerDetailParams { + user_id: string | number +} + +// 表格列配置类型 +export interface TableColumn { + label: string + prop: string + width?: number + sortable?: boolean +} + +// 用户展示信息类型 +export interface UserDisplayInfo { + name: string + id: string | number + role: string + phone: string + email: string + deposit: string | number + balance: string | number + registerTime: string + hisMeny: string | number +} + +// 表格数据行类型 +export interface TableDataRow { + tradeAccount: string | number + accountName: string + balance: string | number + leverage: string | number + tradeVolume: string | number + addTime: string +} diff --git a/src/api/types/profile.d.ts b/src/api/types/profile.d.ts new file mode 100644 index 0000000..d3e3649 --- /dev/null +++ b/src/api/types/profile.d.ts @@ -0,0 +1,60 @@ +// 个人中心相关类型定义 + +// 用户信息类型 +export interface UserInfo { + id: number + username: string + email: string + mobile: string + lang_type: number + avatar: string + last_login: string +} + +// 编辑表单类型 +export interface EditForm { + label: string + value: string + code: string +} + +// 密码表单类型 +export interface PasswordForm { + verifyType: 'mobile' | 'email' + code: string + login_password1: string + login_password2: string +} + +// 修改语言参数类型 +export interface EditLangTypeParams { + lang_type: number +} + +// 绑定手机号参数类型 +export interface BindMobileParams { + mobile: string + code: string +} + +// 绑定邮箱参数类型 +export interface BindEmailParams { + email: string + code: string +} + +// 修改用户名参数类型 +export interface EditUsernameParams { + user_id: number + username: string +} + +// 验证码修改密码参数类型 +export interface UpdatePwdByCaptchaParams { + reg_type: number + email?: string + mobile?: string + code: string + login_password1: string + login_password2: string +} diff --git a/src/views/agent/user/AnimatedNumber.vue b/src/views/agent/user/AnimatedNumber.vue new file mode 100644 index 0000000..fdc2060 --- /dev/null +++ b/src/views/agent/user/AnimatedNumber.vue @@ -0,0 +1,75 @@ + + + diff --git a/src/views/agent/user/default.vue b/src/views/agent/user/default.vue index 1f4bfc3..3a8d307 100644 --- a/src/views/agent/user/default.vue +++ b/src/views/agent/user/default.vue @@ -34,7 +34,9 @@ 账户余额 -
{{ userInfo.balance || '0' }}
+
+ +
@@ -43,7 +45,9 @@ 存款金额
-
{{ userInfo.deposit || '0' }}
+
+ +
@@ -70,7 +74,9 @@ 历史交易金额
-
{{ userInfo.hisMeny || '-' }}
+
+ +
@@ -92,8 +98,20 @@ import { UserFilled, Phone, Message, Money, Wallet, Clock, CreditCard } from '@e import CustomerListTable from '@/components/common/Table.vue' import { getCustomerDetailApi } from '@/api/modules/agent/customerDetail' import dayjs from 'dayjs' +import AnimatedNumber from './AnimatedNumber.vue' -const roleMap: { [key: number]: string } = { +// 类型定义 +import type { + RoleType, + CustomerUserInfo, + Account, + CustomerDetailResponse, + UserDisplayInfo, + TableDataRow, + TableColumn +} from '@/api/types/agent' + +const roleMap: Record = { 1: '平台', 2: '承包商', 3: '特殊做市商', @@ -129,21 +147,21 @@ const loading = ref(false) const tableLoading = ref(false) // 客户信息 -const userInfo = ref({ +const userInfo = ref({ name: '', id: '', role: '', phone: '', email: '', - deposit: '', - balance: '', + deposit: 0, + balance: 0, registerTime: '', - hisMeny: 122, + hisMeny: 0, }) // 表格 -const tableData = ref() -const tableColumnsOptions = ref([ +const tableData = ref([]) +const tableColumnsOptions = ref([ { label: '交易账号', prop: 'tradeAccount' }, { label: '账户名称', prop: 'accountName' }, { label: '余额', prop: 'balance', sortable: true }, @@ -153,40 +171,38 @@ const tableColumnsOptions = ref([ ]) -// ===================== 加载详情数据(替换你的接口) ===================== +// ===================== 加载详情数据 ===================== const loadDetailData = async (id: string | number) => { loading.value = true tableLoading.value = true try { - // 这里替换成你的真实客户详情接口 - getCustomerDetailApi({ user_id: id }).then((res) => { - console.log('res:', res); - const { accounts, user } = res; - userInfo.value = { - name: user.email || user.mobile, - id: user.id, - role: roleMap[user.role_id], - phone: user.mobile || '-', - email: user.email || '-', - balance: user.capital_amount, - deposit: user.total_recharge_amount, - registerTime: dayjs(user.created_at).format('YYYY-MM-DD HH:mm:ss'), + const res: CustomerDetailResponse = await getCustomerDetailApi({ user_id: id }); + const { accounts, user } = res; + + userInfo.value = { + name: user.email || user.mobile || '-', + id: user.id, + role: roleMap[user.role_id] || '-', + phone: user.mobile || '-', + email: user.email || '-', + balance: Number(user.capital_amount) || 0, + deposit: Number(user.total_recharge_amount) || 0, + registerTime: dayjs(user.created_at).format('YYYY-MM-DD HH:mm:ss'), + hisMeny: Number(user.history_transfer_amount) || 0, + } - hisMeny: user.history_transfer_amount, - } - - // 这里替换成你的真实账户列表接口 - tableData.value = accounts.map((item: any) => ({ - tradeAccount: item.account_id, - accountName: item.account_name, - balance: item.wallets_trade.amount, - leverage: item.wallets_trade.lever, - tradeVolume: item.collect_data, - addTime: dayjs(item.created_at).format('YYYY-MM-DD HH:mm:ss'), - })) - }) + // 处理账户列表数据 + tableData.value = accounts.map((item: Account): TableDataRow => ({ + tradeAccount: item.account_id, + accountName: item.account_name, + balance: Number(item.wallets_trade.amount) || 0, + leverage: Number(item.wallets_trade.lever) || 0, + tradeVolume: Number(item.collect_data) || 0, + addTime: dayjs(item.created_at).format('YYYY-MM-DD HH:mm:ss'), + })) } catch (err) { + console.error('加载详情失败:', err); ElMessage.error('加载详情失败') } finally { loading.value = false @@ -203,8 +219,9 @@ watch( }, { immediate: true } ) + // 账户操作 -const handleAccount = (row: any) => { +const handleAccount = (row: TableDataRow) => { ElMessage.success('操作账户:' + row.tradeAccount) } diff --git a/src/views/profile/personalCenter/index.vue b/src/views/profile/personalCenter/index.vue index b9c7702..d1e6e69 100644 --- a/src/views/profile/personalCenter/index.vue +++ b/src/views/profile/personalCenter/index.vue @@ -40,9 +40,12 @@
手机号 {{ userInfo.mobile || '未绑定' }} - - {{ userInfo.mobile ? '重新绑定' : '绑定' }} + + 绑定 +
@@ -63,56 +66,24 @@
- - + + - + - + - - + + @@ -128,35 +99,20 @@ - - + + - + - + @@ -164,7 +120,7 @@