index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <router-link
  3. :to="{ name: 'detail', params: { id: item.id, type: 'reader' } }"
  4. class="book-card"
  5. :class="{ row: isRow, large: size === 'large' }"
  6. >
  7. <div class="book-card-img">
  8. <el-image :src="`${baseUrl}${item.thumb}`" fit="cover" />
  9. <img
  10. v-if="showLike"
  11. class="book-card-img__like"
  12. src="@/assets/images/icon_like.png"
  13. draggable="false"
  14. />
  15. <div v-if="showRead" class="book-card-img__tag">读过</div>
  16. </div>
  17. <div class="book-card-inner">
  18. <p class="book-card__name limit-line">{{ item.name }}</p>
  19. <p v-if="isRow" class="limit-line">{{ item.author }}</p>
  20. <p class="limit-line">{{ item.press }}</p>
  21. </div>
  22. </router-link>
  23. </template>
  24. <script setup>
  25. import { computed } from "vue";
  26. import { getBaseUrl } from "@lsq/base";
  27. const props = defineProps({
  28. // 模式 row-横版 column-竖版
  29. type: {
  30. type: String,
  31. required: false,
  32. default: "row",
  33. },
  34. // 尺寸 normal large
  35. size: {
  36. type: String,
  37. required: false,
  38. defualt: "normal",
  39. },
  40. showLike: {
  41. type: Boolean,
  42. default: false,
  43. },
  44. showRead: {
  45. type: Boolean,
  46. default: false,
  47. },
  48. item: {
  49. type: Object,
  50. required: true,
  51. },
  52. });
  53. const baseUrl = getBaseUrl();
  54. const isRow = computed(() => props.type === "row");
  55. </script>
  56. <style lang="scss" scoped>
  57. .book-card {
  58. display: flex;
  59. flex-direction: column;
  60. width: 150px;
  61. cursor: pointer;
  62. // 横版样式
  63. &.row {
  64. width: 100%;
  65. flex-direction: row;
  66. gap: 18px;
  67. line-height: 16px;
  68. &.large {
  69. width: 100%;
  70. font-size: 18px;
  71. line-height: 21px;
  72. .book-card-img {
  73. width: 114px;
  74. height: 146px;
  75. }
  76. .book-card__name {
  77. margin-bottom: 20px;
  78. font-size: 24px;
  79. line-height: 28px;
  80. }
  81. }
  82. .book-card-img {
  83. width: 90px;
  84. height: 115px;
  85. }
  86. .book-card-inner {
  87. flex: 1;
  88. text-align: left;
  89. }
  90. .book-card__name {
  91. margin-top: unset;
  92. margin-bottom: 5px;
  93. line-height: 22px;
  94. }
  95. }
  96. &.large {
  97. width: 192px;
  98. .book-card-img {
  99. height: 259px;
  100. }
  101. }
  102. &-img {
  103. position: relative;
  104. flex-shrink: 0;
  105. width: inherit;
  106. height: 200px;
  107. .el-image {
  108. width: 100%;
  109. height: 100%;
  110. }
  111. &__like {
  112. position: absolute;
  113. top: 4px;
  114. right: 4px;
  115. width: 30px;
  116. height: 30px;
  117. }
  118. &__tag {
  119. position: absolute;
  120. top: 10px;
  121. right: 10px;
  122. display: flex;
  123. align-items: center;
  124. justify-content: center;
  125. width: 43px;
  126. height: 24px;
  127. color: white;
  128. font-size: 12px;
  129. border-radius: 2px;
  130. background: rgba(0, 0, 0, 0.3);
  131. }
  132. }
  133. &-inner {
  134. text-align: center;
  135. }
  136. &__name {
  137. margin-top: 8px;
  138. font-size: 18px;
  139. font-family: "Source Han Serif CN-Bold";
  140. opacity: 1 !important;
  141. }
  142. p {
  143. opacity: 0.8;
  144. }
  145. }
  146. </style>