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

89 lines
1.7 KiB

  1. <template>
  2. <view class="recommend">
  3. <view class="flex recommend-item" v-for="item in recommendList" :key="item.id">
  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. },
  33. {
  34. id: '002',
  35. icon: '/static/image/temp-12.png',
  36. label: '口碑爆款',
  37. desc: '热销推荐',
  38. },
  39. {
  40. id: '003',
  41. icon: '/static/image/temp-13.png',
  42. label: '新上线路',
  43. desc: '全新上线',
  44. },
  45. ]
  46. },
  47. },
  48. }
  49. </script>
  50. <style scoped lang="scss">
  51. .recommend {
  52. display: grid;
  53. grid-template-columns: repeat(3, 1fr);
  54. column-gap: 12rpx;
  55. &-item {
  56. justify-content: flex-start;
  57. column-gap: 8rpx;
  58. padding: 16rpx;
  59. box-sizing: border-box;
  60. background: linear-gradient(to right, #FFF5EA, #FFFCF9 70%, #FFFCF9);
  61. border-radius: 16rpx;
  62. .img {
  63. width: 56rpx;
  64. height: auto;
  65. }
  66. .label {
  67. font-size: 26rpx;
  68. color: #181818;
  69. }
  70. .desc {
  71. font-size: 22rpx;
  72. color: #9B9B9B;
  73. &.highlight {
  74. color: #FF9035;
  75. }
  76. }
  77. }
  78. }
  79. </style>