menus.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <view class='nav acea-row acea-row'
  3. :style="'background:'+bgColor[0].item+';margin:' +mbConfig+'rpx '+prConfig+'rpx 0;border-radius:'+bgStyle+'rpx;'"
  4. v-if="menus.length">
  5. <block v-if="rowStyle == 0">
  6. <scroll-view scroll-x="true" style="white-space: nowrap; display: flex" show-scrollbar="false">
  7. <view v-for="(item,index) in menus" :key="index" class='item' :style="'color:'+titleColor"
  8. @click="menusTap(item.info[1].value)">
  9. <view class='pictrue skeleton-rect'>
  10. <image :src='item.img' :style="'border-radius:'+menuStyle"></image>
  11. </view>
  12. <view class="menu-txt" :style="'color:'+titleColor">{{item.info[0].value}}</view>
  13. </view>
  14. </scroll-view>
  15. </block>
  16. <block v-else v-for="(item,index) in menus" :key="index">
  17. <view class='item' :style="'color:'+titleColor+';width:'+number" @click="menusTap(item.info[1].value)">
  18. <view class='pictrue skeleton-rect'>
  19. <image :src='item.img' :style="'border-radius:'+menuStyle"></image>
  20. </view>
  21. <view class="menu-txt" :style="'color:'+titleColor">{{item.info[0].value}}</view>
  22. </view>
  23. </block>
  24. <!-- <web-view :src="weburl" v-if="weburl"></web-view> -->
  25. </view>
  26. </template>
  27. <script>
  28. import {
  29. merPath
  30. } from "@/utils/index"
  31. export default {
  32. name: 'menus',
  33. props: {
  34. dataConfig: {
  35. type: Object,
  36. default: () => {}
  37. },
  38. merId: {}
  39. },
  40. data() {
  41. return {
  42. weburl: '',
  43. menus: this.dataConfig.menuConfig.list,
  44. bgColor: this.dataConfig.bgColor.color,
  45. menuStyle: this.dataConfig.menuStyle.type ? '50%' : 0,
  46. rowStyle: this.dataConfig.tabConfig.tabVal, //0单行1多行
  47. bgStyle: this.dataConfig.bgStyle.type ? '16' : '0',
  48. titleColor: this.dataConfig.titleColor.color[0].item,
  49. mbConfig: this.dataConfig.mbConfig.val * 2,
  50. prConfig: this.dataConfig.prConfig.val * 2,
  51. rowNum: this.dataConfig.rowsNum.type, //0两行,1三行,2四行
  52. number: this.dataConfig.number.type == 0 ? '33.33%' : this.dataConfig.number.type == 1 ? '25%' :
  53. '20%', //三个四个五个
  54. };
  55. },
  56. created() {},
  57. mounted() {},
  58. methods: {
  59. menusTap(url) {
  60. let data = this.$util.stringIntercept(url, 1, '\?');
  61. data = this.$util.stringIntercept(data, 1, '\=');
  62. uni.setStorageSync('storeIndex', data);
  63. url = merPath(url, this.merId)
  64. if (url.indexOf("http") != -1) {
  65. // #ifdef H5
  66. location.href = url
  67. // #endif
  68. // #ifdef APP-PLUS
  69. // this.weburl = url
  70. plus.runtime.openURL(
  71. url,
  72. // 打开url失败,执行,如打开的是tabao://但是手机没安装,就会执行报错
  73. function(err) {
  74. console.log(err);
  75. }
  76. );
  77. // #endif
  78. } else {
  79. if (['/pages/goods_cate/goods_cate', '/pages/order_addcart/order_addcart', '/pages/user/index']
  80. .indexOf(url) == -1) {
  81. uni.navigateTo({
  82. url: url
  83. })
  84. } else {
  85. uni.switchTab({
  86. url: url
  87. })
  88. }
  89. }
  90. }
  91. }
  92. }
  93. </script>
  94. <style lang="scss">
  95. .nav {
  96. padding: 30rpx 0;
  97. .item {
  98. width: 20%;
  99. text-align: center;
  100. font-size: 24rpx;
  101. display: inline-block;
  102. .pictrue {
  103. width: 82rpx;
  104. height: 82rpx;
  105. margin: 0 auto;
  106. image {
  107. width: 100%;
  108. height: 100%;
  109. }
  110. }
  111. .menu-txt {
  112. font-size: 24rpx;
  113. color: #454545;
  114. margin-top: 15rpx;
  115. }
  116. &.four {
  117. width: 25%;
  118. .pictrue {
  119. width: 90rpx;
  120. height: 90rpx;
  121. }
  122. }
  123. }
  124. }
  125. </style>