19
19
<div class="total-reply">{{infos.reply_count}} 回复</div>
20
20
</div>
21
21
22
+ <div class =" reply-input" >
23
+ <input v-model.trim =" replyContent" type =" text" >
24
+ <button @click =" reply('')" type =" button" >回复</button>
25
+ </div>
22
26
23
27
<div v-for =" (item, index) of infos.replies" class =" reply-item" >
24
28
27
31
<img :src =" item.author.avatar_url" alt =" " >
28
32
<div class =" reply-desc" >
29
33
<router-link :to =" {name: 'user', params: {name: item.author && item.author.loginname}}" >{{item.author.loginname}}</router-link>
30
-   ; {{index+1}}楼 • {{changeTime(item.create_at)}}
34
+ {{index+1}}楼 • {{changeTime(item.create_at)}}
35
+ <span @click =" currentIndex=index" class =" reply-at" >回复</span>
36
+ <i @click =" ups(index)" :class =" [currentUps===index ? 'ups-yes' : 'ups-no']" class =" icon-reply-at" ></i>
31
37
</div>
32
38
</div>
33
39
</div>
34
40
35
41
<div v-html =" item.content" class =" reply-content" ></div>
36
42
43
+ <transition name="slide-top">
44
+ <div v-show =" currentIndex===index" class =" reply-one" >
45
+ <input type =" text" name =" " v-model.trim =" replyOneContent" :placeholder =" '@' + item.author.loginname" >
46
+ <button @click =" reply(item.id, item.author.loginname)" >回复</button>
47
+ <button @click =" currentIndex=null;replyOneContent=''" >取消</button>
48
+ </div>
49
+ </transition>
50
+
51
+
37
52
</div>
38
53
39
54
</div>
@@ -56,7 +71,14 @@ export default {
56
71
infos: {},
57
72
types: { share: ' 分享' , ask: ' 问答' , job: ' 招聘' },
58
73
oImgs: [],
59
- isCollected: false
74
+ isCollected: false ,
75
+ replyContent: ' ' ,
76
+ replyOneContent: ' ' ,
77
+ isReplyOne: false ,
78
+ isUps: false ,
79
+ currentIndex: null , // 回复某个人的 index
80
+ currentUps: null
81
+
60
82
}
61
83
},
62
84
created () {
@@ -66,6 +88,7 @@ export default {
66
88
this .axios .get (' https://cnodejs.org/api/v1/topic/' + this .id )
67
89
.then (result => result .data .data )
68
90
.then (data => this .infos = data)
91
+ .then (data => console .log (' data' , data))
69
92
.then (() => this .$store .commit (' viewArcticle' , false ))
70
93
.then (() => {
71
94
this .oImgs = document .querySelector (' .md' ).querySelectorAll (' img' );
@@ -128,6 +151,28 @@ export default {
128
151
}
129
152
})
130
153
}
154
+ },
155
+ reply (id , name ) {
156
+ if (! this .ak ) {
157
+ this .$store .commit (' showLogin' , true );
158
+ return ;
159
+ }
160
+ else if (! id) {
161
+ this .axios .post (` https://cnodejs.org/api/v1/topic/${ this .id } /replies` , {
162
+ accesstoken: this .ak ,
163
+ content: this .replyContent
164
+ }).then (() => location .reload ())
165
+ } else {
166
+ console .log (' id' , id);
167
+ this .axios .post (` https://cnodejs.org/api/v1/topic/${ this .id } /replies` , {
168
+ accesstoken: this .ak ,
169
+ content: ' @' + name + ' ' + this .replyOneContent ,
170
+ reply_id: id
171
+ }).then (() => location .reload ())
172
+ }
173
+ },
174
+ ups (index ) {
175
+ this .currentUps === index ? this .currentUps = null : this .currentUps = index;
131
176
}
132
177
}
133
178
}
@@ -141,7 +186,8 @@ export default {
141
186
height : 100% ;
142
187
padding : 8px 5px 0 5px ;
143
188
background-color : rgba (0 , 0 , 0 , .07 );
144
- overflow : auto ;
189
+ overflow-x : hidden ;
190
+ overflow-y : auto ;
145
191
.body {
146
192
background-color : white ;
147
193
height : 100% ;
@@ -178,10 +224,11 @@ export default {
178
224
}
179
225
180
226
.reply {
227
+
181
228
.other {
182
229
margin-top : 20px ;
183
230
margin-bottom : 10px ;
184
- border-bottom : 1px solid rgba (0 , 0 , 0 , .05 );
231
+ // border-bottom: 1px solid rgba(0, 0, 0, .05);
185
232
padding-left : 10px ;
186
233
display : flex ;
187
234
justify-content : space-between ;
@@ -203,6 +250,34 @@ export default {
203
250
}
204
251
}
205
252
253
+ .reply-input {
254
+ width : 100% ;
255
+ height : 50px ;
256
+ background-color : white ;
257
+ margin-bottom : 10px ;
258
+ padding-left : 10px ;
259
+ padding-top : 5px ;
260
+ display : flex ;
261
+ justify-content : center ;
262
+ align-items : center ;
263
+ input {
264
+ width : 80% ;
265
+ height : 40px ;
266
+ font-size : 1.3rem ;
267
+ border-bottom : 1px solid rgba (0 , 0 , 0 , .5 );
268
+ margin-right : 10px ;
269
+ padding-left : 5px ;
270
+ padding-right : 5px ;
271
+ }
272
+ button {
273
+ font-size : 1.3rem ;
274
+ padding : 3px 5px ;
275
+ background-color : #2196f3 ;
276
+ color : white ;
277
+ border-radius : 3px ;
278
+ }
279
+ }
280
+
206
281
.total-reply {
207
282
text-align : center ;
208
283
width : 100px ;
@@ -229,11 +304,68 @@ export default {
229
304
border-radius : 3px ;
230
305
}
231
306
.reply-desc {
307
+ position : relative ;
232
308
flex : 1 ;
233
309
padding-left : 10px ;
310
+ .reply-at {
311
+ position : absolute ;
312
+ right : 50px ;
313
+ }
314
+ .icon-reply-at {
315
+ position : absolute ;
316
+ right : 20px ;
317
+ top : -2px ;
318
+ display : inline-block ;
319
+ width : 20px ;
320
+ height : 20px ;
321
+
322
+ }
323
+ .ups-yes {
324
+ background : url (' ../../common/icons/icon-ups-yes.svg' ) no-repeat ;
325
+ background-size : contain ;
326
+ }
327
+ .ups-no {
328
+ background : url (' ../../common/icons/icon-ups-no.svg' ) no-repeat ;
329
+ background-size : contain ;
330
+ }
234
331
}
235
332
}
236
333
}
334
+
335
+ .reply-one {
336
+ width : 100% ;
337
+ height : 30px ;
338
+ // background-color: red;
339
+ margin-bottom : 20px ;
340
+ padding-top : 2px ;
341
+
342
+ input {
343
+ width : 65% ;
344
+ height : 100% ;
345
+ background : none ;
346
+ border-bottom : 1px solid rgba (0 , 0 , 0 , .1 );
347
+ font-size : 1.3rem ;
348
+ color : gray ;
349
+ }
350
+ input :focus {
351
+ border-bottom : 1px solid #00bcd4 ;
352
+ color : black ;
353
+ }
354
+ button {
355
+ font-size : 1.2rem ;
356
+ vertical-align : bottom ;
357
+ padding : 2px 5px ;
358
+ border-radius : 2px ;
359
+ }
360
+ button :nth-of-type (1 ) {
361
+ background-color : #2196f3 ;
362
+ color : white ;
363
+ }
364
+ button :nth-of-type (2 ) {
365
+ background-color : white ;
366
+ color : gray ;
367
+ }
368
+ }
237
369
}
238
370
}
239
371
0 commit comments