index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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.name || '-' }}</text>
  7. <view class="price-row">
  8. <text class="currency">¥</text>
  9. <text class="price">{{ item.productPrice }}</text>
  10. </view>
  11. <view class="flex space-between">
  12. <view class="discount-tag" v-if="item.discountDesc">
  13. <text class="discount">{{ item.discountDesc }}</text>
  14. <text class="discount-desc">省{{ item.discountPrice }}元</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. // 加入购物车时,传递 sourceFrom 参数为 1
  43. this.$refs.popup.open(this.item, 1);
  44. },
  45. onPopupConfirm(data) {
  46. this.$emit('add-cart', data);
  47. }
  48. }
  49. }
  50. </script>
  51. <style lang="scss" scoped>
  52. .hot-item {
  53. display: flex;
  54. border-radius: 16rpx;
  55. .book-cover {
  56. width: 140rpx;
  57. height: 180rpx;
  58. border-radius: 4rpx;
  59. background-color: #f5f5f5;
  60. margin-right: 20rpx;
  61. flex-shrink: 0;
  62. }
  63. .info-right {
  64. flex: 1;
  65. .info-top {
  66. height: 100%;
  67. display: flex;
  68. flex-direction: column;
  69. justify-content: space-between;
  70. .title {
  71. font-size: 30rpx;
  72. font-weight: bold;
  73. color: #333;
  74. margin-bottom: 10rpx;
  75. display: block;
  76. }
  77. .price-row {
  78. display: flex;
  79. align-items: baseline;
  80. margin-bottom: 10rpx;
  81. .currency {
  82. font-size: 32rpx;
  83. color: #D81A00;
  84. font-weight: bold;
  85. }
  86. .price {
  87. font-size: 36rpx;
  88. color: #D81A00;
  89. font-weight: bold;
  90. }
  91. }
  92. .discount-tag {
  93. display: inline-block;
  94. border-radius: 10rpx;
  95. font-family: Source Han Sans SC;
  96. font-weight: 500;
  97. font-size: 22rpx;
  98. height: 40rpx;
  99. line-height: 40rpx;
  100. background-color: #fff;
  101. border: 2rpx solid #D81A00;
  102. box-sizing: border-box;
  103. overflow: auto;
  104. .discount {
  105. background: #D81A00;
  106. color: #fff;
  107. display: inline-block;
  108. padding: 0 12rpx;
  109. box-sizing: border-box;
  110. }
  111. .discount-desc {
  112. color: #D81A00;
  113. padding: 0 10rpx;
  114. }
  115. }
  116. }
  117. .btn-cart {
  118. align-self: flex-end;
  119. background: #38C248;
  120. border-radius: 30rpx;
  121. height: 60rpx;
  122. display: flex;
  123. align-items: center;
  124. justify-content: center;
  125. padding: 0 20rpx;
  126. text {
  127. font-size: 28rpx;
  128. color: #fff;
  129. }
  130. }
  131. }
  132. }
  133. </style>