shopEvaluate.vue
8.8 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
<template>
<view class="page">
<view class="item" v-for="(item,index) in orderinfo" :key="index">
<view class="infobox">
<image :src="item.image" mode="widthFix" class="left"></image>
<view class="info">
<view class="word">{{item.goods_name}}</view>
<view class="score">
商品评分:
<view class="num">
<!-- :data-item="item" :data-index="index" -->
<view @click="selstar" :data-id="1" :data-index="index">
<image src="../../static/star.png" mode="widthFix" class="star" v-if="item.star>=1"></image>
<image src="../../static/nostar.png" mode="widthFix" class="star" image v-else>
</view>
<view @click="selstar" :data-id="2" :data-index="index">
<image src="../../static/star.png" mode="widthFix" class="star" v-if="item.star>=2"></image>
<image src="../../static/nostar.png" mode="widthFix" class="star" image v-else>
</view>
<view @click="selstar" :data-id="3" :data-index="index">
<image src="../../static/star.png" mode="widthFix" class="star" v-if="item.star>=3"></image>
<image src="../../static/nostar.png" mode="widthFix" class="star" image v-else>
</view>
<view @click="selstar" :data-id="4" :data-index="index">
<image src="../../static/star.png" mode="widthFix" class="star" v-if="item.star>=4"></image>
<image src="../../static/nostar.png" mode="widthFix" class="star" image v-else>
</view>
<view @click="selstar" :data-id="5" :data-index="index">
<image src="../../static/star.png" mode="widthFix" class="star" v-if="item.star>=5"></image>
<image src="../../static/nostar.png" mode="widthFix" class="star" image v-else>
</view>
</view>
</view>
</view>
</view>
<textarea name="" id="" cols="30" rows="10" class="fill" placeholder="请填写评价内容…" @input="entercomment" :data-index="index"></textarea>
<view class="flexone">
<view class="imgarr" v-for="(item,indexk) in item.images" :key="indexk" >
<image :src="item" mode="widthFix" class="imagItem"></image>
<view class="delimg" @click="delimg(index,indexk)">
<image src="../../static/publishchahao.png" mode=""></image>
</view>
</view>
<view class="imgarr" @click="chooseImage(index)">
<image src="../../static/add.png" mode="widthFix" class="imagItem"></image>
</view>
</view>
</view>
<!--
<view class="item">
<view class="infobox">
<image src="../../static/cai.png" mode="widthFix" class="left"></image>
<view class="info">
<view class="word">商品名称名称名称商品名称名称名称商品名称名称名称名称</view>
<view class="score">
商品评分:
<view class="num">
<image src="../../static/star.png" mode="widthFix" class="star"></image>
<image src="../../static/star.png" mode="widthFix" class="star"></image>
<image src="../../static/star.png" mode="widthFix" class="star"></image>
<image src="../../static/star.png" mode="widthFix" class="star"></image>
<image src="../../static/nostar.png" mode="widthFix" class="star" style="margin-right: 0;"></image>
</view>
</view>
</view>
</view>
<textarea name="" id="" cols="30" rows="10" class="fill" placeholder="请填写评价内容….."></textarea>
<view class="imgarr">
<image src="../../static/add.png" mode="widthFix" class="imagItem"></image>
</view>
</view>
-->
<view class="btnbox">
<view class="submit" @click="subevalute">发表评价</view>
</view>
</view>
</template>
<script>
import app from "../../App.vue";
export default {
data() {
return {
order_detail_id:'',
orderinfo:'',
data:[]
};
},
onLoad(options) {
console.log(344834838)
this.order_detail_id=options.order_detail_id;
console.log(this.order_detail_id)
this.getordercomment();
},
methods: {
// 获取订单详情
getordercomment(){
let that = this;
var url = 'order/comments';
var params = {
order_detail_id:that.order_detail_id
}
console.log(params)
app.post(url, params, "post").then((res) => {
console.log(res);
that.orderinfo=res.data.data.order_info;
that.orderinfo.forEach(function(value,index,array){
value.star=0;
value.images=[];
})
that.orderinfo=that.orderinfo;
that.orderinfo.forEach(function(value,index,array){
let obj={};
obj.goods_id=value.goods_id;
obj.images=[];
that.data.push(obj)
})
that.data=that.data;
}).catch((err) => {
console.log(err)
})
},
// 选择星星
selstar(e){
let that=this;
console.log(e)
let id=e.currentTarget.dataset.id;
let index=e.currentTarget.dataset.index;
that.orderinfo[index].star=id;
that.$forceUpdate();
that.orderinfo=that.orderinfo;
that.data[index].star=id;
that.data=that.data;
},
chooseImage(index){
console.log(index)
let that = this;
let indexone=index
console.log('99999',index)
uni.chooseImage({
count: 9,
sizeType: ['original', 'compressed'],
success: function (res) {
console.log(res)
console.log(res.tempFilePaths);
console.log(res.tempFilePaths[0]);
res.tempFilePaths.forEach(function(value,index,array){
app.upload('image', value, "post").then((res) => {
console.log('上传文件', res);
let url = app.globalData.imgurl+res.url;
// newimage.push(url);
// console.log(newimage)
that.data[indexone].images.push(url);
that.data=that.data;
console.log('273734734743',indexone)
that.orderinfo[indexone].images.push(url);
that.orderin=that.orderinfo;
console.log(that.orderinfo)
that.$forceUpdate();
console.log(that.orderinfo[indexone].images)
}).catch((err) => {
console.log(err)
})
})
},
fail: function (res) { }
})
},
// 删除图片
delimg(index,indexk){
let that=this;
console.log(index,indexk);
that.orderinfo[index].images.splice(indexk,1);
that.orderinfo=that.orderinfo;
that.$forceUpdate();
console.log(that.orderinfo)
},
// 写评论
entercomment(e){
console.log(e.detail.value);
let index=e.currentTarget.dataset.index;
console.log(index)
that.data[index].content=e.detail.value;
// that.data[index].content=e.detail.value
},
// 提交评论
subevalute(){
let that = this;
var url = 'order/comments';
console.log('获取的参数', that.seldata)
var params = {
data:JSON.stringify(that.data),
order_detail_id:that.order_detail_id
}
console.log(params)
app.post(url, params, "post").then((res) => {
console.log(res);
uni.showToast({
title:"评论成功",
icon:'none'
})
setTimeout(function(){
uni.navigateBack({
checked:true
})
},1500)
}).catch((err) => {
console.log(err)
})
}
}
};
</script>
<style>
.item {
padding: 32rpx;
border-bottom: 16rpx solid #F7F7F7;
box-sizing: border-box;
background: #fff;
margin-bottom: 16rpx;
overflow: hidden;
}
.infobox {
display: flex;
align-items: center;
justify-content: space-between;
}
.left {
width: 140rpx;
}
.info {
width: 530rpx;
}
.word {
font-size: 30rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: rgba(61, 69, 76, 1);
line-height: 40rpx;
}
.score {
margin-top: 22rpx;
display: flex;
align-items: center;
font-size: 28rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: rgba(61, 68, 76, 1);
}
.num {
display: flex;
align-items: center;
}
.star {
width: 32rpx;
margin-right: 24rpx;
}
.fill {
width: 686rpx;
height: 192rpx;
padding: 24rpx;
box-sizing: border-box;
background: rgba(247, 247, 247, 1);
border-radius: 16rpx;
font-size: 28rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: rgba(189, 196, 206, 1);
line-height: 42rpx;
margin-top: 66rpx;
}
.imgarr {
padding: 32rpx 0;
box-sizing: border-box;
position: relative;
}
.delimg{
width:40rpx;
height:40rpx;
font-size: 0;
position: absolute;
right:-10rpx;
top:0rpx;
}
.imagItem {
width: 160rpx;
margin-right: 16rpx;
}
.btnbox {
padding: 14rpx 32rpx;
box-sizing: border-box;
background: #fff;
}
.submit {
width: 686rpx;
height: 88rpx;
background: rgba(194, 148, 69, 1);
border-radius: 16rpx;
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: rgba(255, 255, 255, 1);
display: flex;
align-items: center;
justify-content: center;
}
</style>