|
@@ -7,8 +7,12 @@
|
|
|
v-model.trim="keyword"
|
|
|
type="text"
|
|
|
placeholder="请输入要搜索的内容..."
|
|
|
+ @keyup.enter="handleSearch"
|
|
|
+ >
|
|
|
+ <button
|
|
|
+ class="search"
|
|
|
+ @click="handleSearch"
|
|
|
>
|
|
|
- <button class="search">
|
|
|
<img
|
|
|
class=""
|
|
|
src="@/assets/images/icon_search-big.png"
|
|
@@ -19,41 +23,58 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <div class="tab-bar">
|
|
|
- <button
|
|
|
+ <Swiper
|
|
|
+ class="tab-bar"
|
|
|
+ :slides-per-view="7"
|
|
|
+ :pagination="{
|
|
|
+ clickable: true,
|
|
|
+ }"
|
|
|
+ :modules="[Pagination]"
|
|
|
+ >
|
|
|
+ <SwiperSlide
|
|
|
v-for="item in collectionTypeList"
|
|
|
- :key="item.id"
|
|
|
- class="tab-item"
|
|
|
- :class="{
|
|
|
- active: item.id === activeTabId
|
|
|
- }"
|
|
|
- @click="activeTabId = item.id"
|
|
|
+ :key="item.value"
|
|
|
>
|
|
|
- {{ item.cn }}
|
|
|
- </button>
|
|
|
- </div>
|
|
|
+ <button
|
|
|
+ class="tab-item"
|
|
|
+ :class="{
|
|
|
+ active: item.value === activeTabId
|
|
|
+ }"
|
|
|
+ @click="handleTab(item.value)"
|
|
|
+ >
|
|
|
+ {{ item.label }}
|
|
|
+ </button>
|
|
|
+ </SwiperSlide>
|
|
|
+ </Swiper>
|
|
|
|
|
|
<div
|
|
|
+ v-loading="loading"
|
|
|
class="card-list"
|
|
|
>
|
|
|
+ <el-empty
|
|
|
+ v-if="!total"
|
|
|
+ style="margin-top: 50px;"
|
|
|
+ description="暂无数据"
|
|
|
+ :image-size="200"
|
|
|
+ />
|
|
|
<div
|
|
|
- v-for="item in collectionList"
|
|
|
- :key="item.name"
|
|
|
+ v-for="item in list"
|
|
|
+ :key="item.culturalRelicId"
|
|
|
class="card"
|
|
|
- @click="onClickCollection(item.bs)"
|
|
|
+ @click="onClickCollection(item.culturalRelicId)"
|
|
|
>
|
|
|
<img
|
|
|
class="thumb"
|
|
|
- :src="`https://yuhuatai.4dage.com/YHT/goodsData/3D/${item.bs}.png`"
|
|
|
+ :src="item.cover"
|
|
|
alt=""
|
|
|
draggable="false"
|
|
|
>
|
|
|
<div class="bottom">
|
|
|
<span
|
|
|
class="name"
|
|
|
- :title="item.name"
|
|
|
+ :title="item.title"
|
|
|
>
|
|
|
- {{ item.name }}
|
|
|
+ {{ item.title }}
|
|
|
</span>
|
|
|
<img
|
|
|
class="icon"
|
|
@@ -71,7 +92,7 @@
|
|
|
:size="'large'"
|
|
|
:page-size="pageSize"
|
|
|
layout="prev, pager, next"
|
|
|
- :total="collectionListlengh"
|
|
|
+ :total="total"
|
|
|
prev-text="上一页"
|
|
|
next-text="下一页"
|
|
|
:hide-on-single-page="true"
|
|
@@ -85,10 +106,13 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ref, computed, watch, onMounted, onBeforeUnmount, inject } from "vue"
|
|
|
+import { ref, watch, onMounted, inject } from "vue"
|
|
|
import { useRoute, useRouter } from "vue-router"
|
|
|
import { useStore } from "vuex"
|
|
|
-import { fetchRelicList } from "@/api.js"
|
|
|
+import { Swiper, SwiperSlide } from 'swiper/vue'
|
|
|
+import { Pagination } from 'swiper/modules'
|
|
|
+import 'swiper/css/pagination'
|
|
|
+import { getCulturalRelicsTypeListApi, getCulturalRelicsListApi } from "@/api.js"
|
|
|
|
|
|
const route = useRoute()
|
|
|
const router = useRouter()
|
|
@@ -98,29 +122,69 @@ const $env = inject('$env')
|
|
|
|
|
|
const keyword = ref('')
|
|
|
|
|
|
-const collectionTypeList = ref([{
|
|
|
- id: 'all',
|
|
|
- cn: '全部',
|
|
|
-}, ...staticConfig.collectionTypeList])
|
|
|
-const activeTabId = ref('all')
|
|
|
+const collectionTypeList = ref([])
|
|
|
+const activeTabId = ref('')
|
|
|
|
|
|
const currentPage = ref(1)
|
|
|
const pageSize = 8
|
|
|
-const collectionListlengh = computed(() => {
|
|
|
- return fetchRelicList(activeTabId.value, keyword.value, currentPage.value - 1, pageSize).total
|
|
|
-})
|
|
|
-const collectionList = computed(() => {
|
|
|
- return fetchRelicList(activeTabId.value, keyword.value, currentPage.value - 1, pageSize).list
|
|
|
-})
|
|
|
+const total = ref(0)
|
|
|
+const list = ref([])
|
|
|
+const loading = ref(false)
|
|
|
+
|
|
|
+const getTypeList = async() => {
|
|
|
+ const data = await getCulturalRelicsTypeListApi()
|
|
|
+ collectionTypeList.value = [
|
|
|
+ {
|
|
|
+ label: '全部',
|
|
|
+ value: ''
|
|
|
+ },
|
|
|
+ ...data
|
|
|
+ ]
|
|
|
+}
|
|
|
+
|
|
|
+const getCulturalRelicsList = async() => {
|
|
|
+ try {
|
|
|
+ loading.value = true
|
|
|
+ const data = await getCulturalRelicsListApi({
|
|
|
+ title: keyword.value,
|
|
|
+ culturalRelicType: activeTabId.value,
|
|
|
+ pageSize,
|
|
|
+ pageNum: currentPage.value
|
|
|
+ })
|
|
|
+ total.value = data.total
|
|
|
+ list.value = data.rows
|
|
|
+ } finally {
|
|
|
+ loading.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const handleTab = (val) => {
|
|
|
+ activeTabId.value = val
|
|
|
+ getCulturalRelicsList()
|
|
|
+}
|
|
|
+
|
|
|
+const handleSearch = () => {
|
|
|
+ currentPage.value = 1
|
|
|
+ getCulturalRelicsList()
|
|
|
+}
|
|
|
|
|
|
function onClickCollection(id) {
|
|
|
router.push({
|
|
|
name: 'CollectionDetail',
|
|
|
- query: {
|
|
|
+ params: {
|
|
|
id,
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ getTypeList()
|
|
|
+ getCulturalRelicsList()
|
|
|
+})
|
|
|
+
|
|
|
+watch(currentPage, () => {
|
|
|
+ getCulturalRelicsList()
|
|
|
+})
|
|
|
</script>
|
|
|
|
|
|
<style lang="less" scoped>
|
|
@@ -172,10 +236,10 @@ function onClickCollection(id) {
|
|
|
color: #FFFFFF;
|
|
|
}
|
|
|
>button.search{
|
|
|
- pointer-events: none;
|
|
|
width: 40px;
|
|
|
height: 40px;
|
|
|
padding: 5px;
|
|
|
+ cursor: pointer;
|
|
|
>img{
|
|
|
width: 100%;
|
|
|
height: 100%;
|
|
@@ -184,21 +248,31 @@ function onClickCollection(id) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- >.tab-bar{
|
|
|
+ .tab-bar{
|
|
|
+ --swiper-theme-color: #FFE794;
|
|
|
+ --swiper-pagination-bottom: 20px;
|
|
|
+ position: relative;
|
|
|
+ margin: 0 auto;
|
|
|
+ width: 80vw;
|
|
|
height: 138px;
|
|
|
- display: flex;
|
|
|
- justify-content: center;
|
|
|
- align-items: center;
|
|
|
+ overflow: hidden;
|
|
|
text-align: center;
|
|
|
- gap: calc(184 / 1920 * 100vw);
|
|
|
- >.tab-item {
|
|
|
+ ::v-deep .swiper-wrapper {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ height: 100%;
|
|
|
+ }
|
|
|
+ ::v-deep .swiper-slide {
|
|
|
+ flex-shrink: 0;
|
|
|
+ }
|
|
|
+ .tab-item {
|
|
|
font-family: Source Han Sans CN, Source Han Sans CN;
|
|
|
font-weight: 400;
|
|
|
font-size: 24px;
|
|
|
color: #474747;
|
|
|
height: 38px;
|
|
|
}
|
|
|
- >.tab-item.active{
|
|
|
+ .tab-item.active{
|
|
|
font-weight: bold;
|
|
|
position: relative;
|
|
|
z-index: 0;
|