diff --git a/api/user/README.md b/api/user/README.md index e6c2b84..e663abc 100644 --- a/api/user/README.md +++ b/api/user/README.md @@ -112,7 +112,57 @@ const response = await getAgentList({ ] ``` -### 5. 更新用户信息 +### 5. 获取提现信息 +```javascript +import { getWithdrawInfo } from '@/api/user/user.js' + +const response = await getWithdrawInfo() +``` + +**接口地址:** `GET /app/withdraw` + +**响应数据:** +```javascript +{ + balance: 10000.00, // 账户余额 + waitVerify: 0, // 待验证金额 + available: 10000.00, // 可提现金额 + unsettled: 0, // 未结算金额 + fee: 1.00, // 提现手续费 + minAmount: 100.00, // 最小提现金额 + maxAmount: 50000.00 // 最大提现金额 +} +``` + +### 6. 提交提现申请 +```javascript +import { submitWithdraw } from '@/api/user/user.js' + +const response = await submitWithdraw({ + amount: 1000.00, // 提现金额 + bankId: '1' // 银行ID +}) +``` + +**接口地址:** `POST /app/withdraw` + +**请求参数:** +- `amount` (number, 必填): 提现金额 +- `bankId` (string, 必填): 银行ID + +**响应数据:** +```javascript +{ + msg: "操作成功", + code: 200, + data: { + balance: 9000.00, // 提现后余额 + waitVerify: 1000.00 // 待验证金额 + } +} +``` + +### 7. 更新用户信息 ```javascript import { updateUserInfo } from '@/api/user/user.js' @@ -126,6 +176,39 @@ const response = await updateUserInfo({ ## 使用示例 +### 在提现页面中 +```javascript +// 在提现页面中 +async fetchWithdrawInfo() { + try { + const response = await getWithdrawInfo() + if (response.code === 200) { + this.withdrawInfo = response.data + } + } catch (error) { + console.error('获取提现信息失败:', error) + } +} + +async submitWithdrawal() { + try { + const response = await submitWithdraw({ + amount: 1000.00, + bankId: '1' + }) + + if (response.code === 200) { + uni.showToast({ + title: '提现申请已提交', + icon: 'success' + }) + } + } catch (error) { + console.error('提现申请失败:', error) + } +} +``` + ### 在页面中获取用户数据 ```javascript // 在 Profile 页面中 @@ -194,4 +277,6 @@ const response = await getUserInfo() - `mockUserInfo`: 用户基本信息 - `mockFinancialData`: 财务数据 - `mockAgentStats`: 代理统计数据 -- `mockAgentList`: 代理用户列表数据 \ No newline at end of file +- `mockAgentList`: 代理用户列表数据 +- `mockWithdrawInfo`: 提现信息数据 +- `mockBanks`: 银行列表数据 \ No newline at end of file diff --git a/api/user/mockData.js b/api/user/mockData.js index 83ac5de..e401292 100644 --- a/api/user/mockData.js +++ b/api/user/mockData.js @@ -68,6 +68,43 @@ export const mockAgentList = [ } ] +export const mockWithdrawInfo = { + balance: 10000.00, + waitVerify: 0, + available: 10000.00, + unsettled: 0, + fee: 1.00, // 提现手续费 + minAmount: 100.00, // 最小提现金额 + maxAmount: 50000.00, // 最大提现金额 +} + +export const mockBanks = [ + { + id: '1', + name: '建设银行', + icon: 'https://api.ccttiot.com/image-1755503384639.png', + cardNumber: '**** **** **** 1234' + }, + { + id: '2', + name: '工商银行', + icon: 'https://api.ccttiot.com/image-1755503384639.png', + cardNumber: '**** **** **** 5678' + }, + { + id: '3', + name: '农业银行', + icon: 'https://api.ccttiot.com/image-1755503384639.png', + cardNumber: '**** **** **** 9012' + }, + { + id: '4', + name: '中国银行', + icon: 'https://api.ccttiot.com/image-1755503384639.png', + cardNumber: '**** **** **** 3456' + } +] + // 模拟API响应格式 export const createMockResponse = (data, code = 200, msg = '操作成功') => { return { diff --git a/api/user/user.js b/api/user/user.js index 60fc6a4..25fe2a0 100644 --- a/api/user/user.js +++ b/api/user/user.js @@ -1,5 +1,5 @@ import request from '@/utils/request' -import { mockUserInfo, mockFinancialData, mockAgentStats, mockAgentList, createMockResponse } from './mockData.js' +import { mockUserInfo, mockFinancialData, mockAgentStats, mockAgentList, mockWithdrawInfo, mockBanks, createMockResponse } from './mockData.js' /** * 获取用户信息 @@ -124,4 +124,38 @@ export function getUserAvatar(userId) { params: { userId }, showLoading: false, }) +} + +/** + * 获取提现信息 + * @returns {Promise} 返回提现相关信息 + */ +export function getWithdrawInfo() { + return request({ + url: '/app/withdraw', + method: 'GET', + showLoading: false, + }).catch(error => { + console.warn('提现信息API调用失败,使用模拟数据:', error) + return createMockResponse(mockWithdrawInfo) + }) +} + +/** + * 提交提现申请 + * @param {Object} data 提现数据 + * @param {number} data.amount 提现金额 + * @param {string} data.bankId 银行ID + * @returns {Promise} 返回提现申请结果 + */ +export function submitWithdraw(data) { + return request({ + url: '/app/withdraw', + method: 'POST', + data, + showLoading: true, + }).catch(error => { + console.warn('提现申请API调用失败:', error) + throw error + }) } \ No newline at end of file diff --git a/pages/requestWithdrawal/requestWithdrawal.vue b/pages/requestWithdrawal/requestWithdrawal.vue index 5c6baad..65eba96 100644 --- a/pages/requestWithdrawal/requestWithdrawal.vue +++ b/pages/requestWithdrawal/requestWithdrawal.vue @@ -1,15 +1,23 @@