2024-07-18 15:42:42 +08:00
|
|
|
|
<script setup lang="ts">
|
2024-07-18 17:41:23 +08:00
|
|
|
|
import { ref } from 'vue';
|
|
|
|
|
import { useT_bookApi } from "../../../api/maku/t_book";
|
2024-07-18 15:42:42 +08:00
|
|
|
|
|
2024-07-17 17:21:52 +08:00
|
|
|
|
|
2024-07-18 17:41:23 +08:00
|
|
|
|
const totalBooks = 5; // 假设有5本书
|
|
|
|
|
|
|
|
|
|
// 创建一个包含所有书籍的数组,初始值为5个空对象
|
|
|
|
|
const books = ref(Array(totalBooks).fill({}));
|
|
|
|
|
|
|
|
|
|
// 定义一个函数,用于根据索引调用对应的API获取书籍信息
|
|
|
|
|
function getBook(index: number) {
|
|
|
|
|
useT_bookApi(index + 1).then(res => {
|
|
|
|
|
books.value[index] = res.data;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 使用循环调用获取书籍信息的函数
|
|
|
|
|
for (let i = 0; i < totalBooks; i++) {
|
|
|
|
|
getBook(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</script>
|
2024-07-17 17:21:52 +08:00
|
|
|
|
<template>
|
|
|
|
|
<div class="search-suggest-combobox">
|
|
|
|
|
<div class="input-search">
|
|
|
|
|
<input placeholder="马嘉祺" />
|
2024-07-19 11:22:32 +08:00
|
|
|
|
<button >搜索</button>
|
2024-07-17 17:21:52 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="screen-outer">
|
2024-07-18 17:41:23 +08:00
|
|
|
|
<div class="tb-pick-content-item" v-for="book in books" :key="book.id">
|
|
|
|
|
<div class="img-wrapper">
|
|
|
|
|
<img :src="book.bookCover" style="width:100%; height:120%;" alt="Book Cover">
|
|
|
|
|
</div>
|
|
|
|
|
<div class="info-wrapper">{{ book.bookName }}</div>
|
|
|
|
|
<div class="price-wrapper">
|
|
|
|
|
<span class="price-unit">¥</span>
|
|
|
|
|
<span class="price-value">{{ book.price }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2024-07-17 17:21:52 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
.search-suggest-combobox {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 38px;
|
|
|
|
|
margin-top: 40px;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
|
|
|
|
.input-search {
|
|
|
|
|
width: 1004px;
|
|
|
|
|
height: 38px;
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
border: 2px solid rgb(255, 80, 0);
|
|
|
|
|
align-items: center;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
background: white;
|
|
|
|
|
|
|
|
|
|
input {
|
|
|
|
|
border: none;
|
|
|
|
|
background: none;
|
|
|
|
|
height: 38px;
|
|
|
|
|
margin-left: 30px;
|
|
|
|
|
width: 800px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
button {
|
|
|
|
|
width: 72px;
|
|
|
|
|
height: 34px;
|
|
|
|
|
border: none;
|
|
|
|
|
background: #ff6200;
|
|
|
|
|
color: #fff;
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
margin-right: 5px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.screen-outer {
|
2024-07-18 17:41:23 +08:00
|
|
|
|
|
|
|
|
|
transform:translate(10px);
|
2024-07-17 17:21:52 +08:00
|
|
|
|
background: #fff;
|
|
|
|
|
width: 1552px;
|
|
|
|
|
margin: 30px auto;
|
|
|
|
|
border-radius: 18px;
|
|
|
|
|
padding-top: 16px;
|
|
|
|
|
padding-bottom: 24px;
|
|
|
|
|
min-height: 300px;
|
|
|
|
|
display: flex; /* 添加此行启用Flex布局 */
|
|
|
|
|
flex-wrap: wrap; /* 允许Flex子项目换行 */
|
|
|
|
|
box-sizing: border-box; /* 确保padding计算在总宽内 */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.tb-pick-content-item {
|
|
|
|
|
border-radius: 12px;
|
|
|
|
|
border: 1px solid transparent;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
margin: 16px 0 16px 16px; /* 调整上边距以适应新的换行布局 */
|
|
|
|
|
position: relative;
|
|
|
|
|
transition: all 0.5s;
|
|
|
|
|
width: 240px;
|
|
|
|
|
height: 358px;
|
|
|
|
|
padding: 5px;
|
|
|
|
|
|
|
|
|
|
.info-wrapper {
|
|
|
|
|
height: 48px;
|
|
|
|
|
margin-top: 8px;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
width: 96%;
|
|
|
|
|
color: #11192d;
|
|
|
|
|
display: inline-block;
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
line-height: 24px;
|
|
|
|
|
margin-left: 8px;
|
|
|
|
|
margin-right: 8px;
|
|
|
|
|
max-height: 48px;
|
|
|
|
|
word-break: break-all;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.tb-pick-content-item:hover {
|
|
|
|
|
border: 1px solid #ff6200;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.img-wrapper {
|
2024-07-18 17:41:23 +08:00
|
|
|
|
// background-image: url();
|
2024-07-17 17:21:52 +08:00
|
|
|
|
background-position: 50%;
|
|
|
|
|
background-repeat: no-repeat;
|
|
|
|
|
background-size: cover;
|
|
|
|
|
background-color: #f3f6f8;
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
height: 230px;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
position: relative;
|
|
|
|
|
width: 230px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.price-wrapper {
|
|
|
|
|
align-items: flex-end;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
height: 24px;
|
|
|
|
|
margin-left: 8px;
|
|
|
|
|
margin-top: 8px;
|
|
|
|
|
|
|
|
|
|
.price-unit {
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
line-height: 14px;
|
|
|
|
|
margin-bottom: 1px;
|
|
|
|
|
margin-right: 2px;
|
|
|
|
|
color: #ff5500;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.price-value {
|
|
|
|
|
font-size: 24px;
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
line-height: 24px;
|
|
|
|
|
color: #ff5500;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|