book-card.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <view class="book-card" @click="handleClick">
  3. <view class="book-cover">
  4. <image :src="cover" mode="aspectFill" class="cover-image"></image>
  5. </view>
  6. <view class="book-info">
  7. <text class="book-title">{{ title }}</text>
  8. <view class="price-row">
  9. <text class="current-price">¥{{ currentPrice }}</text>
  10. <text class="original-price">¥{{ originalPrice }}</text>
  11. </view>
  12. <view class="buy-button">
  13. <text class="button-text">加入购物车</text>
  14. </view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. name: 'BookCard',
  21. props: {
  22. cover: {
  23. type: String,
  24. required: true
  25. },
  26. title: {
  27. type: String,
  28. required: true
  29. },
  30. currentPrice: {
  31. type: [String, Number],
  32. required: true
  33. },
  34. originalPrice: {
  35. type: [String, Number],
  36. required: true
  37. }
  38. },
  39. methods: {
  40. handleClick() {
  41. this.$emit('click');
  42. }
  43. }
  44. };
  45. </script>
  46. <style lang="scss" scoped>
  47. .book-card {
  48. display: flex;
  49. flex-direction: column;
  50. width: 220rpx;
  51. .book-cover {
  52. width: 220rpx;
  53. height: 300rpx;
  54. border-radius: 8rpx;
  55. overflow: hidden;
  56. margin-bottom: 16rpx;
  57. .cover-image {
  58. width: 100%;
  59. height: 100%;
  60. }
  61. }
  62. .book-info {
  63. .book-title {
  64. font-size: 28rpx;
  65. color: #333333;
  66. font-weight: 500;
  67. margin-bottom: 12rpx;
  68. display: block;
  69. overflow: hidden;
  70. text-overflow: ellipsis;
  71. white-space: nowrap;
  72. }
  73. .price-row {
  74. display: flex;
  75. align-items: center;
  76. margin-bottom: 16rpx;
  77. .current-price {
  78. font-size: 32rpx;
  79. color: #FF3B30;
  80. font-weight: bold;
  81. margin-right: 12rpx;
  82. }
  83. .original-price {
  84. font-size: 24rpx;
  85. color: #999999;
  86. text-decoration: line-through;
  87. }
  88. }
  89. .buy-button {
  90. width: 100%;
  91. height: 56rpx;
  92. background: linear-gradient(90deg, #5DD466 0%, #38C148 100%);
  93. border-radius: 28rpx;
  94. display: flex;
  95. align-items: center;
  96. justify-content: center;
  97. .button-text {
  98. font-size: 24rpx;
  99. color: #FFFFFF;
  100. }
  101. }
  102. }
  103. }
  104. </style>