<template>
|
<div class="list-root">
|
<div class="search">
|
<CustomSearch3 v-on:search="Search"></CustomSearch3>
|
</div>
|
<div class="line"></div>
|
<div class="data-list"
|
v-infinite-scroll="loadBottom"
|
:infinite-scroll-disabled="allLoaded"
|
:infinite-scroll-distance="10">
|
<template v-for="item in data.data">
|
<div class="image-item"
|
:key="item.key"
|
@click="ToDetail(item.id,item.name)">
|
<div class="item-left">
|
<img :src="item.img"/>
|
</div>
|
<div class="item-right">
|
<div class="item-title">{{ item.name }}</div>
|
<div class="item-context">{{ item.keyWord }}</div>
|
</div>
|
</div>
|
<div :key="item.key" class="line"></div>
|
</template>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import CustomSearch3 from "@/components/CustomSearch3";
|
import {GetDataList as Api_GetDataList} from "@/api/apilist";
|
|
export default {
|
name: "list",
|
components: {CustomSearch3},
|
data() {
|
return {
|
dataType: 4,
|
searchType: "title",
|
searchName: "",
|
data: {
|
currentPage: 1,
|
pageSize: 5,
|
total: 0,
|
data: []
|
},
|
allLoaded: false
|
};
|
},
|
methods: {
|
Search: function (searchType, searchName) {
|
this.searchType = searchType;
|
this.searchName = searchName;
|
Api_GetDataList(this.dataType, searchType, searchName, 1, this.data.pageSize).then(res => {
|
this.currentPage = res.currentPage;
|
this.pageSize = res.pageSize;
|
this.total = res.total;
|
this.data = res;
|
}, rej => {
|
alert(rej);
|
}).catch(err => {
|
console.log(err);
|
alert("错误的请求!");
|
});
|
},
|
loadBottom: function () {
|
Api_GetDataList(this.dataType, this.searchType, this.searchName, this.data.currentPage + 1, this.data.pageSize).then(res => {
|
this.data.currentPage = res.currentPage;
|
this.data.pageSize = res.pageSize;
|
this.data.total = res.total;
|
if (res.data.length > 0) {
|
this.data.data = this.data.data.concat(res.data);
|
} else {
|
this.allLoaded = true;
|
}
|
}, rej => {
|
alert(rej);
|
}).catch(err => {
|
console.log(err);
|
alert("错误的请求!");
|
});
|
},
|
ToDetail: function (id, name) {
|
this.$router.push({name: "personage-detail", query: {id: id, name: name}})
|
}
|
},
|
created() {
|
this.Search("title", "");
|
}
|
}
|
</script>
|
|
<style scoped>
|
li {
|
list-style-type: none;
|
}
|
|
.list-root {
|
display: flex;
|
flex-direction: column;
|
justify-content: flex-start;
|
align-items: center;
|
width: 100%;
|
}
|
|
.search {
|
width: 100%;
|
margin-top: 3vh;
|
}
|
|
.search .custom-search3 {
|
width: 90%;
|
margin-left: 5%;
|
}
|
|
.line {
|
width: 100%;
|
border: 1px solid #EEEEEE;
|
margin-top: 3vh;
|
margin-bottom: 3vh;
|
opacity: 1;
|
}
|
|
.data-list {
|
width: 90%;
|
height: 65vh;
|
margin-left: 5%;
|
overflow: scroll;
|
}
|
|
.data-list .line {
|
width: 100%;
|
margin-bottom: 2vh;
|
}
|
|
.data-list /deep/ .image-item {
|
display: flex;
|
flex-direction: row;
|
justify-content: flex-start;
|
align-items: flex-start;
|
|
width: 100%;
|
margin-bottom: 2vh;
|
}
|
|
.data-list /deep/ .image-item .item-left {
|
width: 30%;
|
}
|
|
.data-list /deep/ .image-item .item-left img {
|
width: 100%;
|
height: 12vh;
|
border-radius: 10px;
|
object-fit: cover;
|
}
|
|
.data-list /deep/ .image-item .item-right {
|
width: 70%;
|
}
|
|
.data-list /deep/ .image-item .item-title {
|
text-overflow: ellipsis;
|
overflow: hidden;
|
white-space: nowrap;
|
padding-left: 2rem;
|
|
text-align: left;
|
font-size: 2rem;
|
font-family: Source Han Serif CN;
|
font-weight: bold;
|
line-height: 4rem;
|
color: #BC0000;
|
}
|
|
.data-list /deep/ .image-item .item-context {
|
display: -webkit-box;
|
-webkit-line-clamp: 2;
|
-webkit-box-orient: vertical;
|
text-overflow: ellipsis;
|
overflow: hidden;
|
padding-left: 2rem;
|
|
font-size: 1.62rem;
|
font-family: Source Han Sans CN;
|
font-weight: 400;
|
line-height: 2rem;
|
color: #767676;
|
text-align: left;
|
}
|
</style>
|