c293da23
刘淇
新园林init
|
1
|
<template>
|
37c26bd3
刘淇
巡查计划
|
2
|
<!-- 外层容器:包含蓝色块 + 原始内容 -->
|
c293da23
刘淇
新园林init
|
3
|
<view class="workbench-container">
|
9b30ab8c
刘淇
新增快速工单,原版
|
4
5
6
7
8
9
10
11
|
<!-- 加载页:覆盖整个容器,渲染完成后隐藏 -->
<up-loading-page
v-if="loading"
loading-text="加载中..."
color="#577ee3"
style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999;"
></up-loading-page>
|
37c26bd3
刘淇
巡查计划
|
12
13
|
<!-- 蓝色装饰块:#577ee3 -->
<view class="blue-decor-block"></view>
|
c293da23
刘淇
新园林init
|
14
|
|
37c26bd3
刘淇
巡查计划
|
15
16
17
18
|
<!-- 原始内容容器:仅添加定位和顶部偏移实现压边 -->
<view class="content-wrap">
<!-- uview-plus空状态组件 -->
<u-empty
|
9b30ab8c
刘淇
新增快速工单,原版
|
19
|
v-if="!moduleList.length && !loading"
|
37c26bd3
刘淇
巡查计划
|
20
21
22
23
24
25
26
|
mode="list"
text="暂无菜单数据"
color="#999"
font-size="28rpx"
></u-empty>
<!-- 菜单卡片列表(修复header插槽语法,恢复标题显示) -->
|
9b30ab8c
刘淇
新增快速工单,原版
|
27
|
<view v-else-if="!loading" class="menu-card-wrap">
|
37c26bd3
刘淇
巡查计划
|
28
|
<up-card
|
993d98fa
刘淇
工作台
|
29
30
31
32
|
:title-size="18"
v-for="(parentModule, index) in moduleList"
:key="parentModule.id"
:title="parentModule.name"
|
37c26bd3
刘淇
巡查计划
|
33
|
>
|
37c26bd3
刘淇
巡查计划
|
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
<template #body>
<view>
<up-grid
:border="false"
col="4"
>
<up-grid-item
v-for="(listItem,listIndex) in parentModule.children"
:key="listItem.id"
@click="handleMenuClick(listItem)"
>
<u-image
:src="listItem.icon "
mode="aspectFit"
width="80rpx"
height="80rpx"
lazy-load
radius="16rpx"
></u-image>
<text class="grid-text">{{ listItem.name }}</text>
</up-grid-item>
</up-grid>
<up-toast ref="uToastRef"/>
</view>
</template>
</up-card>
|
c293da23
刘淇
新园林init
|
60
61
62
63
64
|
</view>
</view>
</view>
</template>
|
37c26bd3
刘淇
巡查计划
|
65
|
<script setup lang="ts">
|
9b30ab8c
刘淇
新增快速工单,原版
|
66
|
// 原始代码完全保留,新增loading状态
|
37c26bd3
刘淇
巡查计划
|
67
|
import {ref, nextTick} from 'vue';
|
993d98fa
刘淇
工作台
|
68
69
70
71
|
import { onShow } from '@dcloudio/uni-app';
import { useUserStore } from '@/pinia/user';
import globalConfig from '@/common/config/global';
import cache from '@/common/utils/cache';
|
37c26bd3
刘淇
巡查计划
|
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
interface MenuItem {
id: number;
name: string;
subtitle?: string;
type: number;
sort: number;
parentId: number;
icon: string;
jumpUrl: string;
miniAppId?: string;
badgeText?: string;
badgeColor?: string;
statisticCount: number | null;
hasStatistic: boolean;
extra: any;
children: MenuItem[];
}
|
c293da23
刘淇
新园林init
|
90
|
|
9b30ab8c
刘淇
新增快速工单,原版
|
91
92
|
// 新增:加载状态(默认开启)
const loading = ref(true);
|
c293da23
刘淇
新园林init
|
93
|
const userStore = useUserStore();
|
37c26bd3
刘淇
巡查计划
|
94
95
96
97
98
99
100
101
102
103
|
const moduleList = ref<MenuItem[]>([]);
// 无用变量(保留避免警告)
const subTitle = ref('');
const thumb = ref('');
const border = ref(true);
const click = () => {
};
const headClick = () => {
};
|
c293da23
刘淇
新园林init
|
104
|
|
37c26bd3
刘淇
巡查计划
|
105
|
onShow(async () => {
|
c293da23
刘淇
新园林init
|
106
|
try {
|
9b30ab8c
刘淇
新增快速工单,原版
|
107
108
109
|
// 重置加载状态
loading.value = true;
|
993d98fa
刘淇
工作台
|
110
|
const rawMenuData = userStore.moduleListInfo || cache.get(globalConfig.cache.moduleListKey);
|
37c26bd3
刘淇
巡查计划
|
111
112
|
const menuData = rawMenuData || [];
moduleList.value = menuData;
|
9b30ab8c
刘淇
新增快速工单,原版
|
113
114
|
// 关键:等待DOM完全渲染后再隐藏加载页
|
37c26bd3
刘淇
巡查计划
|
115
|
await nextTick();
|
9b30ab8c
刘淇
新增快速工单,原版
|
116
117
118
119
120
|
// 额外延迟(可选,确保视觉更流畅)
setTimeout(() => {
loading.value = false;
}, 300);
|
37c26bd3
刘淇
巡查计划
|
121
122
123
124
|
console.log('菜单数据:', moduleList.value);
} catch (error) {
console.error('获取菜单数据失败:', error);
moduleList.value = [];
|
9b30ab8c
刘淇
新增快速工单,原版
|
125
126
127
|
// 出错时也隐藏加载页
await nextTick();
loading.value = false;
|
c293da23
刘淇
新园林init
|
128
|
}
|
37c26bd3
刘淇
巡查计划
|
129
|
});
|
c293da23
刘淇
新园林init
|
130
|
|
37c26bd3
刘淇
巡查计划
|
131
132
133
134
135
136
137
138
|
const handleMenuClick = (item: MenuItem) => {
if (!item.jumpUrl) {
uni.showToast({
title: '暂无跳转链接',
icon: 'none',
duration: 2000
});
return;
|
c293da23
刘淇
新园林init
|
139
|
}
|
37c26bd3
刘淇
巡查计划
|
140
141
142
143
144
145
146
147
148
149
150
151
|
console.log(item.jumpUrl)
uni.navigateTo({
url: item.jumpUrl,
fail: (err) => {
console.error('页面跳转失败:', err);
uni.showToast({
title: '页面路径错误',
icon: 'none',
duration: 2000
});
}
});
|
c293da23
刘淇
新园林init
|
152
153
154
155
|
};
</script>
<style scoped>
|
37c26bd3
刘淇
巡查计划
|
156
|
/* 仅新增/保留必要样式,不修改卡片核心样式 */
|
c293da23
刘淇
新园林init
|
157
|
.workbench-container {
|
37c26bd3
刘淇
巡查计划
|
158
|
width: 100%;
|
c293da23
刘淇
新园林init
|
159
|
min-height: 100vh;
|
37c26bd3
刘淇
巡查计划
|
160
161
|
position: relative;
background-color: #fff;
|
c293da23
刘淇
新园林init
|
162
|
}
|
37c26bd3
刘淇
巡查计划
|
163
164
165
166
167
168
169
170
171
172
|
/* 蓝色块样式 */
.blue-decor-block {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 200px;
background-color: #577ee3;
z-index: 1;
|
c293da23
刘淇
新园林init
|
173
|
}
|
37c26bd3
刘淇
巡查计划
|
174
175
176
177
178
|
/* 内容容器样式 */
.content-wrap {
position: relative;
z-index: 2;
|
37c26bd3
刘淇
巡查计划
|
179
|
padding-top: 160px;
|
c293da23
刘淇
新园林init
|
180
|
}
|
37c26bd3
刘淇
巡查计划
|
181
182
183
184
185
|
/* 第一张卡片层级 */
.first-card-position {
position: relative;
z-index: 3;
|
c293da23
刘淇
新园林init
|
186
|
}
|
37c26bd3
刘淇
巡查计划
|
187
188
189
190
191
192
|
/* 仅补充标题文字基础样式(确保显示,不修改卡片其他样式) */
.card-title-text {
font-size: 32rpx;
color: #333;
font-weight: 600;
|
c293da23
刘淇
新园林init
|
193
|
}
|
37c26bd3
刘淇
巡查计划
|
194
195
196
|
/* 网格文字样式(保留原始) */
.grid-text {
|
c293da23
刘淇
新园林init
|
197
|
font-size: 24rpx;
|
37c26bd3
刘淇
巡查计划
|
198
199
200
|
color: #333;
text-align: center;
margin-top: 10rpx;
|
c293da23
刘淇
新园林init
|
201
|
}
|
9b30ab8c
刘淇
新增快速工单,原版
|
202
203
204
205
206
|
/* 加载页样式优化(可选) */
:deep(.up-loading-page) {
background-color: rgba(255, 255, 255, 0.9);
}
|
37c26bd3
刘淇
巡查计划
|
207
|
</style>
|