index.vue 8.0 KB

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