-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmy-comments.vue
executable file
·131 lines (129 loc) · 3.39 KB
/
my-comments.vue
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
<template>
<div id="my-comments">
<div class="member-nav">
<ul class="member-nav-list">
<li class="active">
<a href="./my-comments">My comments</a>
</li>
</ul>
</div>
<empty-member v-if="comments && !comments.data.length">No comments</empty-member>
<template v-else>
<div class="comments-container">
<ul>
<li v-for="comment in comments.data" :key="comment.comment_id" class="comment-item">
<div class="comment-title">
<a :href="'/goods/' + comment.goods_id">{{ comment.goods_name }}</a>
<span>{{ comment.create_time | unixToDate }}</span>
</div>
<div class="comment-body">
<strong>My comments:</strong>
<div>
<p v-html="comment.content.replace(/\n/g, '<br>')"></p>
<div v-if="comment.images && comment.images.length > 0" class="comment-gallery">
<a v-for="(image, index) in comment.images" :key="index" :href="image" target="_blank">
<img :src="image" class="comment-thumbnail">
</a>
</div>
</div>
</div>
<div v-if="comment.reply_status === 1" class="comment-body reply">
<strong>The shopkeeper replies:</strong>
<div>
<p v-html="comment.reply.content.replace(/\n/g, '<br>')"></p>
</div>
</div>
</li>
</ul>
</div>
<div class="member-pagination" v-if="comments">
<el-pagination
@current-change="handleCurrentPageChange"
:current-page.sync="params.page_no"
:page-size="params.page_size"
layout="total, prev, pager, next"
:total="comments.data_total">
</el-pagination>
</div>
</template>
</div>
</template>
<script>
import * as API_Members from '@/api/members'
export default {
name: 'my-comments',
head() {
return {
title: `My comments-${this.site.title}`
}
},
data() {
return {
comments: '',
params: {
page_no: 1,
page_size: 10
}
}
},
mounted() {
this.GET_Comments()
},
methods: {
/** The current page number changed*/
handleCurrentPageChange(page) {
this.params.page_no = page
this.GET_Comments()
},
GET_Comments() {
API_Members.getComments(this.params).then(response => {
this.comments = response
this.MixinScrollToTop()
})
}
}
}
</script>
<style type="text/scss" lang="scss" scoped>
@import "../../assets/styles/color";
.comments-container {
padding-top: 10px;
}
.comment-item {
margin-bottom: 10px;
}
.comment-title {
padding: 5px 0;
border: 1px solid #e7e7e7;
background: #fafafa;
overflow: hidden;
a {
color: $color-href;
margin-left: 10px;
margin-right: 20px;
&:hover { color: $color-main }
}
}
.comment-body {
display: flex;
border: 1px solid #e7e7e7;
overflow: hidden;
padding: 10px;
border-top: none;
&.reply {
color: $color-main;
}
strong {
width: 60px;
flex-shrink: 0;
}
.comment-gallery {
margin-top: 10px;
}
.comment-thumbnail {
width: 100px;
height: 100px;
margin-right: 10px;
}
}
</style>