index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <view class="index-page">
  3. <image src="@/static/home.jpg" class="bg_home"></image>
  4. <view class="menu">
  5. <view class="menu-box" v-for="(item, index) in menuList" :key="index">
  6. <view class="title">{{item.meta.title}}</view>
  7. <!-- @click="toPage(children.path)" -->
  8. <view class="menu-item" v-for="(children, i) in item.children" :key="i" @click="toPage(i)">
  9. <image :src="children.meta.icon" class="icon_menu"></image>
  10. <view class="menu-title">{{children.meta.title}}</view>
  11. </image>
  12. </view>
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. data() {
  20. return {
  21. menuList: [],
  22. }
  23. },
  24. onShow() {
  25. this.getInfo()
  26. this.getUserMenu();
  27. },
  28. methods: {
  29. getInfo() {
  30. this.$api.getInfo().then(res => {
  31. uni.setStorageSync('userInfo', res.enterpriseUser);
  32. }).catch(err => {})
  33. },
  34. getUserMenu() {
  35. this.menuList = []
  36. this.$api.getRouters().then(res => {
  37. for (let i = 0; i < res.data.length; i++) {
  38. if (res.data[i].pcShow == '0') {
  39. let children = res.data[i].children
  40. for (let j = 0; j < children.length; j++) {
  41. this.menuList.push(children[j])
  42. }
  43. }
  44. }
  45. }).catch(err => {})
  46. },
  47. toPage(path) {
  48. let url = null
  49. if (path == 0) {
  50. url = '/subPackages/work/index'
  51. }else if (path == 1) {
  52. url = '/subPackages/qualityinspection/index'
  53. }else if (path == 2) {
  54. url = '/subPackages/manualdeclaration/index'
  55. }else if (path == 3) {
  56. url = '/subPackages/workorder/index'
  57. }
  58. uni.navigateTo({
  59. url: url
  60. });
  61. },
  62. }
  63. }
  64. </script>
  65. <style lang="scss" scoped>
  66. .index-page {
  67. .bg_home {
  68. width: 100%;
  69. height: 400rpx;
  70. }
  71. .menu {
  72. margin: 16rpx;
  73. .menu-box {
  74. background-color: $uni-bg-color;
  75. margin: 0 2% 20rpx 2%;
  76. padding: 30rpx 20rpx;
  77. border-radius: 10rpx;
  78. }
  79. .title {
  80. margin: 10rpx;
  81. font-size: 30rpx;
  82. font-weight: bold;
  83. }
  84. .menu-item {
  85. width: 25%;
  86. margin-top: 24rpx;
  87. display: inline-flex;
  88. flex-direction: column;
  89. align-items: center;
  90. text-align: center;
  91. position: relative;
  92. .icon_menu {
  93. width: 90rpx;
  94. height: 90rpx;
  95. }
  96. .menu-title {
  97. margin-top: 10rpx;
  98. color: #666;
  99. }
  100. }
  101. }
  102. }
  103. </style>