重构前端代码架构, 完善我的内容区

This commit is contained in:
zhonghua1
2026-01-11 12:11:01 +08:00
parent 1908ae0b2c
commit 3b169467ac
8 changed files with 989 additions and 519 deletions

View File

@@ -35,7 +35,19 @@
<uni-grid class="grid" :column="4" :showBorder="false" :square="true">
<uni-grid-item class="item" v-for="(item,index) in gridList" @click.native="tapGrid(index)" :key="index">
<uni-icons class="icon" color="#007AFF" :type="item.icon" size="26"></uni-icons>
<text class="text">{{item.text}}</text>
<view v-if="index === 0" class="device-text-wrapper">
<text class="device-label">设备总数</text>
<text class="device-count">{{totalDevices}}</text>
</view>
<view v-else-if="index === 1" class="device-text-wrapper">
<text class="device-label">人员总数</text>
<text class="device-count">{{totalSales}}</text>
</view>
<view v-else-if="index === 2" class="device-text-wrapper">
<text class="device-label">项目总数</text>
<text class="device-count">{{totalProjects}}</text>
</view>
<text v-else class="text">{{item.text}}</text>
</uni-grid-item>
</uni-grid>
<uni-list class="center-list" v-for="(sublist , index) in ucenterList" :key="index">
@@ -51,6 +63,12 @@
</uni-list-item>
</uni-list>
<!-- 设备绑定弹窗 -->
<device-bind-popup ref="deviceBindPopup" @success="onDeviceBindSuccess"></device-bind-popup>
<!-- 设备列表弹窗 -->
<device-list-popup ref="deviceListPopup"></device-list-popup>
<!-- 修改密码弹窗 -->
<uni-popup ref="changePwdPopup" type="dialog">
<view class="change-pwd-dialog">
@@ -93,8 +111,14 @@
store,
mutations
} from '@/uni_modules/uni-id-pages/common/store.js'
import { put } from '@/common/request.js'
import { put, get } from '@/common/request.js'
import DeviceBindPopup from './components/DeviceBindPopup.vue'
import DeviceListPopup from './components/DeviceListPopup.vue'
export default {
components: {
DeviceBindPopup,
DeviceListPopup
},
// #ifdef APP
onBackPress({from}) {
if(from=='backbutton'){
@@ -109,17 +133,20 @@
return {
tenantId: '',
loginUserInfo: {},
totalDevices: 0,
totalSales: 0,
totalProjects: 0,
gridList: [{
"text": this.$t('mine.showText'),
"icon": "chat"
"text": "设备总数",
"icon": "gear"
},
{
"text": this.$t('mine.showText'),
"icon": "cloud-upload"
"text": "人员总数",
"icon": "person-filled"
},
{
"text": this.$t('mine.showText'),
"icon": "contact"
"text": "项目总数",
"icon": "list"
},
{
"text": '修改密码',
@@ -142,25 +169,13 @@
},
// #endif
{
"title": this.$t('mine.signIn'),
"to": '/pages/reception/reception',
"title": "设备绑定",
"event": 'openDeviceBind',
"icon": "compose"
},
// #ifdef APP-PLUS
{
"title": this.$t('mine.toEvaluate'),
"event": 'gotoMarket',
"icon": "star"
},
//#endif
{
"title":this.$t('mine.readArticles'),
"to": '/pages/customer/customer',
"icon": "flag"
},
{
"title": this.$t('mine.myScore'),
"to": '/pages/team/team',
"title": "设备列表",
"event": 'openDeviceList',
"icon": "paperplane"
}
// #ifdef APP
@@ -172,10 +187,6 @@
// #endif
],
[{
"title": this.$t('mine.feedback'),
"to": '/pages/champion/champion',
"icon": "help"
}, {
"title": this.$t('mine.settings'),
"to": '/pages/ucenter/settings/settings',
"icon": "gear"
@@ -216,6 +227,12 @@
onShow() {
// 每次显示页面时更新租户信息和登录人信息
this.loadUserInfo()
// 加载设备统计信息
this.loadDeviceStatistics()
// 加载销售(人员)统计信息
this.loadSalesStatistics()
// 加载项目统计信息
this.loadProjectStatistics()
},
computed: {
userInfo() {
@@ -254,6 +271,60 @@
console.error('加载用户信息失败:', e)
}
},
/**
* 加载设备统计信息
*/
async loadDeviceStatistics() {
try {
const res = await get('/api/deviceManagement/statistics')
if (res.statusCode === 200 && res.data && res.data.success) {
this.totalDevices = res.data.data?.totalDevices || 0
} else {
console.error('获取设备统计信息失败:', res.data?.message || '未知错误')
this.totalDevices = 0
}
} catch (e) {
console.error('获取设备统计信息异常:', e)
this.totalDevices = 0
}
},
/**
* 加载销售(人员)统计信息
*/
async loadSalesStatistics() {
try {
const res = await get('/api/salesManagement/statistics')
if (res.statusCode === 200 && res.data && res.data.success) {
this.totalSales = res.data.data?.totalSales || 0
} else {
console.error('获取销售统计信息失败:', res.data?.message || '未知错误')
this.totalSales = 0
}
} catch (e) {
console.error('获取销售统计信息异常:', e)
this.totalSales = 0
}
},
/**
* 加载项目统计信息
*/
async loadProjectStatistics() {
try {
const res = await get('/api/projectManagement/statistics')
if (res.statusCode === 200 && res.data && res.data.success) {
this.totalProjects = res.data.data?.totalProjects || 0
} else {
console.error('获取项目统计信息失败:', res.data?.message || '未知错误')
this.totalProjects = 0
}
} catch (e) {
console.error('获取项目统计信息异常:', e)
this.totalProjects = 0
}
},
toSettings() {
uni.navigateTo({
url: "/pages/ucenter/settings/settings"
@@ -447,6 +518,29 @@
})
// #endif
},
/**
* 打开设备绑定弹窗
*/
openDeviceBind() {
if (this.$refs.deviceBindPopup) {
this.$refs.deviceBindPopup.open()
}
},
/**
* 设备绑定成功回调
*/
onDeviceBindSuccess() {
// 刷新设备统计信息
this.loadDeviceStatistics()
},
/**
* 打开设备列表弹窗
*/
openDeviceList() {
if (this.$refs.deviceListPopup) {
this.$refs.deviceListPopup.open()
}
},
/**
* 打开修改密码弹窗
*/
@@ -678,6 +772,27 @@
align-items: center;
}
.device-text-wrapper {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.device-label {
font-size: 14px;
color: #817f82;
line-height: 20px;
margin-bottom: 2px;
}
.device-count {
font-size: 18px;
font-weight: bold;
color: #007AFF;
line-height: 22px;
}
/*修改边线粗细示例*/
/* #ifndef APP-NVUE */