1
1
<template >
2
- <div class =' container' >
2
+ <div class =' container' >
3
3
<div v-if =' sendVisible' >
4
4
<sendReply @close-modal =' closeModal' @reply-success =' replySuccess' :content =' content' :topicId =' id' :replyId =' replyId' ></sendReply >
5
5
</div >
11
11
</div >
12
12
<span >楼主</span >
13
13
</div >
14
- <div class =' body' >
14
+
15
+ <scroll-view class =' body' scroll-y =' true' :scroll-top =" top" enable-back-to-top =' true' @scrolltolower =' getMore' >
15
16
<div class =' title' >
16
17
<p class =' big' >{{detailData.title}}</p >
17
18
<div class =' time-info' >
20
21
<span >评论:{{detailData.reply_count}}</span >
21
22
</div >
22
23
</div >
24
+ <img class =' up-png' src =" ../../../static/up.png" mode =' widthFix' @click.stop =" goTop" >
23
25
<div v-if =' !sendVisible' class =' reply-buton' @click.stop =" showReplyModal" >评论</div >
24
26
<div class =' content' >
25
27
<wemark :mdData =' detailData.content' ></wemark >
43
45
</div >
44
46
</div >
45
47
</div >
46
- </div >
48
+ </scroll-view >
47
49
</div >
48
50
</div >
49
51
</template >
@@ -66,18 +68,12 @@ export default {
66
68
return passTime (this .detailData .create_at );
67
69
},
68
70
formatReplies () {
69
- return (
70
- this .detailData &&
71
- this .detailData .replies &&
72
- this .detailData .replies
73
- .map (_ => {
74
- return {
75
- ... _,
76
- create_at: passTime (_ .create_at )
77
- };
78
- })
79
- .reverse ()
80
- );
71
+ return this .currentReplies .map (_ => {
72
+ return {
73
+ ... _,
74
+ create_at: passTime (_ .create_at )
75
+ };
76
+ });
81
77
}
82
78
},
83
79
@@ -93,10 +89,35 @@ export default {
93
89
wx .hideLoading ();
94
90
if (res .data .success ) {
95
91
this .detailData = res .data .data ;
92
+ this .currentReplies = res .data .data .replies .reverse ().splice (0 , 10 );
93
+ this .remainReplies = res .data .data .replies ;
96
94
// this.article = res.data.content;
97
95
} else {
98
96
}
99
97
},
98
+ goTop () {
99
+ console .log (11 );
100
+ setTimeout (() => (this .top = 0 ));
101
+ this .top = 1 ;
102
+ // wx.pageScrollTo({
103
+ // scrollTop: 500,
104
+ // duration: 300
105
+ // });
106
+ },
107
+ getMore () {
108
+ if (this .remainReplies .length > 0 ) {
109
+ this .currentReplies = [
110
+ ... this .currentReplies ,
111
+ ... this .remainReplies .splice (0 , 10 )
112
+ ];
113
+ } else {
114
+ wx .showToast ({
115
+ title: " 无更多数据" ,
116
+ icon: " none" ,
117
+ duration: 2000
118
+ });
119
+ }
120
+ },
100
121
async upOrCancel (e ) {
101
122
// / todo 防抖
102
123
// console.log(e);
@@ -161,10 +182,13 @@ export default {
161
182
data () {
162
183
return {
163
184
detailData: {},
185
+ remainReplies: [],
186
+ currentReplies: [],
164
187
content: " " ,
165
188
sendVisible: false ,
166
189
id: " " ,
167
- replyId: " "
190
+ replyId: " " ,
191
+ top: 0
168
192
};
169
193
}
170
194
};
@@ -173,7 +197,7 @@ export default {
173
197
<style lang='scss' scoped>
174
198
$color : rgb (65 , 184 , 131 );
175
199
.container {
176
- min- height : 100vh ;
200
+ height : 100vh ;
177
201
background-color : rgb (245 , 245 , 239 );
178
202
.header {
179
203
display : flex ;
@@ -191,6 +215,9 @@ $color: rgb(65, 184, 131);
191
215
}
192
216
}
193
217
}
218
+ .body {
219
+ height : 90vh ;
220
+ }
194
221
.title {
195
222
background-color : white ;
196
223
margin-bottom : 20 rpx;
@@ -216,6 +243,12 @@ $color: rgb(65, 184, 131);
216
243
left : 81vw ;
217
244
color : white ;
218
245
}
246
+ .up-png {
247
+ width : 100 rpx;
248
+ top : 75vh ;
249
+ left : 81vw ;
250
+ position : fixed ;
251
+ }
219
252
.content {
220
253
background-color : white ;
221
254
margin-bottom : 20 rpx;
0 commit comments