123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- <template>
- <router-link
- :to="{ name: 'detail', params: { id: item.id, type: 'reader' } }"
- class="book-card"
- :class="{ row: isRow, large: size === 'large' }"
- >
- <div class="book-card-img">
- <el-image :src="`${baseUrl}${item.thumb}`" fit="cover" />
- <img
- v-if="showLike"
- class="book-card-img__like"
- src="@/assets/images/icon_like.png"
- draggable="false"
- />
- <div v-if="showRead" class="book-card-img__tag">读过</div>
- </div>
- <div class="book-card-inner">
- <p class="book-card__name limit-line">{{ item.name }}</p>
- <p v-if="isRow" class="limit-line">{{ item.author }}</p>
- <p class="limit-line">{{ item.press }}</p>
- </div>
- </router-link>
- </template>
- <script setup>
- import { computed } from "vue";
- import { getBaseUrl } from "@lsq/base";
- const props = defineProps({
- // 模式 row-横版 column-竖版
- type: {
- type: String,
- required: false,
- default: "row",
- },
- // 尺寸 normal large
- size: {
- type: String,
- required: false,
- defualt: "normal",
- },
- showLike: {
- type: Boolean,
- default: false,
- },
- showRead: {
- type: Boolean,
- default: false,
- },
- item: {
- type: Object,
- required: true,
- },
- });
- const baseUrl = getBaseUrl();
- const isRow = computed(() => props.type === "row");
- </script>
- <style lang="scss" scoped>
- .book-card {
- display: flex;
- flex-direction: column;
- width: 150px;
- cursor: pointer;
- // 横版样式
- &.row {
- width: 100%;
- flex-direction: row;
- gap: 18px;
- line-height: 16px;
- &.large {
- width: 100%;
- font-size: 18px;
- line-height: 21px;
- .book-card-img {
- width: 114px;
- height: 146px;
- }
- .book-card__name {
- margin-bottom: 20px;
- font-size: 24px;
- line-height: 28px;
- }
- }
- .book-card-img {
- width: 90px;
- height: 115px;
- }
- .book-card-inner {
- flex: 1;
- text-align: left;
- }
- .book-card__name {
- margin-top: unset;
- margin-bottom: 5px;
- line-height: 22px;
- }
- }
- &.large {
- width: 192px;
- .book-card-img {
- height: 259px;
- }
- }
- &-img {
- position: relative;
- flex-shrink: 0;
- width: inherit;
- height: 200px;
- .el-image {
- width: 100%;
- height: 100%;
- }
- &__like {
- position: absolute;
- top: 4px;
- right: 4px;
- width: 30px;
- height: 30px;
- }
- &__tag {
- position: absolute;
- top: 10px;
- right: 10px;
- display: flex;
- align-items: center;
- justify-content: center;
- width: 43px;
- height: 24px;
- color: white;
- font-size: 12px;
- border-radius: 2px;
- background: rgba(0, 0, 0, 0.3);
- }
- }
- &-inner {
- text-align: center;
- }
- &__name {
- margin-top: 8px;
- font-size: 18px;
- font-family: "Source Han Serif CN-Bold";
- opacity: 1 !important;
- }
- p {
- opacity: 0.8;
- }
- }
- </style>
|