index.vue 7.7 KB

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