book-list-item.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <view class="book-item">
  3. <!-- 书籍封面 -->
  4. <image class="book-cover" :src="book.cover" mode="aspectFill" />
  5. <!-- 书籍详情 -->
  6. <view class="book-info">
  7. <view class="book-title">{{ book.bookName }}</view>
  8. <view class="book-price">
  9. <view class="sale-price">
  10. <text class="symbol">¥</text>
  11. <text class="amount">{{ book.recycleMoney }}</text>
  12. </view>
  13. <text class="origin-price">¥{{ book.recycleMoney }}</text>
  14. </view>
  15. </view>
  16. <!-- 选择框 -->
  17. <view class="checkbox-item" v-if="isEditMode">
  18. <u-checkbox v-show="isEditMode" class="checkbox-item" v-model="book.selected" :name="book.isbn"
  19. shape="circle" label-size="0" active-color="#38C148" @change="updateCheckbox"></u-checkbox>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. name: 'BookListItem',
  26. props: {
  27. book: {
  28. type: Object,
  29. required: true
  30. },
  31. isEditMode: {
  32. type: Boolean,
  33. default: false
  34. }
  35. },
  36. data() {
  37. return {
  38. statusMap: {
  39. 1: "added",
  40. 2: 'pending',
  41. 3: 'disabled'
  42. }
  43. }
  44. },
  45. methods: {
  46. getStatusText(status) {
  47. // 1-已加入卖书清单 2-未加入 3-暂不回收
  48. let key = this.statusMap[status]
  49. const statusKey = {
  50. pending: '加入卖书清单',
  51. added: '已加入卖书清单',
  52. disabled: '暂不回收'
  53. }
  54. return statusKey[key] || key
  55. },
  56. updateCheckbox({ value }) {
  57. this.$nextTick(() => {
  58. this.$emit('checked', { book: this.book, checked: value })
  59. })
  60. },
  61. handleAction() {
  62. this.$emit('action', this.book)
  63. }
  64. }
  65. }
  66. </script>
  67. <style lang="scss" scoped>
  68. .book-item {
  69. position: relative;
  70. width: calc((100vw - 80rpx) / 3);
  71. background-color: #ffffff;
  72. box-sizing: border-box;
  73. padding: 20rpx;
  74. display: flex;
  75. flex-direction: column;
  76. align-items: center;
  77. border-radius: 10rpx;
  78. height: 100%;
  79. padding-bottom: 10rpx;
  80. .check-icon {
  81. position: absolute;
  82. left: 6rpx;
  83. top: 6rpx;
  84. z-index: 1;
  85. width: 32rpx;
  86. height: 32rpx;
  87. background: #38C148;
  88. border-radius: 50%;
  89. display: flex;
  90. align-items: center;
  91. justify-content: center;
  92. }
  93. .book-cover {
  94. width: 140rpx;
  95. height: 197rpx;
  96. border-radius: 8rpx;
  97. margin-bottom: 8rpx;
  98. }
  99. .book-info {
  100. width: 100%;
  101. .book-title {
  102. font-size: 24rpx;
  103. color: #333333;
  104. margin-bottom: 8rpx;
  105. display: -webkit-box;
  106. -webkit-box-orient: vertical;
  107. -webkit-line-clamp: 1;
  108. overflow: hidden;
  109. margin-top: 15rpx;
  110. }
  111. .book-price {
  112. margin-bottom: 12rpx;
  113. font-family: Source Han Sans CN;
  114. display: flex;
  115. justify-content: space-between;
  116. align-items: center;
  117. align-items: baseline;
  118. .sale-price {
  119. color: #FF5B5B;
  120. margin-right: 12rpx;
  121. display: flex;
  122. align-items: baseline;
  123. font-weight: bold;
  124. .symbol {
  125. font-size: 24rpx;
  126. margin-right: 2rpx;
  127. }
  128. .amount {
  129. font-size: 32rpx;
  130. line-height: 1;
  131. }
  132. }
  133. .origin-price {
  134. font-size: 24rpx;
  135. color: #999999;
  136. text-decoration: line-through;
  137. }
  138. }
  139. }
  140. .checkbox-item {
  141. position: absolute;
  142. right: 6rpx;
  143. top: 0;
  144. z-index: 9;
  145. ::v-deep .u-checkbox__label {
  146. margin: 0 !important;
  147. }
  148. }
  149. }
  150. </style>