index.vue 3.0 KB

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