shopcomment.vue
4.9 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
<template>
<view class="container">
<view class="goodcomment">
<view class="goodcommentop flexone">
<view class="topitem " :class="star_type==0?'topitemactive':''" @click="commenttype" :data-id="0">全部({{total}})</view>
<view class="topitem" :class="star_type==1?'topitemactive':''" @click="commenttype" :data-id="1">好评({{total1}})</view>
<view class="topitem" :class="star_type==2?'topitemactive':''" @click="commenttype" :data-id="2">中评({{total2}})</view>
<view class="topitem" :class="star_type==3?'topitemactive':''" @click="commenttype" :data-id="3">差评({{total3}})</view>
</view>
<view class="nodata" v-if="commentlist.length==0">暂无评论</view>
<view v-else>
<view class="commentlist">
<view class="jianintro photobox" bindtap="comdetail" v-for="(item,index) in commentlist" :key="index">
<view class="comtop flextwo">
<view class="comleft">
<image :src="item.user.avatar"></image>
</view>
<view class="comright">
<view class="comrtop">
<view class="usertop flextwo">
<view class="comrname">{{item.user.nickname}}</view>
<view class="comdate">{{item.createtime}}</view>
</view>
<view class="star starone flexone">
<view class="staritem">
<image src="../../static/starredk.png" v-if="item.star>=1"></image>
<image src="../../static/starred.png" v-else></image>
</view>
<view class="staritem">
<image src="../../static/starredk.png" v-if="item.star>=2"></image>
<image src="../../static/starred.png" v-else></image>
</view>
<view class="staritem">
<image src="../../static/starredk.png" v-if="item.star>=3"></image>
<image src="../../static/starred.png" v-else></image>
</view>
<view class="staritem">
<image src="../../static/starredk.png" v-if="item.star>=4"></image>
<image src="../../static/starred.png" v-else></image>
</view>
<view class="staritem">
<image src="../../static/starredk.png" v-if="item.star>=5"></image>
<image src="../../static/starred.png" v-else></image>
</view>
</view>
</view>
</view>
</view>
<view>
<view class="commenttext">
{{item.content}}
</view>
<view class="commentimg flexone" v-if="item.images.length!=0">
<view class="commentimgitem" v-for="(itemk,indexk) in item.images" :key="indexk" @click="previewimg(index,indexk)">
<image :src="itemk" mode=""></image>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import app from "../../App.vue";
export default {
data() {
return {
commentlist: [],
total: 0,
total1: 0,
total2: 0,
total3: 0,
store_id: '',
star_type: 0,
page: 1,
}
},
onLoad(options) {
this.store_id=options.store_id;
this.getcommentlist()
},
methods: {
// 评论切换
commenttype(e) {
this.star_type = e.currentTarget.dataset.id;
this.page = 1;
this.commentlist = [];
this.getcommentlist()
},
// 获取评论列表
getcommentlist() {
let that = this;
var url = 'goods_comments/store_goods_comments';
var params = {
store_id: that.store_id,
star_type: that.star_type,
page: that.page,
pageNum: 10
}
console.log('33478478', params)
app.post(url, params).then((res) => {
console.log('获取评论列表', res);
that.commentlist = that.commentlist.concat(res.data.data.list);
that.total = res.data.data.total;
that.total1 = res.data.data.total1;
that.total2 = res.data.data.total2;
that.total3 = res.data.data.total3;
}).catch((err) => {
console.log(err)
})
},
// 预览图片
previewimg(index, indexk) {
let that = this;
console.log(that.commentlist[index].images[indexk])
uni.previewImage({
current: that.commentlist[index].images[indexk],
urls: that.commentlist[index].images,
success: function(res) {},
fail: function(res) {},
complete: function(res) {},
})
},
}
}
</script>
<style>
@import url('../../base/nearshop');
@import url('../../base/homepage');
.tapnavactive::after {
bottom: -32rpx;
}
.goodetailbox {
color: #3D454C;
font-size: 24rpx;
padding: 20rpx;
box-sizing: border-box;
}
.huiyuanprice {
margin-left: 28rpx
}
.tapnav {
padding: 32rpx 126rpx;
box-sizing: border-box;
}
.miaoduleft {
width: 260rpx !important;
}
.miaotiao {
position: relative;
}
.qiang {
width: 200rpx;
display: block;
position: absolute;
left: 0rpx;
top: 0;
text-align: left;
padding-left: 10rpx;
box-sizing: border-box;
}
.topitemactive {
border: 1rpx solid #C29445;
color: #C29445;
}
</style>