大改动,清理个人中心页面冗余模拟数据

This commit is contained in:
WindowBird 2025-08-30 10:33:41 +08:00
parent 76f237ecab
commit 9c1475c59c
4 changed files with 14 additions and 434 deletions

View File

@ -1,282 +0,0 @@
# 用户模块 API 文档
## 接口列表
### 1. 获取用户信息
```javascript
import { getUserInfo } from '@/api/user/user.js'
const response = await getUserInfo()
```
**接口地址:** `GET /app/user/info`
**响应数据:**
```javascript
{
userId: '1', // 用户ID
nickName: '超级管理员', // 用户昵称
phonenumber: '15888888888', // 手机号
avatar: 'https://...', // 头像URL
email: null, // 邮箱
sex: null, // 性别
status: '0', // 状态
createTime: null, // 创建时间
updateTime: null // 更新时间
}
```
### 2. 获取用户财务数据
```javascript
import { getUserFinancialData } from '@/api/user/user.js'
const response = await getUserFinancialData()
```
**接口地址:** `GET /app/user/financial`
**响应数据:**
```javascript
{
balance: 10000.00, // 余额
waitBalance: 0, // 待结算余额
withdrawBalance: 0, // 可提现余额
withdrawedBalance: 0 // 已提现余额
}
```
### 3. 获取代理统计
```javascript
import { getAgentCount } from '@/api/user/user.js'
const response = await getAgentCount()
```
**接口地址:** `GET /app/order/agentCount`
**响应数据:**
```javascript
{
userNum: 4, // 名下用户数
deviceNum: 1, // 设备数量
rentAmount: 2 // 租赁数量
}
```
### 4. 获取代理用户列表
```javascript
import { getAgentList } from '@/api/user/user.js'
const response = await getAgentList({
beginTime: '2024-10-10 12:10:00', // 开始时间(筛选)
endTime: '2026-10-10 12:10:00', // 结束时间(筛选)
name: '李' // 用户昵称(搜索)
})
```
**接口地址:** `GET /app/order/agentList`
**请求参数:**
- `beginTime` (string, 可选): 开始时间,格式: YYYY-MM-DD HH:mm:ss
- `endTime` (string, 可选): 结束时间,格式: YYYY-MM-DD HH:mm:ss
- `name` (string, 可选): 用户昵称,支持模糊搜索
**响应数据:**
```javascript
[
{
userId: '28', // 用户ID
nickName: '李四', // 用户昵称
avatar: '', // 头像
totalAmount: 730.00, // 总金额
deviceNum: 2, // 设备数量
orders: [ // 订单列表
{
id: '3', // 订单ID
userId: '28', // 用户ID
name: '派大星', // 联系人姓名
phone: '13777777777', // 联系电话
address: '广西南宁市西乡塘区', // 地址
detailed: '详细地址', // 详细地址
typeName: '单头灶', // 设备类型名称
suitName: '一年', // 套餐名称
suitDay: '365', // 套餐天数
amount: 365.00, // 金额
status: '2', // 订单状态
leaseTime: '2025-08-15 10:50:22', // 租赁时间
expirationTime: '2025-11-15 10:50:25', // 到期时间
orderNumber: '123456789101114' // 订单号
}
]
}
]
```
### 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'
const response = await updateUserInfo({
nickName: '新昵称',
email: 'new@example.com'
})
```
**接口地址:** `PUT /app/user/info`
## 使用示例
### 在提现页面中
```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 页面中
async fetchUserData() {
try {
const [userInfo, financial, stats] = await Promise.all([
getUserInfo(),
getUserFinancialData(),
getAgentCount()
])
this.userInfo = userInfo.data
this.financialData = financial.data
this.userStats = stats.data
} catch (error) {
console.error('获取用户数据失败:', error)
}
}
```
### 在用户列表页面中
```javascript
// 在用户列表页面中
async fetchUserList() {
try {
const params = {
beginTime: '2024-10-10 00:00:00',
endTime: '2026-10-10 23:59:59',
name: '李'
}
const response = await getAgentList(params)
if (response.code === 200) {
// 转换数据格式
this.users = response.data.map(user => ({
...user,
devices: user.orders.map(order => ({
type: order.typeName,
amount: order.amount,
rentDate: this.formatDate(order.leaseTime),
period: order.suitName,
expiryDate: this.formatDate(order.expirationTime)
}))
}))
}
} catch (error) {
console.error('获取用户列表失败:', error)
}
}
```
## 错误处理
所有API函数都包含错误处理机制如果API调用失败会自动返回模拟数据
```javascript
// 如果API调用失败会返回模拟数据
const response = await getUserInfo()
// 即使网络错误,也会返回模拟的用户信息
```
## 模拟数据
当API不可用时系统会自动使用模拟数据
- `mockUserInfo`: 用户基本信息
- `mockFinancialData`: 财务数据
- `mockAgentStats`: 代理统计数据
- `mockAgentList`: 代理用户列表数据
- `mockWithdrawInfo`: 提现信息数据
- `mockBanks`: 银行列表数据

View File

@ -1,115 +0,0 @@
// 用户相关模拟数据
export const mockUserInfo = {
userId: '1',
nickName: '超级管理员',
phonenumber: '15888888888',
avatar: 'https://api.ccttiot.com/FhzRBfWKKOWOMJA1vV3sxMw_nVZ',
email: null,
sex: null,
status: '0',
createTime: null,
updateTime: null,
}
export const mockFinancialData = {
balance: 10000.00,
waitBalance: 0,
withdrawBalance: 0,
withdrawedBalance: 0,
}
export const mockAgentStats = {
userNum: 4,
deviceNum: 1,
rentAmount: 2,
}
export const mockAgentList = [
{
userId: '28',
nickName: '李四',
avatar: '',
totalAmount: 730.00,
deviceNum: 2,
orders: [
{
id: '3',
userId: '28',
name: '派大星',
phone: '13777777777',
address: '广西南宁市西乡塘区',
detailed: '详细地址',
typeName: '单头灶',
suitName: '一年',
suitDay: '365',
amount: 365.00,
status: '2',
leaseTime: '2025-08-15 10:50:22',
expirationTime: '2025-11-15 10:50:25',
orderNumber: '123456789101114',
},
{
id: '4',
userId: '28',
name: '派大星',
phone: '137777777777',
address: '测试',
detailed: '测试',
typeName: '单头灶',
suitName: '一年',
suitDay: '365',
amount: 365.00,
status: '2',
leaseTime: '2025-08-18 14:10:26',
expirationTime: '2025-10-01 14:10:29',
orderNumber: '123456789101115',
}
]
}
]
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 {
code,
msg,
data,
}
}

View File

@ -1,13 +1,5 @@
import request from '@/utils/request'
import {
mockUserInfo,
mockFinancialData,
mockAgentStats,
mockAgentList,
mockWithdrawInfo,
mockBanks,
createMockResponse,
} from './mockData.js'
import { uploadFile } from '@/utils/request.js'
/**
@ -29,15 +21,8 @@ export function getUserInfo() {
return response
})
.catch(error => {
console.warn('用户信息API调用失败使用模拟数据:', error)
// 如果API调用失败返回模拟数据
const mockResponse = createMockResponse(mockUserInfo)
// 模拟数据中如果有用户ID也存入本地存储
if (mockResponse.data && mockResponse.data.userId) {
uni.setStorageSync('userId', mockResponse.data.userId)
console.log('模拟数据用户ID已存入本地存储:', mockResponse.data.userId)
}
return mockResponse
console.warn('用户信息API调用失败:', error)
return null
})
}
@ -51,9 +36,8 @@ export function getUserFinancialData() {
method: 'GET',
showLoading: false,
}).catch(error => {
console.warn('财务数据API调用失败使用模拟数据:', error)
// 如果API调用失败返回模拟数据
return createMockResponse(mockFinancialData)
console.warn('财务数据API调用失败:', error)
return null
})
}
@ -67,9 +51,8 @@ export function getUserStats() {
method: 'GET',
showLoading: false,
}).catch(error => {
console.warn('用户统计API调用失败使用模拟数据:', error)
// 如果API调用失败返回模拟数据
return createMockResponse(mockAgentStats)
console.warn('用户统计API调用失败:', error)
return null
})
}
@ -83,13 +66,8 @@ export function getAgentCount() {
method: 'GET',
showLoading: false,
}).catch(error => {
console.warn('代理统计API调用失败使用模拟数据:', error)
// 如果API调用失败返回模拟数据
return createMockResponse({
userNum: 4,
deviceNum: 1,
rentAmount: 2,
})
console.warn('代理统计API调用失败:', error)
return null
})
}
@ -108,9 +86,8 @@ export function getAgentList(params = {}) {
params,
showLoading: false,
}).catch(error => {
console.warn('代理用户列表API调用失败使用模拟数据:', error)
// 如果API调用失败返回模拟数据
return createMockResponse(mockAgentList)
console.warn('代理用户列表API调用失败:', error)
return null
})
}
@ -181,8 +158,8 @@ export function computedServiceAmount(amount) {
showLoading: false,
params: { amount },
}).catch(error => {
console.warn('服务费用API调用失败,使用模拟数据:', error)
return createMockResponse(mockWithdrawInfo)
console.warn('服务费用API调用失败:', error)
return null
})
}

View File

@ -133,7 +133,7 @@ export default {
serviceModalVisible: false,
commonEnum,
userInfo: {
nickName: '昵称',
nickName: '',
avatar: '',
userId: '',