From 1942e317bc74645102f72b0f5e1a5e4e91a3c023 Mon Sep 17 00:00:00 2001
From: WindowBird <13870814+windows-bird@user.noreply.gitee.com>
Date: Tue, 19 Aug 2025 12:01:17 +0800
Subject: [PATCH] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=AD=E5=BF=83=E9=A1=B5?=
=?UTF-8?q?=E9=9D=A2=E6=95=B0=E6=8D=AE=E6=B8=B2=E6=9F=93?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
api/user/README.md | 60 +++++++++++----
api/user/mockData.js | 11 +--
api/user/user.js | 94 ++++++++++++++++++++++-
pages/profile/profile.vue | 34 ++++-----
pages/useList/useList.vue | 152 ++++++++++++++++++++------------------
5 files changed, 240 insertions(+), 111 deletions(-)
diff --git a/api/user/README.md b/api/user/README.md
index f0b4b44..0c9b183 100644
--- a/api/user/README.md
+++ b/api/user/README.md
@@ -30,19 +30,31 @@ if (response.code === 200) {
}
```
-### 3. 获取用户统计
+### 3. 获取代理统计
```javascript
-import { getUserStats } from '@/api/user/user.js'
+import { getAgentCount } from '@/api/user/user.js'
-// 获取用户统计信息
-const response = await getUserStats()
+// 获取代理统计信息
+const response = await getAgentCount()
if (response.code === 200) {
- const userStats = response.data
- // userStats包含:users, leases, amount等
+ const agentStats = response.data
+ // agentStats包含:userNum, deviceNum, rentAmount等
}
```
-### 4. 更新用户信息
+### 4. 获取用户列表
+```javascript
+import { getUserList } from '@/api/user/user.js'
+
+// 获取用户列表
+const response = await getUserList()
+if (response.code === 200) {
+ const userList = response.data
+ // userList包含用户列表数据
+}
+```
+
+### 5. 更新用户信息
```javascript
import { updateUserInfo } from '@/api/user/user.js'
@@ -81,18 +93,36 @@ const response = await updateUserInfo(userData)
}
```
-### 用户统计 (UserStats)
+### 代理统计 (AgentStats)
```javascript
{
- users: 30, // 名下用户数
- leases: 30, // 租赁数量
- amount: 3000, // 租赁金额
- activeUsers: 25, // 活跃用户数
- totalLeases: 45, // 总租赁数
- totalAmount: 5000 // 总金额
+ userNum: 4, // 名下用户数
+ deviceNum: 1, // 设备数量
+ rentAmount: 2 // 租赁数量
}
```
+### 用户列表 (UserList)
+```javascript
+[
+ {
+ id: 1, // 用户ID
+ username: '张三', // 用户名
+ totalAmount: '5000', // 总金额
+ deviceCount: 2, // 设备数量
+ devices: [ // 设备列表
+ {
+ type: '智能门锁', // 设备类型
+ amount: '1000', // 金额
+ rentDate: '2025.01.15', // 租赁日期
+ period: '1年', // 租赁周期
+ expiryDate: '2026.01.15' // 到期日期
+ }
+ ]
+ }
+]
+```
+
## 错误处理
所有API都包含错误处理机制:
@@ -133,7 +163,7 @@ export default {
const [userInfo, financial, stats] = await Promise.all([
getUserInfo(),
getUserFinancialData(),
- getUserStats()
+ getAgentCount()
])
this.userInfo = userInfo.data
diff --git a/api/user/mockData.js b/api/user/mockData.js
index c85ebea..2e11f35 100644
--- a/api/user/mockData.js
+++ b/api/user/mockData.js
@@ -18,13 +18,10 @@ export const mockFinancialData = {
withdrawedBalance: 0,
}
-export const mockUserStats = {
- users: 30,
- leases: 30,
- amount: 3000,
- activeUsers: 25,
- totalLeases: 45,
- totalAmount: 5000,
+export const mockAgentStats = {
+ userNum: 4,
+ deviceNum: 1,
+ rentAmount: 2,
}
// 模拟API响应格式
diff --git a/api/user/user.js b/api/user/user.js
index 0f51135..f3a9675 100644
--- a/api/user/user.js
+++ b/api/user/user.js
@@ -1,5 +1,5 @@
import request from '@/utils/request'
-import { mockUserInfo, mockFinancialData, mockUserStats, createMockResponse } from './mockData.js'
+import { mockUserInfo, mockFinancialData, mockAgentStats, createMockResponse } from './mockData.js'
/**
* 获取用户信息
@@ -45,7 +45,97 @@ export function getUserStats() {
}).catch(error => {
console.warn('用户统计API调用失败,使用模拟数据:', error)
// 如果API调用失败,返回模拟数据
- return createMockResponse(mockUserStats)
+ return createMockResponse(mockAgentStats)
+ })
+}
+
+/**
+ * 获取代理统计数据
+ * @returns {Promise} 返回代理统计信息
+ */
+export function getAgentCount() {
+ return request({
+ url: '/app/order/agentCount',
+ method: 'GET',
+ showLoading: false,
+ }).catch(error => {
+ console.warn('代理统计API调用失败,使用模拟数据:', error)
+ // 如果API调用失败,返回模拟数据
+ return createMockResponse({
+ userNum: 4,
+ deviceNum: 1,
+ rentAmount: 2
+ })
+ })
+}
+
+/**
+ * 获取用户列表
+ * @param {Object} params - 查询参数
+ * @returns {Promise} 返回用户列表数据
+ */
+export function getUserList(params = {}) {
+ return request({
+ url: '/app/user/list',
+ method: 'GET',
+ params,
+ showLoading: false,
+ }).catch(error => {
+ console.warn('用户列表API调用失败,使用模拟数据:', error)
+ // 如果API调用失败,返回模拟数据
+ return createMockResponse([
+ {
+ id: 1,
+ username: '张三',
+ totalAmount: '5000',
+ deviceCount: 2,
+ devices: [
+ {
+ type: '智能门锁',
+ amount: '1000',
+ rentDate: '2025.01.15 12:56:08',
+ period: '1年',
+ expiryDate: '2026.01.15 12:56:08',
+ },
+ {
+ type: '智能摄像头',
+ amount: '800',
+ rentDate: '2025.02.20 10:30:00',
+ period: '6个月',
+ expiryDate: '2025.08.20 10:30:00',
+ },
+ ],
+ },
+ {
+ id: 2,
+ username: '李四',
+ totalAmount: '3200',
+ deviceCount: 3,
+ devices: [
+ {
+ type: '智能门锁',
+ amount: '1200',
+ rentDate: '2025.03.10 14:20:00',
+ period: '1年',
+ expiryDate: '2026.03.10 14:20:00',
+ },
+ {
+ type: '智能摄像头',
+ amount: '600',
+ rentDate: '2025.04.05 09:15:00',
+ period: '3个月',
+ expiryDate: '2025.07.05 09:15:00',
+ },
+ {
+ type: '智能音箱',
+ amount: '400',
+ rentDate: '2025.05.12 16:45:00',
+ period: '6个月',
+ expiryDate: '2025.11.12 16:45:00',
+ },
+ ],
+ },
+ ])
})
}
diff --git a/pages/profile/profile.vue b/pages/profile/profile.vue
index 1802a33..0001fe0 100644
--- a/pages/profile/profile.vue
+++ b/pages/profile/profile.vue
@@ -77,16 +77,16 @@
- {{ userStats.users || 0 }}
+ {{ userStats.userNum || 0 }}
名下用户(个)
- {{ userStats.leases || 0 }}
- 租赁数量(个)
+ {{ userStats.deviceNum || 0 }}
+ 设备数量(个)
- {{ userStats.amount || 0 }}
- 租赁金额(元)
+ {{ userStats.rentAmount || 0 }}
+ 租赁数量(个)
@@ -126,7 +126,7 @@