myshoucang.vue
1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<template>
<div class="container">
<div class="nodata" v-if="tiezilist.length == 0">暂无数据</div>
<div class="mycollectlist" v-else>
<van-list
v-model="loading"
:finished="finished"
finished-text="没有更多了"
@load="onLoad"
>
<mytiezi :tiezilist="tiezilist" :showpull="showpull" :fenlei="fenlei" />
</van-list>
</div>
</div>
</template>
<script>
import mytiezi from "@/components/mytiezi.vue";
export default {
components: {
mytiezi
},
data(){
return{
page:1,
tiezilist: [],
showpull: true,
loading: false,
finished: false,
}
},
created(){
this.getmycollect()
},
methods:{
onLoad() {
// 异步更新数据
// setTimeout 仅做示例,真实场景中一般为 ajax 请求
setTimeout(() => {
let newpage = this.page;
newpage++;
this.page = newpage;
this.getmycollect()
// 加载状态结束
this.loading = false;
// 数据全部加载完成
if (this.showpull == false) {
this.finished = true;
}
}, 1000);
},
// 获取我的收藏
getmycollect() {
console.log(347874837)
let that = this;
var url = "/api/forum/get_my_collect";
var params = {
page: that.page,
pageNum: 10
};
console.log("参数", params);
that.$axios
.post(url, params)
.then(res => {
console.log(res);
that.tiezilist = that.tiezilist.concat(res.data);
if (that.page > 1) {
if (res.data.length == 0) {
that.showpull = false;
}
}
})
.catch(err => {
console.log(err);
});
},
}
}
</script>
<style>
.nodata {
color: #999;
font-size: 0.28rem;
text-align: center;
margin-top: 1.5rem;
}
</style>