index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <view class="hot-item">
  3. <!-- Rank -->
  4. <view class="rank-col">
  5. <image v-if="rank === 1" src="/pages-sell/static/hot/icon-first.png" class="rank-icon" mode="widthFix"></image>
  6. <image v-else-if="rank === 2" src="/pages-sell/static/hot/icon-second.png" class="rank-icon" mode="widthFix"></image>
  7. <image v-else-if="rank === 3" src="/pages-sell/static/hot/icon-third.png" class="rank-icon" mode="widthFix"></image>
  8. <text v-else class="rank-text">{{ rank < 10 ? '0' + rank : rank }}</text>
  9. </view>
  10. <!-- Book Info -->
  11. <view class="book-info" @click.stop="navigateToDetail">
  12. <image :src="item.bookImg" class="book-cover" mode="aspectFill"></image>
  13. <view class="info-right">
  14. <text class="title">{{ item.bookName || '-' }}</text>
  15. <text class="author">{{ item.author || '-' }}</text>
  16. <view class="bottom-row">
  17. <view class="price-box">
  18. <text class="currency">¥</text>
  19. <text class="price">{{ item.bookPrice }}</text>
  20. <text class="original">¥{{ item.bookOriginalPrice }}</text>
  21. </view>
  22. <view class="cart-btn" @click.stop="handleAddToCart">
  23. <text>加入购物车</text>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <!-- Product Selection Popup -->
  29. <SelectGoodPopup ref="popup" @confirm="onPopupConfirm"></SelectGoodPopup>
  30. </view>
  31. </template>
  32. <script>
  33. import SelectGoodPopup from '../select-good-popup/index.vue';
  34. export default {
  35. name: 'HotSellItem',
  36. components: {
  37. SelectGoodPopup
  38. },
  39. props: {
  40. rank: {
  41. type: Number,
  42. required: true
  43. },
  44. item: {
  45. type: Object,
  46. required: true
  47. }
  48. },
  49. methods: {
  50. navigateToDetail() {
  51. uni.navigateTo({
  52. url: '/pages-sell/pages/detail?isbn=' + this.item.bookIsbn || ''
  53. });
  54. },
  55. handleAddToCart() {
  56. this.item.isbn = this.item.bookIsbn || '';
  57. this.$refs.popup.open(this.item, 1);
  58. },
  59. onPopupConfirm(data) {
  60. this.$emit('add-cart', data);
  61. }
  62. }
  63. }
  64. </script>
  65. <style lang="scss" scoped>
  66. .hot-item {
  67. display: flex;
  68. align-items: center;
  69. padding: 30rpx 0;
  70. border-bottom: 1rpx solid #f6f7f8;
  71. .rank-col {
  72. width: 80rpx;
  73. display: flex;
  74. justify-content: center;
  75. margin-right: 10rpx;
  76. .rank-icon {
  77. width: 60rpx;
  78. height: 60rpx;
  79. }
  80. .rank-text {
  81. font-family: Arial-BoldItalicMT;
  82. font-size: 36rpx;
  83. color: #706F6D;
  84. font-style: italic;
  85. font-weight: bold;
  86. }
  87. }
  88. .book-info {
  89. flex: 1;
  90. display: flex;
  91. align-items: center;
  92. .book-cover {
  93. width: 140rpx;
  94. height: 180rpx;
  95. border-radius: 4rpx;
  96. background-color: #f5f5f5;
  97. margin-right: 24rpx;
  98. flex-shrink: 0;
  99. }
  100. .info-right {
  101. flex: 1;
  102. height: 190rpx;
  103. display: flex;
  104. flex-direction: column;
  105. justify-content: space-between;
  106. padding: 10rpx 0;
  107. .title {
  108. font-size: 32rpx;
  109. color: #303030;
  110. font-weight: bold;
  111. line-height: 1.2;
  112. overflow: hidden;
  113. text-overflow: ellipsis;
  114. display: -webkit-box;
  115. -webkit-line-clamp: 2;
  116. -webkit-box-orient: vertical;
  117. }
  118. .author {
  119. font-size: 24rpx;
  120. color: #999999;
  121. }
  122. .bottom-row {
  123. display: flex;
  124. justify-content: space-between;
  125. align-items: flex-end;
  126. .price-box {
  127. display: flex;
  128. align-items: baseline;
  129. .currency {
  130. font-size: 36rpx;
  131. color: #D81A00;
  132. font-weight: bold;
  133. margin-right: 6rpx;
  134. }
  135. .price {
  136. font-size: 36rpx;
  137. color: #D81A00;
  138. font-weight: bold;
  139. margin-right: 12rpx;
  140. }
  141. .original {
  142. font-size: 24rpx;
  143. color: #999999;
  144. text-decoration: line-through;
  145. }
  146. }
  147. .cart-btn {
  148. width: 160rpx;
  149. height: 56rpx;
  150. background: linear-gradient(90deg, #4ED964 0%, #38C248 100%);
  151. border-radius: 28rpx;
  152. display: flex;
  153. align-items: center;
  154. justify-content: center;
  155. text {
  156. font-size: 24rpx;
  157. color: #fff;
  158. font-weight: 500;
  159. }
  160. }
  161. }
  162. }
  163. }
  164. }
  165. </style>