图书馆小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

179 lines
3.7 KiB

2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
  1. <template>
  2. <view class="item-container" @click="$emit('click')">
  3. <view class="book-item-box">
  4. <view class="item-box-left">
  5. <image
  6. class="img-item"
  7. :src="data.cover || data.imgCover || '/static/images/default-book.png'"
  8. mode="scaleToFill"
  9. @error="onImgError"
  10. />
  11. </view>
  12. <view class="item-box-right">
  13. <view class="item-title line-clamp-2">{{ data.title || '暂无标题' }}</view>
  14. <view>
  15. <text class="item-author">{{ data.author || '佚名' }}</text>
  16. </view>
  17. <view class="item-desc line-clamp-2">{{ data.localname || data.oplocalname }}</view>
  18. </view>
  19. </view>
  20. <view class="lending-info">
  21. <view class="lending-time">
  22. <text>借书时间{{ data.loantime || '' }}</text>
  23. <text>应还时间{{ data.returntime || '' }}</text>
  24. </view>
  25. <!-- 只在 在借中 显示状态 -->
  26. <image
  27. v-if="isLending && status === 'overdue'"
  28. class="lending-status"
  29. src="@/static/images/mylending-img1.png"
  30. mode="heightFix"
  31. />
  32. <image
  33. v-if="isLending && status === 'warning'"
  34. class="lending-status"
  35. src="@/static/images/mylending-img3.png"
  36. mode="heightFix"
  37. />
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. export default {
  43. name: "lending-list-item",
  44. props: {
  45. data: {
  46. type: Object,
  47. required: true
  48. },
  49. // 父组件传:是否是在借列表
  50. isLending: {
  51. type: Boolean,
  52. default: false
  53. }
  54. },
  55. computed: {
  56. status() {
  57. if (!this.isLending || !this.data.returntime) return '';
  58. const now = Date.now();
  59. const returnTime = new Date(this.data.returntime).getTime();
  60. // 相差毫秒数
  61. const diffTime = returnTime - now;
  62. // 换算成天数
  63. const day = diffTime / (1000 * 60 * 60 * 24);
  64. // 1. 已经过期 → 逾期
  65. if (day < 0) {
  66. return 'overdue';
  67. }
  68. // 2. 没过期,但 ≤3 天 → 临期
  69. if (day <= 3) {
  70. return 'warning';
  71. }
  72. // 3. 大于3天 → 正常,不显示
  73. return '';
  74. }
  75. },
  76. methods: {
  77. onImgError(e) {
  78. e.target.src = "/static/images/default-book.png";
  79. }
  80. },
  81. };
  82. </script>
  83. <style lang="scss" scoped>
  84. .item-container {
  85. padding: 10px;
  86. background-color: #fff;
  87. border-radius: 6px;
  88. border-bottom: 1px solid #f4f4f4;
  89. margin-bottom: 10px;
  90. .book-item-box {
  91. display: flex;
  92. justify-content: flex-start;
  93. align-items: flex-start;
  94. .item-box-left {
  95. margin-right: 10px;
  96. .img-item {
  97. width: 64px;
  98. height: 90px;
  99. border-radius: 5px;
  100. }
  101. }
  102. .item-box-right {
  103. display: flex;
  104. flex-direction: column;
  105. justify-content: flex-start;
  106. flex: 1;
  107. .item-title {
  108. font-size: 15px;
  109. font-weight: bold;
  110. color: #000;
  111. margin-bottom: 6px;
  112. }
  113. .item-author {
  114. font-size: 12px;
  115. color: #191A1A;
  116. padding: 2px 4px;
  117. border-radius: 2px;
  118. background-color: #F4F6FC;
  119. margin-right: 6px;
  120. }
  121. .item-desc {
  122. font-size: 12px;
  123. color: #191A1A;
  124. padding-top: 8px;
  125. }
  126. }
  127. }
  128. }
  129. .lending-info {
  130. display: flex;
  131. justify-content: space-between;
  132. align-items: center;
  133. padding: 10px 10px 10px 0;
  134. .lending-time {
  135. font-size: 12px;
  136. display: flex;
  137. flex-direction: column;
  138. justify-content: flex-start;
  139. line-height: 22px;
  140. }
  141. .lending-status {
  142. height: 50px;
  143. }
  144. .type-tag {
  145. padding: 4px 10px;
  146. border-radius: 12px;
  147. font-size: 12px;
  148. color: #fff;
  149. font-weight: bold;
  150. }
  151. .tag-lend {
  152. background-color: #409eff;
  153. }
  154. .tag-return {
  155. background-color: #ff3871;
  156. }
  157. }
  158. </style>