index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <view class="recommend-item">
  3. <!-- Main Info Row -->
  4. <view class="main-info" :style="{ 'margin-bottom': showDesc ? '30rpx' : '0' }">
  5. <image :src="item.cover" class="book-cover" mode="aspectFill"></image>
  6. <view class="info-right">
  7. <view class="title-author">
  8. <view class="title-row">
  9. <text class="title">{{ item.title }}</text>
  10. </view>
  11. <text class="author">{{ item.author }}</text>
  12. </view>
  13. <view class="price-action">
  14. <view class="price-box">
  15. <text class="currency">¥</text>
  16. <text class="price">{{ item.price }}</text>
  17. <text class="original">¥{{ item.originalPrice }}</text>
  18. </view>
  19. <view class="cart-btn" @click.stop="handleAddToCart">
  20. <text>加入购物车</text>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <!-- Description Row -->
  26. <view class="desc-section" v-if="showDesc">
  27. <view class="desc-header">
  28. <text class="label">简介</text>
  29. <view class="indicator"></view>
  30. </view>
  31. <text class="desc-content">{{ item.desc || '暂无简介' }}</text>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. name: 'RecommendItem',
  38. props: {
  39. item: {
  40. type: Object,
  41. required: true
  42. },
  43. showDesc: {
  44. type: Boolean,
  45. default: true
  46. }
  47. },
  48. methods: {
  49. handleAddToCart() {
  50. this.$emit('add-cart', this.item);
  51. }
  52. }
  53. }
  54. </script>
  55. <style lang="scss" scoped>
  56. .recommend-item {
  57. padding: 30rpx 0;
  58. border-bottom: 1rpx dashed #EEEEEE;
  59. .main-info {
  60. display: flex;
  61. margin-bottom: 30rpx;
  62. .book-cover {
  63. width: 172rpx;
  64. height: 220rpx;
  65. border-radius: 8rpx;
  66. background-color: #f5f5f5;
  67. margin-right: 24rpx;
  68. flex-shrink: 0;
  69. box-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.1);
  70. }
  71. .info-right {
  72. flex: 1;
  73. display: flex;
  74. flex-direction: column;
  75. justify-content: space-between;
  76. padding: 4rpx 0;
  77. .title-author {
  78. .title {
  79. font-size: 32rpx;
  80. font-weight: bold;
  81. color: #333;
  82. margin-bottom: 12rpx;
  83. display: block;
  84. line-height: 1.4;
  85. }
  86. .author {
  87. font-size: 24rpx;
  88. color: #999;
  89. }
  90. }
  91. .price-action {
  92. display: flex;
  93. justify-content: space-between;
  94. align-items: flex-end;
  95. .price-box {
  96. .currency {
  97. font-size: 24rpx;
  98. color: #FF4B4B;
  99. font-weight: bold;
  100. }
  101. .price {
  102. font-size: 36rpx;
  103. color: #FF4B4B;
  104. font-weight: bold;
  105. margin-right: 12rpx;
  106. }
  107. .original {
  108. font-size: 24rpx;
  109. color: #999;
  110. text-decoration: line-through;
  111. }
  112. }
  113. .cart-btn {
  114. background: #38C248;
  115. border-radius: 30rpx;
  116. height: 60rpx;
  117. line-height: 60rpx;
  118. padding: 0 24rpx;
  119. text {
  120. font-size: 26rpx;
  121. color: #fff;
  122. }
  123. }
  124. }
  125. }
  126. }
  127. .desc-section {
  128. .desc-header {
  129. position: relative;
  130. display: inline-block;
  131. margin-bottom: 16rpx;
  132. .label {
  133. font-size: 30rpx;
  134. font-weight: bold;
  135. color: #333;
  136. position: relative;
  137. z-index: 1;
  138. }
  139. .indicator {
  140. position: absolute;
  141. bottom: 4rpx;
  142. right: 4rpx;
  143. width: 30rpx;
  144. height: 8rpx;
  145. background: #4ED964;
  146. border-radius: 4rpx;
  147. z-index: 0;
  148. }
  149. }
  150. .desc-content {
  151. font-family: Source Han Sans SC;
  152. font-size: 26rpx;
  153. color: #8D8D8D;
  154. line-height: 1.6;
  155. display: block;
  156. text-align: justify;
  157. }
  158. }
  159. }
  160. </style>