GoodEvaluateAndQuestion.vue
13.2 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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
<!--
* @FileDescription:商品评价和问答
* @Author: kahu
* @Date: 2022/11/7
* @LastEditors: kahu
* @LastEditTime: 2022/11/7
-->
<template>
<div class="content">
<view class="evaQaTab flex-items flex-sp-around">
<view
:class="{active: activeTab === 1}"
class="evaBtn"
@click="activeTab = 1"
>
<view class="tabTit">宝贝评价({{ commentList.length }})</view>
</view>
<view
:class="{active: activeTab === 2}"
class="qaBtn"
@click="activeTab = 2"
>
<view class="tabTit">商品问答({{ problemsTotal }})</view>
</view>
</view>
<!-- 评价 -->
<view class="borRig-line-20"></view>
<view
class="evaluate-box flex-start flex-column"
v-show="activeTab === 1"
>
<view
class="evaluateTag-box"
v-if="commentList.length>0"
>
<view class="evaluateTag-text">
全部({{ commentList.length }})
</view>
</view>
<view
class="evaluate-contentbox mar-top-30"
v-for="(commentItem, commentIndex) in commentList.slice(0,2)"
:key="commentIndex"
>
<view class="evaluate-content flex-items flex-row flex-sp-between">
<view class="flex-items">
<image
class="user-headSmallImg"
:src="$baseURL+commentItem.headImage"
></image>
<label class="fs28 mar-left-20">{{ commentItem.name }}</label>
</view>
<label class="font-color-999 fs22">{{ commentItem.createTime }}</label>
</view>
<view class="evaluateDes-box">
<label class="evaluateDes">{{ commentItem.comment }}</label>
</view>
<view
class="item-image-box"
v-if="commentItem.image"
>
<view
v-for="(imgItem, imgIndex) in (commentItem.image.split(',')||[])"
:key="imgIndex"
>
<image
@click="handlePreviewImage(commentList[commentIndex].images,imgIndex)"
class="img-item"
:src="$baseURL+imgItem"
></image>
</view>
</view>
<view class="item-line"></view>
<view
class="item-like-box"
v-if="commentItem.addComment !== ''"
>
<view class="addEvaluate">
<view>追加评价:{{ commentItem.addComment }}</view>
<view
class="item-image-box"
v-if="commentItem.addImages"
>
<view
v-for="(itemAddImg, imgIndex) in commentItem.addImages"
:key="imgIndex"
>
<image
@click="handlePreviewImage(commentList[commentIndex].addImages,imgIndex)"
class="img-item"
:src="$baseURL+itemAddImg"
>
</image>
</view>
</view>
</view>
</view>
<view class="like-box">
<image
class="like-img"
@click="handlePraise(commentItem,0)"
src="https://zhgw-uat.028wlkj.com/cdwlMall/zsfwzxt/file/static/images/praiseActiveIcon.png"
v-if="commentItem.ifLike === 1"
></image>
<image
class="like-img"
@click="handlePraise(commentItem,1)"
src="https://zhgw-uat.028wlkj.com/cdwlMall/zsfwzxt/file/static/images/praiseIcon.png"
v-else
></image>
<view class="like-num">{{ commentItem.likes }}</view>
</view>
</view>
<view
class="moreBox"
v-if="commentList.length>0"
@click="handleJumpToComments"
>
<label class="fs24">查看全部</label>
<image
class="evaluateAllArrow-icon mar-left-10"
src="https://zhgw-uat.028wlkj.com/cdwlMall/zsfwzxt/file/static/img//user/arrow.png"
></image>
</view>
</view>
<!-- 问答 -->
<view class="borRig-line-20"></view>
<view
class="questions"
v-show="activeTab === 2"
>
<view class="questionInfo flex-items flex-row flex-sp-between">
<view class="infoTit">宝贝好不好,问问已买过的人</view>
<view
class="putQuestion"
@click="handleJumpToQuestion"
>去提问
</view>
</view>
<view class="listBox">
<QuestionsAndAnswersList
:product-info="productInfo"
:problems-list="problemsList"
/>
<view
class="moreBox"
v-if="problemsList.length>0"
@click="handleJumpAllAnswer"
>
<label class="fs24">查看全部</label>
<image
class="evaluateAllArrow-icon mar-left-10"
src="https://zhgw-uat.028wlkj.com/cdwlMall/zsfwzxt/file/static/img//user/arrow.png"
></image>
</view>
</view>
</view>
</div>
</template>
<script>
const NET = require('../../../utils/request')
const API = require('../../../config/api')
import lodash from 'lodash'
import QuestionsAndAnswersList from "./QuestionsAndAnswersList";
export default {
name: "GoodEvaluateAndQuestion",
components: {QuestionsAndAnswersList},
data() {
return {
// 当前选中的tab
activeTab: 1, // 1评价 2问答
problemsList: [], // 问题列表
problemsTotal:0 //问题总数
}
},
props: {
commentList: {
type: Array,
default: () => []
},
productInfo: {
type: Object,
default: () => ({})
}
},
mounted() {
this.handleGetProblemList()
},
methods: {
/**
* 获取问答数据
* @return {Promise<void>}
*/
async handleGetProblemList() {
if(!this.productInfo.productId){
return
}
const res = await NET.request(API.getProblems, {
productId: this.productInfo.productId,
page: 1,
pageSize: 2
}, 'GET')
this.problemsList = res.data.list
this.problemsTotal = res.data.total
},
/**
* 放大查看照片
* @param dataList 所有照片
* @param currentIndex 选中索引
*/
handlePreviewImage(dataList, currentIndex) {
const newDataList = dataList.map(item => {
item = this.$baseURL + item;
return item;
})
uni.previewImage({
current: newDataList[currentIndex],
urls: newDataList
})
},
/**
* 点赞
* @param commentItem 当前评论项
* @param action 0取消1点赞
*/
handlePraise: lodash.debounce(async function (commentItem, actionType) {
uni.showLoading({
mask: true,
title: '提交中...',
})
try {
await NET.request(API.LikeOrUnLikeComment, {
commentId: commentItem.commentId,
ifLike: actionType
}, 'POST')
if (commentItem.ifLike === 1) {
commentItem.ifLike = 0
commentItem.likes--
} else {
commentItem.ifLike = 1
commentItem.likes++
}
} finally {
uni.hideLoading()
}
}, 500),
/**
* 跳转到全部评论
*/
handleJumpToComments() {
this.$jump('/pages_category_page1/goodsModule/evaluateList?commentList=' + JSON.stringify(this.commentList))
},
/**
* 跳转到提问
*/
handleJumpToQuestion() {
const paramObj = Object.assign({}, this.productInfo, {
questionNumber: this.problemsList.length,
images: this.productInfo.images[0],
})
this.$jump('/pages_category_page1/goodsModule/putQuestions', paramObj)
},
/**
* 跳转到该商品下所有问答
*/
handleJumpAllAnswer() {
const paramObj = Object.assign({}, this.productInfo, {
images: this.productInfo.images[0]
})
this.$jump('/pages_category_page1/goodsModule/answerList', paramObj)
}
}
}
</script>
<style
lang="scss"
scoped
>
.evaQaTab {
height: 82rpx;
line-height: 82rpx;
border-bottom: #F3F4F5 solid 2rpx;
font-size: 30rpx;
color: #CCCCCC;
.evaBtn {
width: 50%;
position: relative;
text-align: center;
&:before {
content: '';
width: 2rpx;
height: 30rpx;
background: #CCCCCC;
display: block;
position: absolute;
right: 0;
top: 20rpx;
}
}
.qaBtn {
width: 50%;
text-align: center;
}
.tabTit {
display: inline-block;
height: 82rpx;
line-height: 82rpx;
}
.active {
color: #333333;
.tabTit {
border-bottom: 4rpx solid #444444;
}
}
}
.questions {
.questionInfo {
padding: 0 30upx;
min-height: 150upx;
.infoTit {
font-size: 28upx;
}
.putQuestion {
width: 140upx;
height: 60upx;
background: #333333;
line-height: 60upx;
font-size: 24upx;
color: #FFEBC4;
padding-left: 20rpx;
position: relative;
&:before {
content: '';
width: 40rpx;
height: 26rpx;
top:18rpx;
background: url("https://zhgw-uat.028wlkj.com/cdwlMall/zsfwzxt/file/static/images/arrow.png") no-repeat center center;
background-size: contain;
display: block;
position: absolute;
right: 0;
}
}
}
.listBox {
padding: 0 30upx;
border-bottom: 20upx solid #EEEEEE;
.itemBox {
padding-bottom: 30upx;
border-bottom: 1upx solid #EEEEEE;
margin-bottom: 30upx;
&:last-child {
border-bottom: none;
}
.itemAsk {
display: flex;
align-items: center;
margin-bottom: 42upx;
i {
font-style: normal;
width: 38upx;
height: 38upx;
line-height: 38upx;
background: #C5AA7B;
display: block;
margin-right: 30upx;
font-size: 24upx;
color: #FFFFFF;
text-align: center;
}
span {
font-size: 28upx;
color: #333333;
}
}
.answer {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 30upx;
.answerBox {
display: flex;
align-items: center;
i {
font-style: normal;
width: 38upx;
height: 38upx;
line-height: 38upx;
background: #C5AA7B;
display: block;
text-align: center;
margin-right: 30upx;
font-size: 24rpx;
color: #FFFFFF;
}
span {
font-size: 26upx;
color: #666666;
}
}
.answerBtn {
width: 130upx;
height: 50upx;
line-height: 50upx;
border: #333333 2rpx solid;
text-align: center;
color: #333;
font-size: 24upx;
}
}
.seeAll {
margin-left: 68upx;
font-size: 28upx;
color: #C5AA7B;
}
}
}
}
.evaluate-box {
background-color: #FFFFFF;
margin-top: 20upx;
.evaluate {
width: 690upx;
padding: 20upx 0;
border-bottom: 1upx solid #EDEDED;
}
.evaluateTitle-box {
width: 690upx;
border-bottom: 1upx solid #EDEDED;
padding-bottom: 20upx;
}
.evaluateAllArrow-icon {
width: 18upx;
height: 24upx;
}
.evaluateTag-box {
margin-top: 10upx;
margin-left: 10upx;
padding-bottom: 10upx;
display: flex;
flex-wrap: wrap;
.evaluateTag-text {
background-color: #F4F4F4;
border-radius: 6upx;
padding: 16upx 14upx;
color: #656565;
margin-left: 20upx;
margin-top: 20upx;
}
}
.evaluate-contentbox {
display: flex;
justify-content: center;
flex-direction: column;
margin-left: 30upx;
// border-bottom: 1upx solid #EDEDED;
padding-bottom: 50upx;
.evaluate-content {
width: 670upx;
display: flex;
justify-content: space-between;
.user-headSmallImg {
width: 46upx;
height: 46upx;
border-radius: 50%;
}
}
.evaluateDes-box {
width: 670upx;
margin-top: 30upx;
.evaluateDes {
width: 670upx;
}
}
.addEvaluate {
padding-top: 30upx;
}
}
}
.item-image-box {
width: 700upx;
display: flex;
flex-direction: row;
flex-wrap: wrap;
.img-item {
width: 223upx;
height: 223upx;
border-radius: 10upx;
margin-right: 10upx;
margin-top: 10upx;
}
}
.item-line {
width: 690upx;
height: 1px;
background: rgba(238, 238, 238, 1);
margin-top: 20upx;
}
.item-like-box {
display: flex;
flex-direction: row;
width: 690upx;
align-items: center;
justify-content: space-between;
}
.like-box {
display: flex;
flex-direction: row;
padding-top: 30upx;
align-items: center;
justify-content: flex-end;
margin-right: 50upx;
.like-img {
width: 48upx;
height: 48upx;
}
.like-num {
font-size: 28upx;
font-weight: 500;
color: rgba(51, 51, 51, 1);
margin-left: 30upx;
}
}
.moreBox {
width: 170rpx;
height: 54rpx;
line-height: 54rpx;
margin: 0 auto 50rpx auto;
border: 2rpx solid #C5AA7B;
color: #C5AA7B;
display: flex;
align-items: center;
justify-content: center;
image {
width: 10rpx;
height: 20rpx;
}
}
</style>