index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <template>
  2. <view class="server-page">
  3. <!-- 状态栏占位 -->
  4. <view class="device-detail__header">
  5. <u-icon
  6. size="36"
  7. class="arrow-left"
  8. name="arrow-left"
  9. @click="goBack"
  10. ></u-icon>
  11. 更多服务
  12. </view>
  13. <!-- 主内容区域 -->
  14. <view class="content-container">
  15. <!-- 加载状态 -->
  16. <view class="loading-container" v-if="loading">
  17. <u-loading mode="circle" size="80"></u-loading>
  18. <text class="loading-text">加载中...</text>
  19. </view>
  20. <!-- 空数据状态 -->
  21. <view class="empty-container" v-else-if="menuList.length === 0">
  22. <image :src="$imageURL + '/bigdata_app/newindex/empty.png'" mode="aspectFit" class="empty-img"></image>
  23. <text class="empty-text">暂无数据</text>
  24. </view>
  25. <!-- 菜单网格 -->
  26. <view class="menu-grid" v-else>
  27. <view
  28. class="menu-item"
  29. v-for="(item, index) in menuList"
  30. :key="item.pur_id || index"
  31. >
  32. <view class="menu-icon-wrap">
  33. <text class="menu-name">{{ item.purview_name }}</text>
  34. <view class="menu-icon-container">
  35. <view class="menu-icon" v-for="(child, childIndex) in item.children" :key="child.pur_id || childIndex"
  36. >
  37. <view @click="() => handleMenuClick(child)" class="menu-item-wraper">
  38. <image :src="child.app_menu_icon || getDefaultIcon(child.icon)" mode="aspectFit" class="app_menu_icon"></image>
  39. <text class="menu-icon-text">{{ getSlice(child.purview_name) }}</text>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. export default {
  51. data() {
  52. return {
  53. loading: true,
  54. menuList: [],
  55. deviceTypeList:[
  56. 36,
  57. 40,
  58. 42,
  59. 44,
  60. 202,
  61. 282,
  62. 426,
  63. 427,
  64. 428,
  65. 233,
  66. 456,
  67. 458
  68. ],
  69. }
  70. },
  71. onLoad() {
  72. this.getMenuList()
  73. },
  74. methods: {
  75. getSlice(name){
  76. return name.slice(0,4)
  77. },
  78. // 获取菜单列表
  79. async getMenuList() {
  80. try {
  81. this.loading = true
  82. const res = await this.$myRequest({
  83. url: '/api/api_gateway?method=user.login.user_login_info',
  84. method: 'POST',
  85. data: {
  86. is_app: 1
  87. }
  88. })
  89. console.log(res,'resresres')
  90. if (res.length > 0) {
  91. // 获取第一层数据
  92. this.menuList = res.filter(item => item.children && item.children.length > 0)
  93. console.log(this.menuList,'menuListmenuList')
  94. }
  95. } catch (error) {
  96. console.error('获取菜单列表失败:', error)
  97. uni.showToast({
  98. title: '获取菜单失败',
  99. icon: 'none'
  100. })
  101. } finally {
  102. this.loading = false
  103. }
  104. },
  105. // 获取默认图标
  106. getDefaultIcon(icon) {
  107. const iconMap = {
  108. 'forecast': this.$imageURL + '/bigdata_app/newindex/cb.png',
  109. 'sex-lure': this.$imageURL + '/bigdata_app/newindex/cb.png',
  110. 'color-lure': this.$imageURL + '/bigdata_app/newindex/fz.png',
  111. 'control': this.$imageURL + '/bigdata_app/newindex/fz.png',
  112. 'weather': this.$imageURL + '/bigdata_app/newindex/qxyj.png',
  113. 'seedling': this.$imageURL + '/bigdata_app/newindex/base.png',
  114. 'disaster': this.$imageURL + '/bigdata_app/newindex/hj.png',
  115. 'soil': this.$imageURL + '/bigdata_app/newindex/sqyj.png',
  116. 'video': this.$imageURL + '/bigdata_app/newindex/jk.png',
  117. 'irrigate': this.$imageURL + '/bigdata_app/newindex/guangai.png',
  118. 'water': this.$imageURL + '/bigdata_app/newindex/guangai.png',
  119. 'four-mood': this.$imageURL + '/bigdata_app/newindex/base.png',
  120. 'expert': this.$imageURL + '/bigdata_app/newindex/knowledge.png',
  121. 'data': this.$imageURL + '/bigdata_app/newindex/user.png',
  122. 'setting': this.$imageURL + '/bigdata_app/newindex/user.png'
  123. }
  124. return iconMap[icon] || this.$imageURL + '/bigdata_app/newindex/base.png'
  125. },
  126. // 处理菜单点击
  127. handleMenuClick(item) {
  128. console.log('点击菜单:', item)
  129. // 根据不同的pur_id跳转到不同的页面
  130. const purId = item.pur_id
  131. // 虫情监测模块
  132. if (this.deviceTypeList.includes(purId)) {
  133. uni.switchTab({
  134. url: '/pages/equipList2/index',
  135. success: () => {
  136. setTimeout(() => {
  137. uni.$emit('purId',purId);
  138. }, 50);
  139. }
  140. })
  141. }
  142. // 四情基地
  143. else if (purId == 25) {
  144. uni.navigateTo({
  145. url: '/pages/fourBase/index'
  146. })
  147. }else if(purId == 125){
  148. uni.navigateTo({
  149. url: '/pages/expertDiagnosis/index'
  150. })
  151. }
  152. else if (purId == 126) {
  153. uni.navigateTo({
  154. url: '/pages/expertDiagnosis/wormcase?name=虫情百科'
  155. })
  156. }
  157. // 用户管理 || purId == 156
  158. else if (purId == 29) {
  159. uni.navigateTo({
  160. url: '/pages/equipMange/index/index'
  161. })
  162. }
  163. else if (purId == 156) {
  164. uni.navigateTo({
  165. url: '/pages/afterSale/index'
  166. })
  167. }else if(purId == 422){
  168. uni.navigateTo({
  169. url: '/pages/warning/index'
  170. })
  171. }
  172. // 默认跳转到开发中页面
  173. else {
  174. uni.navigateTo({
  175. url: '/pages/index/developing'
  176. })
  177. }
  178. },
  179. // 返回上一页
  180. goBack() {
  181. uni.navigateBack({
  182. delta: 1
  183. })
  184. }
  185. }
  186. }
  187. </script>
  188. <style lang="scss" scoped>
  189. .server-page {
  190. width: 100%;
  191. min-height: calc(100vh - 112rpx);
  192. padding-top: 112rpx;
  193. overflow-y: auto;
  194. background: linear-gradient(180deg, #D3F4E3 10.82%, #F5F6FA 16.29%, #f5f6fa00 100%), #F5F6FA;
  195. }
  196. .device-detail__header {
  197. width: 100%;
  198. font-size: 28rpx;
  199. color: #999;
  200. color: #042118;
  201. font-family: 'Source Han Sans CN VF';
  202. font-weight: 700;
  203. position: relative;
  204. text-align: center;
  205. .arrow-left {
  206. position: absolute;
  207. left: 32rpx;
  208. margin-right: 12rpx;
  209. }
  210. }
  211. .status_bar {
  212. height: var(--status-bar-height);
  213. width: 100%;
  214. background-color: #fff;
  215. }
  216. .nav-bar {
  217. width: 100%;
  218. background-color: #fff;
  219. border-bottom: 1px solid #e5e5e5;
  220. .nav-bar-content {
  221. display: flex;
  222. align-items: center;
  223. justify-content: space-between;
  224. height: 88rpx;
  225. padding: 0 30rpx;
  226. .nav-back {
  227. width: 60rpx;
  228. height: 60rpx;
  229. display: flex;
  230. align-items: center;
  231. justify-content: center;
  232. }
  233. .nav-title {
  234. font-size: 36rpx;
  235. font-weight: 500;
  236. color: #333;
  237. }
  238. .nav-placeholder {
  239. width: 60rpx;
  240. }
  241. }
  242. }
  243. .content-container {
  244. padding: 30rpx;
  245. padding-bottom: 100rpx;
  246. }
  247. .loading-container {
  248. display: flex;
  249. flex-direction: column;
  250. align-items: center;
  251. justify-content: center;
  252. padding-top: 200rpx;
  253. .loading-text {
  254. margin-top: 30rpx;
  255. font-size: 28rpx;
  256. color: #999;
  257. }
  258. }
  259. .empty-container {
  260. display: flex;
  261. flex-direction: column;
  262. align-items: center;
  263. justify-content: center;
  264. padding-top: 200rpx;
  265. .empty-img {
  266. width: 300rpx;
  267. height: 300rpx;
  268. }
  269. .empty-text {
  270. margin-top: 30rpx;
  271. font-size: 28rpx;
  272. color: #999;
  273. }
  274. }
  275. .menu-grid {
  276. display: grid;
  277. gap: 30rpx 20rpx;
  278. .menu-item {
  279. background-color: #fff;
  280. border-radius: 20rpx;
  281. padding: 30rpx 20rpx;
  282. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
  283. transition: all 0.3s ease;
  284. .menu-icon-wrap {
  285. margin-bottom: 16rpx;
  286. .menu-name{
  287. color: #333333;
  288. font-family: "Source Han Sans CN VF";
  289. font-size: 28rpx;
  290. font-weight: 700;
  291. }
  292. .menu-icon-container{
  293. margin-top: 20rpx;
  294. }
  295. .menu-item-wraper{
  296. display: flex;
  297. flex-direction: column;
  298. align-items: center;
  299. justify-content: center;
  300. }
  301. .menu-icon{
  302. display: inline-block;
  303. width: 20%;
  304. text-align: center;
  305. margin-top: 20rpx;
  306. }
  307. .app_menu_icon {
  308. width: 80rpx;
  309. height: 80rpx;
  310. margin-bottom: 8rpx;
  311. &:active {
  312. transform: scale(0.95);
  313. opacity: 0.8;
  314. }
  315. }
  316. .menu-icon-text{
  317. // 超出部分省略号
  318. width: 100%;
  319. overflow: hidden;
  320. text-overflow: ellipsis;
  321. white-space: nowrap;
  322. color: #333333;
  323. text-align: center;
  324. font-family: "Source Han Sans CN VF";
  325. font-size: 24rpx;
  326. font-weight: 400;
  327. }
  328. }
  329. .menu-name {
  330. font-size: 24rpx;
  331. color: #333;
  332. text-align: center;
  333. line-height: 1.4;
  334. max-width: 100%;
  335. overflow: hidden;
  336. text-overflow: ellipsis;
  337. white-space: nowrap;
  338. }
  339. }
  340. }
  341. </style>