ChannelEntry.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <view class="channel-entry" v-if="list && list.length > 0">
  3. <view class="channel-grid-wrap">
  4. <view class="channel-grid">
  5. <view class="channel-item" v-for="(item, ci) in list" :key="item.id || ci" @tap="onClick(item)">
  6. <image class="channel-icon" :src="item.icon || item.imageUrl" mode="aspectFill"></image>
  7. <text class="channel-name">{{ item.categoryName || item.name || item.menuName }}</text>
  8. </view>
  9. </view>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. name: 'ChannelEntry',
  16. props: {
  17. list: { type: Array, default: () => [] },
  18. perRow: { type: Number, default: 4 },
  19. rows: { type: Number, default: 2 },
  20. imgSize: { type: Number, default: 88 }
  21. },
  22. methods: {
  23. onClick(item) {
  24. this.$emit('click', item);
  25. }
  26. }
  27. };
  28. </script>
  29. <style lang="scss" scoped>
  30. .channel-entry {
  31. background: #fff;
  32. padding: 24rpx 0 32rpx;
  33. }
  34. .channel-grid-wrap {
  35. padding: 0 24rpx;
  36. }
  37. .channel-grid {
  38. display: flex;
  39. flex-wrap: wrap;
  40. }
  41. .channel-item {
  42. width: 25%;
  43. display: flex;
  44. flex-direction: column;
  45. align-items: center;
  46. padding-bottom: 28rpx;
  47. box-sizing: border-box;
  48. }
  49. .channel-icon {
  50. width: 96rpx;
  51. height: 96rpx;
  52. border-radius: 50%;
  53. margin-bottom: 12rpx;
  54. background: #f5f5f5;
  55. }
  56. .channel-name {
  57. font-size: 24rpx;
  58. color: #333;
  59. text-align: center;
  60. overflow: hidden;
  61. text-overflow: ellipsis;
  62. white-space: nowrap;
  63. max-width: 100%;
  64. }
  65. </style>