index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. <!-- Product Selection Popup -->
  23. <SelectGoodPopup ref="popup" @confirm="onPopupConfirm"></SelectGoodPopup>
  24. </view>
  25. </template>
  26. <script>
  27. import SelectGoodPopup from '../select-good-popup/index.vue';
  28. export default {
  29. name: 'HotRecommendItem',
  30. components: {
  31. SelectGoodPopup
  32. },
  33. props: {
  34. item: {
  35. type: Object,
  36. required: true,
  37. default: () => ({})
  38. }
  39. },
  40. methods: {
  41. handleAddToCart() {
  42. this.$refs.popup.open(this.item);
  43. },
  44. onPopupConfirm(data) {
  45. this.$emit('add-cart', data);
  46. }
  47. }
  48. }
  49. </script>
  50. <style lang="scss" scoped>
  51. .hot-item {
  52. display: flex;
  53. border-radius: 16rpx;
  54. .book-cover {
  55. width: 140rpx;
  56. height: 180rpx;
  57. border-radius: 4rpx;
  58. background-color: #f5f5f5;
  59. margin-right: 20rpx;
  60. flex-shrink: 0;
  61. }
  62. .info-right {
  63. flex: 1;
  64. .info-top {
  65. height: 100%;
  66. display: flex;
  67. flex-direction: column;
  68. justify-content: space-between;
  69. .title {
  70. font-size: 30rpx;
  71. font-weight: bold;
  72. color: #333;
  73. margin-bottom: 10rpx;
  74. display: block;
  75. }
  76. .price-row {
  77. display: flex;
  78. align-items: baseline;
  79. margin-bottom: 10rpx;
  80. .currency {
  81. font-size: 32rpx;
  82. color: #D81A00;
  83. font-weight: bold;
  84. }
  85. .price {
  86. font-size: 36rpx;
  87. color: #D81A00;
  88. font-weight: bold;
  89. }
  90. }
  91. .discount-tag {
  92. display: inline-block;
  93. border-radius: 10rpx;
  94. font-family: Source Han Sans SC;
  95. font-weight: 500;
  96. font-size: 22rpx;
  97. height: 40rpx;
  98. line-height: 40rpx;
  99. background-color: #fff;
  100. border: 2rpx solid #D81A00;
  101. box-sizing: border-box;
  102. overflow: auto;
  103. .discount {
  104. background: #D81A00;
  105. color: #fff;
  106. display: inline-block;
  107. padding: 0 12rpx;
  108. box-sizing: border-box;
  109. }
  110. .discount-desc {
  111. color: #D81A00;
  112. padding: 0 10rpx;
  113. }
  114. }
  115. }
  116. .btn-cart {
  117. align-self: flex-end;
  118. background: #38C248;
  119. border-radius: 30rpx;
  120. height: 60rpx;
  121. display: flex;
  122. align-items: center;
  123. justify-content: center;
  124. padding: 0 20rpx;
  125. text {
  126. font-size: 28rpx;
  127. color: #fff;
  128. }
  129. }
  130. }
  131. }
  132. </style>