鸿宇研学生前端代码
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.

97 lines
2.1 KiB

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