<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="text-item" :key="item.key" @click="ToDetail(item.id, item.name)">
|
<div class="item-title">{{ item.name }}</div>
|
<div class="item-context">{{ item.keyWord }}</div>
|
</div>
|
<div class="line" :key="item.key"></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: 1,
|
searchType: "title",
|
searchName: "",
|
data: {
|
currentPage: 1,
|
pageSize: 10,
|
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: "memory-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-top: 1px solid #EEEEEE;
|
margin-top: 3vh;
|
margin-bottom: 3vh;
|
opacity: 1;
|
}
|
|
.data-list {
|
width: 90%;
|
height: 65vh;
|
display: flex;
|
flex-direction:column;
|
justify-content: flex-start;
|
align-items: center;
|
}
|
|
.data-list .line {
|
width: 100%;
|
margin-top: 2vh;
|
margin-bottom: 2vh;
|
}
|
|
|
.data-list /deep/ .text-item {
|
width: 90%;
|
}
|
|
.data-list /deep/ .text-item .item-title {
|
text-align: left;
|
font-size: 2rem;
|
font-family: Source Han Serif CN;
|
font-weight: bold;
|
line-height: 4rem;
|
color: #BC0000;
|
}
|
|
.data-list /deep/ .text-item .item-context {
|
text-align: left;
|
font-size: 1.62rem;
|
font-family: Source Han Sans CN;
|
font-weight: 400;
|
line-height: 2rem;
|
color: #767676;
|
text-align: left;
|
}
|
</style>
|