index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <view class="hot-item">
  3. <image :src="item.cover" class="book-cover" mode="aspectFill"></image>
  4. <view class="info-right">
  5. <view class="info-top">
  6. <text class="title">{{ item.title }}</text>
  7. <view class="price-row">
  8. <text class="currency">¥</text>
  9. <text class="price">{{ item.price }}</text>
  10. </view>
  11. <view class="flex space-between">
  12. <view class="discount-tag" v-if="item.discountDesc">
  13. <text class="discount">{{ item.discount }}</text>
  14. <text class="discount-desc">{{ item.discountDesc }}</text>
  15. </view>
  16. <view class="btn-cart" @click.stop="handleAddToCart">
  17. <text>加入购物车</text>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. name: 'HotRecommendItem',
  27. props: {
  28. item: {
  29. type: Object,
  30. required: true,
  31. default: () => ({})
  32. }
  33. },
  34. methods: {
  35. handleAddToCart() {
  36. this.$emit('add-cart', this.item);
  37. }
  38. }
  39. }
  40. </script>
  41. <style lang="scss" scoped>
  42. .hot-item {
  43. display: flex;
  44. border-radius: 16rpx;
  45. .book-cover {
  46. width: 140rpx;
  47. height: 180rpx;
  48. border-radius: 4rpx;
  49. background-color: #f5f5f5;
  50. margin-right: 20rpx;
  51. flex-shrink: 0;
  52. }
  53. .info-right {
  54. flex: 1;
  55. .info-top {
  56. height: 100%;
  57. display: flex;
  58. flex-direction: column;
  59. justify-content: space-between;
  60. .title {
  61. font-size: 30rpx;
  62. font-weight: bold;
  63. color: #333;
  64. margin-bottom: 10rpx;
  65. display: block;
  66. }
  67. .price-row {
  68. display: flex;
  69. align-items: baseline;
  70. margin-bottom: 10rpx;
  71. .currency {
  72. font-size: 32rpx;
  73. color: #D81A00;
  74. font-weight: bold;
  75. }
  76. .price {
  77. font-size: 36rpx;
  78. color: #D81A00;
  79. font-weight: bold;
  80. }
  81. }
  82. .discount-tag {
  83. display: inline-block;
  84. border-radius: 10rpx;
  85. font-family: Source Han Sans SC;
  86. font-weight: 500;
  87. font-size: 22rpx;
  88. height: 40rpx;
  89. line-height: 40rpx;
  90. background-color: #fff;
  91. border: 2rpx solid #D81A00;
  92. box-sizing: border-box;
  93. overflow: auto;
  94. .discount {
  95. background: #D81A00;
  96. color: #fff;
  97. display: inline-block;
  98. padding: 0 12rpx;
  99. box-sizing: border-box;
  100. }
  101. .discount-desc {
  102. color: #D81A00;
  103. padding: 0 10rpx;
  104. }
  105. }
  106. }
  107. .btn-cart {
  108. align-self: flex-end;
  109. background: #38C248;
  110. border-radius: 30rpx;
  111. height: 60rpx;
  112. display: flex;
  113. align-items: center;
  114. justify-content: center;
  115. padding: 0 20rpx;
  116. text {
  117. font-size: 28rpx;
  118. color: #fff;
  119. }
  120. }
  121. }
  122. }
  123. </style>