鸿宇研学生前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
2.1 KiB

  1. <template>
  2. <view class="recommend">
  3. <view class="flex recommend-item" v-for="item in recommendList" :key="item.id" @click="onClick(item)">
  4. <image class="img" :src="item.icon" mode="widthFix"></image>
  5. <view>
  6. <view class="label">{{ item.label }}</view>
  7. <view :class="['desc', item.highlight ? 'highlight' : '']">{{ item.desc }}</view>
  8. </view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. data() {
  15. return {
  16. recommendList: [],
  17. }
  18. },
  19. created() {
  20. this.getData()
  21. },
  22. methods: {
  23. getData() {
  24. // todo: fetch
  25. this.recommendList = [
  26. {
  27. id: '001',
  28. icon: '/static/image/temp-11.png',
  29. label: '限时优惠',
  30. desc: '速抢折扣',
  31. highlight: true,
  32. path: `/pages_order/product/search?isDiscount=1&title=限时优惠`,
  33. },
  34. {
  35. id: '002',
  36. icon: '/static/image/temp-12.png',
  37. label: '口碑爆款',
  38. desc: '热销推荐',
  39. path: `/pages_order/product/search?isHot=1&title=口碑爆款`,
  40. },
  41. {
  42. id: '003',
  43. icon: '/static/image/temp-13.png',
  44. label: '新上线路',
  45. desc: '全新上线',
  46. path: `/pages_order/product/search?isNew=1&title=新上线路`,
  47. },
  48. ]
  49. },
  50. onClick(target) {
  51. const { path } = target
  52. if (path) {
  53. uni.navigateTo({
  54. url: path
  55. })
  56. }
  57. },
  58. },
  59. }
  60. </script>
  61. <style scoped lang="scss">
  62. .recommend {
  63. display: grid;
  64. grid-template-columns: repeat(3, 1fr);
  65. column-gap: 12rpx;
  66. &-item {
  67. justify-content: flex-start;
  68. column-gap: 8rpx;
  69. padding: 16rpx;
  70. box-sizing: border-box;
  71. background: linear-gradient(to right, #FFF5EA, #FFFCF9 70%, #FFFCF9);
  72. border-radius: 16rpx;
  73. .img {
  74. width: 56rpx;
  75. height: auto;
  76. }
  77. .label {
  78. font-size: 26rpx;
  79. color: #181818;
  80. }
  81. .desc {
  82. font-size: 22rpx;
  83. color: #9B9B9B;
  84. &.highlight {
  85. color: #FF9035;
  86. }
  87. }
  88. }
  89. }
  90. </style>