menus.vue 3.1 KB

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