menus.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <view class="menu-main">
  3. <view class='nav acea-row acea-row' v-if="isShow && menus.length">
  4. <block v-for="(item,index) in menus" :key="index">
  5. <view class='item' @click="menusTap(item.info[1].value)">
  6. <view class='pictrue'>
  7. <image class="skeleton-radius" :src='item.img'></image>
  8. </view>
  9. <view class="menu-txt">{{item.info[0].value}}</view>
  10. </view>
  11. </block>
  12. </view>
  13. <view class='nav acea-row acea-row' v-if="!isShow && isIframe && menus.length">
  14. <block v-for="(item,index) in menus" :key="index">
  15. <view class='item' @click="menusTap(item.info[1].value)">
  16. <view class='pictrue'>
  17. <image :src='item.img'></image>
  18. </view>
  19. <view class="menu-txt">{{item.info[0].value}}</view>
  20. </view>
  21. </block>
  22. </view>
  23. <view class="nav acea-row acea-row" v-if="isIframe && !menus.length">
  24. <view class='item'>
  25. <view class='pictrue default'>
  26. <text class="iconfont icon-icon25201"></text>
  27. </view>
  28. <view class="menu-txt">默认</view>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. let app = getApp()
  35. import {
  36. goPage
  37. } from '@/libs/order.js'
  38. export default {
  39. name: 'menus',
  40. props: {
  41. dataConfig: {
  42. type: Object,
  43. default: () => {}
  44. }
  45. },
  46. watch: {
  47. dataConfig: {
  48. immediate: true,
  49. handler(nVal, oVal) {
  50. if (nVal) {
  51. this.menus = nVal.imgList.list;
  52. this.isShow = nVal.isShow.val
  53. }
  54. }
  55. }
  56. },
  57. data() {
  58. return {
  59. menus: [],
  60. name: this.$options.name,
  61. isIframe: false,
  62. isShow: true
  63. };
  64. },
  65. created() {
  66. this.isIframe = app.globalData.isIframe;
  67. },
  68. mounted() {},
  69. methods: {
  70. menusTap(url) {
  71. goPage().then(res => {
  72. if (url.indexOf("http") != -1) {
  73. // #ifdef H5
  74. location.href = url
  75. // #endif
  76. } else {
  77. // uni.navigateTo({
  78. // url: url
  79. // })
  80. if (['/pages/goods_cate/goods_cate', '/pages/order_addcart/order_addcart',
  81. '/pages/user/index'
  82. ].indexOf(url) == -1) {
  83. uni.navigateTo({
  84. url: url
  85. })
  86. } else {
  87. uni.switchTab({
  88. url: url
  89. })
  90. }
  91. }
  92. })
  93. }
  94. }
  95. }
  96. </script>
  97. <style lang="scss">
  98. .menu-main {
  99. background-color: #fff;
  100. }
  101. .nav {
  102. margin: 0 30rpx;
  103. // margin: $uni-index-margin-row $uni-index-margin-col;
  104. border-radius: $uni-border-radius-index;
  105. // box-shadow: $uni-index-box-shadow;
  106. .item {
  107. margin-top: 26rpx;
  108. width: 20%;
  109. text-align: center;
  110. font-size: 24rpx;
  111. .pictrue {
  112. width: 90rpx;
  113. height: 90rpx;
  114. margin: 0 auto;
  115. &.default {
  116. background-color: #ccc;
  117. border-radius: 50%;
  118. text-align: center;
  119. line-height: 90rpx;
  120. .iconfont {
  121. font-size: 40rpx;
  122. }
  123. }
  124. image {
  125. width: 100%;
  126. height: 100%;
  127. border-radius: 50%;
  128. }
  129. }
  130. .menu-txt {
  131. margin-top: 15rpx;
  132. }
  133. &.four {
  134. width: 25%;
  135. .pictrue {
  136. width: 90rpx;
  137. height: 90rpx;
  138. }
  139. }
  140. }
  141. }
  142. </style>