|
@@ -1,16 +1,16 @@
|
|
|
<template>
|
|
|
- <div class="report-home">
|
|
|
- <div v-if="list.length && list.length > 0">
|
|
|
+ <div class="report-home" ref="wrapper">
|
|
|
+ <div v-if="listState.list.length && listState.list.length > 0">
|
|
|
<van-list
|
|
|
- v-model="loading"
|
|
|
- :finished="finished"
|
|
|
+ v-model="listState.loading"
|
|
|
+ :finished="listState.finished"
|
|
|
:immediate-check="false"
|
|
|
finished-text="没有更多了"
|
|
|
@load="onLoad"
|
|
|
:offset="50"
|
|
|
>
|
|
|
<ul class="list">
|
|
|
- <li class="item" v-for="item in list" :key="item.id" @click="$router.push(`/reportdetail/${item.id}`)">
|
|
|
+ <li class="item" v-for="item in listState.list" :key="item.id" @click="goDetail(item)">
|
|
|
<div class="item-img">
|
|
|
<img :src="item.img" alt="">
|
|
|
</div>
|
|
@@ -53,57 +53,86 @@ import Empty from '@/components/common/Empty.vue'
|
|
|
|
|
|
export default class Home extends Vue {
|
|
|
protected getList!: any
|
|
|
- list = []
|
|
|
- data = [
|
|
|
- { id: 1, title: '2019-2020年城际高速铁路和城际轨道交通市场研究报告', img: 'https://s1.ax1x.com/2020/05/19/Y5fgl6.png', price: 199, before_price: 299, pushtime: 1577780169 },
|
|
|
- { id: 2, title: '2019-2020年城际高速铁路和城际轨道交通市场研究报告', img: 'https://s1.ax1x.com/2020/05/19/Y5fROO.png', price: 199, before_price: 299, pushtime: 1577780169 },
|
|
|
- { id: 3, title: '2019-2020年城际高速铁路和城际轨道交通市场研究报告', img: 'https://s1.ax1x.com/2020/05/19/Y5fcSx.png', price: 199, before_price: 299, pushtime: 1577780169 },
|
|
|
- { id: 4, title: '2019-2020年城际高速铁路和城际轨道交通市场研究报告', img: 'https://s1.ax1x.com/2020/05/19/Y5fyf1.png', price: 199, before_price: 299, pushtime: 1577780169 },
|
|
|
- { id: 5, title: '2019-2020年城际高速铁路和城际轨道交通市场研究报告', img: 'https://s1.ax1x.com/2020/05/19/Y5f26K.png', price: 199, before_price: 299, pushtime: 1577780169 },
|
|
|
- { id: 6, title: '2019-2020年城际高速铁路和城际轨道交通市场研究报告', img: 'https://s1.ax1x.com/2020/05/19/Y5ffmD.png', price: 199, before_price: 299, pushtime: 1577780169 },
|
|
|
- { id: 7, title: '2019-2020年城际高速铁路和城际轨道交通市场研究报告', img: 'https://s1.ax1x.com/2020/05/19/Y5fh0e.png', price: 199, before_price: 299, pushtime: 1577780169 }
|
|
|
- ]
|
|
|
+ listState = {
|
|
|
+ list: [],
|
|
|
+ loading: false,
|
|
|
+ finished: false,
|
|
|
+ currentPage: 1,
|
|
|
+ totalPage: 0,
|
|
|
+ scroll: 0
|
|
|
+ }
|
|
|
|
|
|
- loading = false
|
|
|
- finished = false
|
|
|
- currentPage = 1
|
|
|
- totalPage = 0
|
|
|
+ beforeRouteEnter (to, from, next) {
|
|
|
+ console.log(to, from)
|
|
|
+ if (from.name === 'detail') {
|
|
|
+ to.meta.isBack = true
|
|
|
+ } else {
|
|
|
+ to.meta.isBack = false
|
|
|
+ }
|
|
|
+ next()
|
|
|
+ }
|
|
|
|
|
|
created () {
|
|
|
- this.getReportList()
|
|
|
+ // this.getReportList()
|
|
|
+ }
|
|
|
+
|
|
|
+ activated () {
|
|
|
+ if (!this.$route.meta.isBack) {
|
|
|
+ this.listState = {
|
|
|
+ list: [],
|
|
|
+ loading: false,
|
|
|
+ finished: false,
|
|
|
+ currentPage: 1,
|
|
|
+ totalPage: 0,
|
|
|
+ scroll: 0
|
|
|
+ }
|
|
|
+ this.getReportList()
|
|
|
+ }
|
|
|
+ this.$route.meta.isBack = false
|
|
|
+ ;(this.$refs.wrapper as any).scrollTop = this.listState.scroll
|
|
|
+ }
|
|
|
+
|
|
|
+ beforeRouteLeave (to, form, next) {
|
|
|
+ console.log((this.$refs.wrapper as any).scrollTop)
|
|
|
+ this.listState.scroll = (this.$refs.wrapper as any).scrollTop
|
|
|
+ next()
|
|
|
}
|
|
|
|
|
|
getReportList () {
|
|
|
- this.loading = true
|
|
|
- this.getList(`page_index=${this.currentPage}`).then((res: any) => {
|
|
|
+ this.listState.loading = true
|
|
|
+ this.getList(`page_index=${this.listState.currentPage}`).then((res: any) => {
|
|
|
if (res.error_code === 0 && res.data.list) {
|
|
|
const rows = res.data.list
|
|
|
- this.loading = false
|
|
|
- this.totalPage = res.data.page_count
|
|
|
+ this.listState.loading = false
|
|
|
+ this.listState.totalPage = res.data.page_count
|
|
|
if (rows === null || rows.length === 0) {
|
|
|
- this.finished = true
|
|
|
+ this.listState.finished = true
|
|
|
return
|
|
|
}
|
|
|
- if (this.currentPage >= this.totalPage) {
|
|
|
- this.finished = true
|
|
|
+ if (this.listState.currentPage >= this.listState.totalPage) {
|
|
|
+ this.listState.finished = true
|
|
|
}
|
|
|
- if (this.currentPage === 1) {
|
|
|
- this.list = rows
|
|
|
+ if (this.listState.currentPage === 1) {
|
|
|
+ this.listState.list = rows
|
|
|
} else {
|
|
|
- this.list = this.list.concat(rows)
|
|
|
+ this.listState.list = this.listState.list.concat(rows)
|
|
|
}
|
|
|
} else {
|
|
|
- this.finished = true
|
|
|
+ this.listState.finished = true
|
|
|
}
|
|
|
}).catch(() => {
|
|
|
- this.finished = true
|
|
|
+ this.listState.finished = true
|
|
|
})
|
|
|
}
|
|
|
|
|
|
onLoad () {
|
|
|
- this.currentPage++
|
|
|
+ this.listState.currentPage++
|
|
|
this.getReportList()
|
|
|
}
|
|
|
+
|
|
|
+ goDetail (item) {
|
|
|
+ this.$router.push(`/detail/${item.id}`)
|
|
|
+ }
|
|
|
}
|
|
|
</script>
|
|
|
<style lang="scss">
|
|
@@ -122,14 +151,16 @@ export default class Home extends Vue {
|
|
|
right: 16px;
|
|
|
bottom: 0;
|
|
|
left: 16px;
|
|
|
- border-bottom: 1px solid #ebedf0;
|
|
|
- -webkit-transform: scaleY(0.5);
|
|
|
- transform: scaleY(0.5);
|
|
|
+ border-bottom: 1px solid rgba(0, 0, 0, 0.02);
|
|
|
+ // -webkit-transform: scaleY(0.5);
|
|
|
+ // transform: scaleY(0.5);
|
|
|
}
|
|
|
.item-img{
|
|
|
width: 80px;
|
|
|
height: 80px;
|
|
|
+ border-radius: 4px;
|
|
|
margin-right: 16px;
|
|
|
+ overflow: hidden;
|
|
|
img{
|
|
|
width: 100%;
|
|
|
height: 100%;
|