mycollect.vue
8.4 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
<template>
<div class="container">
<div class="flextwo mykind">
<div
class="fenleiword"
:class="fenlei == 0 ? 'fenleiactive' : ''"
@click="getfen(0)"
>
我的发布
</div>
<div
class="fenleiword"
:class="fenlei == 1 ? 'fenleiactive' : ''"
@click="getfen(1)"
>
我的关注
</div>
<div
class="fenleiword"
:class="fenlei == 2 ? 'fenleiactive' : ''"
@click="getfen(2)"
>
我的点赞
</div>
<div
class="fenleiword"
:class="fenlei == 3 ? 'fenleiactive' : ''"
@click="getfen(3)"
>
我的评论
</div>
</div>
<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 class="tieziitem mycollectitem">
<div class="tiezitop flexone">
<div class="tieziimg">
<img src="../../../assets/touxiang_img@2x.png" alt="" />
</div>
<div class="tieziright">
<div class="tiezirighttop flex">
<div>
<div class="tieziming">中面小麦</div>
<div class="tiezifen">30分钟</div>
</div>
<div>
<div class="vipimg">
<img src="../../../assets/vip_icon@2x.png" alt="" />
<div class="vipname">VIP1</div>
</div>
<div class="tiezizhuan">面坊转让</div>
</div>
<img
src="../../../assets/banggong_icon@2x.png"
class="banggongimg"
alt=""
/>
<img
src="../../../assets/peisong_icon@2x.png"
class="banggongimg"
alt=""
/>
<img
src="../../../assets/yirenzheng_icon@2x.png"
class="banggongimg"
alt=""
/>
</div>
<div class="tiezibto flexone"></div>
</div>
</div>
<div class="tiezicontent">
<div class="teizicontenttop flextwo">
<div class="tiezicontentname">滚滚长江东逝水</div>
<img
src="../../../assets/xingxing_icon@2x.png"
alt=""
class="starimg"
/>
<img
src="../../../assets/weishoucang_icon@2x.png"
alt=""
class="starimg"
/>
</div>
<div class="tieziwordbox">滚滚长江东逝水</div>
<div class="teiziimgbox flexone">
<div class="tieziimgimg">
<img src="../../../assets/banner.png" alt="" />
</div>
<div class="tieziimgimg">
<img src="../../../assets/banner.png" alt="" />
</div>
<div class="tieziimgimg">
<img src="../../../assets/banner.png" alt="" />
</div>
<div class="tieziimgimg">
<img src="../../../assets/banner.png" alt="" />
</div>
<div class="tieziimgimg">
<img src="../../../assets/banner.png" alt="" />
</div>
</div>
<div class="tiezipingbot">
<div class="teizipingitem flexone">
<img
src="../../../assets/pinglun_icon@2x.png"
alt=""
class="lunimg"
/>
1005
</div>
<div class="teizipingitem flexone">
<img
src="../../../assets/zan_icon@2x.png"
alt=""
class="lunimg zanimg"
/>
1005
</div>
<div class="teizipingitem flexone">
<img
src="../../../assets/cai_icon@2x.png"
alt=""
class="lunimg zanimg"
/>
1005
</div>
</div>
</div>
</div> -->
</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,
fenlei: 0,
tiezilist: []
};
},
created() {
this.fenlei = this.$route.query.type;
if (this.fenlei == 0) {
this.getfabu();
} else if (this.fenlei == 1) {
this.getguanzhu();
} else if (this.fenlei == 2) {
this.getdainzian();
} else if (this.fenlei == 3) {
this.getpinglun();
}
},
methods: {
onLoad() {
// 异步更新数据
// setTimeout 仅做示例,真实场景中一般为 ajax 请求
setTimeout(() => {
let newpage = this.page;
newpage++;
this.page = newpage;
if (this.fenlei == 0) {
this.getfabu();
} else if (this.fenlei == 1) {
this.getguanzhu();
} else if (this.fenlei == 2) {
this.getdainzian();
} else if (this.fenlei == 3) {
this.getpinglun();
}
// 加载状态结束
this.loading = false;
// 数据全部加载完成
if (this.showpull == false) {
this.finished = true;
}
}, 1000);
},
// 头部切换
getfen(id) {
this.fenlei = id;
this.page = 1;
this.tiezilist = [];
if (this.fenlei == 0) {
this.getfabu();
} else if (this.fenlei == 1) {
this.getguanzhu();
} else if (this.fenlei == 2) {
this.getdainzian();
} else if (this.fenlei == 3) {
this.getpinglun();
}
},
// 获取我的发布
getfabu() {
let that = this;
var url = "/api/forum/get_my_forum";
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);
});
},
// 获取我的关注
getguanzhu() {
let that = this;
var url = "/api/forum/get_my_forum_attention";
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);
});
},
// 获取论我的点赞
getdainzian() {
let that = this;
var url = "/api/forum/get_my_forum_praise";
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);
});
},
// 获取我的评论
getpinglun() {
let that = this;
var url = "/api/forum/get_my_forum_comments";
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 scoped>
@import "../../style/homepage.css";
.mycollectlist {
margin-top: 1rem;
}
.nodata {
color: #999;
font-size: 0.28rem;
text-align: center;
margin-top: 1.5rem;
}
</style>