BeeMenus.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <view class="menus-container">
  3. <view v-if="data.length > 8">
  4. <view v-if="showAll" style="display: flex;align-items: center;justify-content: flex-start;flex-wrap: wrap;">
  5. <view
  6. v-for="item in data" :key="item.name" class="menu-bar-item" :style="{ width: 100 / column + '%' }"
  7. @click="$emit('click', item)"
  8. >
  9. <BeeIcon
  10. :src="item[picUrl] ? common.seamingImgUrl(item[picUrl]) : '../../static/images/index/xiuxian.png'"
  11. :size="40"
  12. ></BeeIcon>
  13. <text>{{ item[name] }}</text>
  14. </view>
  15. </view>
  16. <view v-else style="display: flex;align-items: center;justify-content: flex-start;flex-wrap: wrap;">
  17. <view
  18. v-for="item in data.slice(0, 7)" :key="item.name" class="menu-bar-item" :style="{ width: 100 / column + '%' }"
  19. @click="$emit('click', item)"
  20. >
  21. <BeeIcon
  22. :src="item[picUrl] ? common.seamingImgUrl(item[picUrl]) : '../../static/images/index/xiuxian.png'"
  23. :size="40"
  24. ></BeeIcon>
  25. <text>{{ item[name] }}</text>
  26. </view>
  27. <view class="menu-bar-item" :style="{ width: 100 / column + '%' }" @click="handleClickMore">
  28. <BeeIcon
  29. src="../../static/images/icon/xiangxiajiantou.png"
  30. :size="40"
  31. ></BeeIcon>
  32. <text style="color: #888888;">更多</text>
  33. </view>
  34. </view>
  35. </view>
  36. <view v-else style="display: flex;align-items: center;justify-content: flex-start;flex-wrap: wrap;">
  37. <view
  38. v-for="item in data" :key="item.name" class="menu-bar-item" :style="{ width: 100 / column + '%' }"
  39. @click="$emit('click', item)"
  40. >
  41. <BeeIcon
  42. :src="item[picUrl] ? common.seamingImgUrl(item[picUrl]) : '../../static/images/index/xiuxian.png'"
  43. :size="40"
  44. ></BeeIcon>
  45. <text>{{ item[name] }}</text>
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. export default {
  52. name: 'BeeMenus',
  53. props: {
  54. data: {
  55. type: Array,
  56. required: true
  57. },
  58. column: {
  59. type: Number,
  60. default: 4
  61. },
  62. name: {
  63. type: String,
  64. default: 'storeName'
  65. },
  66. picUrl: {
  67. type: String,
  68. default: 'picUrl'
  69. }
  70. },
  71. data() {
  72. return {
  73. showAll: false
  74. }
  75. },
  76. methods: {
  77. handleClickMore() {
  78. this.showAll = true
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="scss" scoped>
  84. .menus-container {
  85. background-color: #fff;
  86. padding: 30upx 0 0 0;
  87. border-radius: 20upx;
  88. margin-top: 16upx;
  89. .menu-bar-item {
  90. display: flex;
  91. align-items: center;
  92. justify-content: center;
  93. flex-direction: column;
  94. margin-bottom: 24upx;
  95. }
  96. }
  97. </style>