index.vue
9.75 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
<template>
<view class="content-container">
<z-paging ref="paging" :fixed="false" v-model="dataList" @query="queryList">
<empty-view slot:empty></empty-view>
<view class="page-box">
<view class="order" v-for="(item, index) in dataList" :key="index">
<view class="top">
<view class="left">
<u-icon name="home" :size="30" color="rgb(94,94,94)"></u-icon>
<view class="store">{{ item.garOrderCompanyName }}</view>
<u-icon name="arrow-right" color="rgb(203,203,203)" :size="26"></u-icon>
</view>
<view style="display: flex;align-items: center;">
<view v-if="item.garOrderHandlerStatus === 0 && item.garCancelFlag === 0" class="right">待清运 </view>
<view v-if="item.garCancelFlag === 1" class="right">已取消 </view>
<view v-if="item.garOrderHandlerStatus === 1 && item.garCancelFlag === 0" class="right">清运中 </view>
</view>
<view v-if="item.garEvaluateFlag === 0 && userType === '用户'" class="right">待评价
</view>
<view v-if="item.garTimeOutFlag === 1" class="right" style="color: red;">超时取消
</view>
<view v-if="item.garHandlerEvaluateFlag === 0 && userType === '运输企业负责人'" class="right">待评价
</view>
<view v-if="item.garEvaluateFlag === 1 && userType === '用户'" class="right">已评价
</view>
<view v-if="item.garHandlerEvaluateFlag === 1 && userType === '运输企业负责人'" class="right">已评价
</view>
</view>
<view class="item" @click="handleClick(item.garOrderId)">
<view class="content">
<view class="title u-line-2">{{ item.garOrderAddress + item.garOrderAddressDetails }}</view>
<view class="type">垃圾类型: {{ item.garOrderTrashType }}</view>
<view class="delivery-time">预约时间 {{ item.garOrderAgreementTime }}</view>
</view>
</view>
<view class="bottom" v-if="item.garOrderHandlerStatus === 0 && item.garCancelFlag === 0">
<view class="more">
<!-- <u-icon name="more-dot-fill" color="rgb(203,203,203)"></u-icon> -->
</view>
<view hover-class="btn-hover" class="logistics btn" @click="handleCancelOrder(item.garOrderId)">取消订单</view>
</view>
<!-- 用户对公司评价 -->
<view class="bottom"
v-if="item.garEvaluateFlag === 0 && item.garOrderHandlerStatus === 3 && userType === '用户'">
<view class="more">
<!-- <u-icon name="more-dot-fill" color="rgb(203,203,203)"></u-icon> -->
</view>
<view hover-class="btn-hover" class="logistics btn" @click="handleUserEvaluate(item.garOrderId, userType)">
去评价
</view>
</view>
<!-- 公司对用户评价 -->
<view class="bottom"
v-if="item.garHandlerEvaluateFlag === 0 && item.garOrderHandlerStatus === 3 && userType === '运输企业负责人' && item.haveEvaluateOfClient==1">
<view class="more">
<!-- <u-icon name="more-dot-fill" color="rgb(203,203,203)"></u-icon> -->
</view>
<view hover-class="btn-hover" class="logistics btn" @click="handleUserEvaluate(item.garOrderId, userType)">
查看评价
</view>
</view>
</view>
</view>
</z-paging>
<u-action-sheet :closeOnClickOverlay="true" :closeOnClickAction="false" @actionSheetClose="handleClose"
@submitFunction="submitFunction" @select="selectClick" :actions="list" round="15" title="取消订单" :show="cancelShow">
</u-action-sheet>
</view>
</template>
<script setup>
import { queryOrderList, updateOrder } from "@/apis/order.js";
import { useMainStore } from '@/stores/index.js';
import { onLoad } from "@dcloudio/uni-app";
import { computed, ref } from 'vue';
const store = useMainStore();
const userType = computed(() => store.userType)
const currentCancelOrderId = ref("");
const currentCancelName = ref("");
const cancelShow = ref(false);
const type = ref(0);
const evaluateFlag = ref();
const list = computed(() => {
let reason = [
{
name: '订单信息填写有误',
},
{
name: '线下协商有问题',
},
{
name: '不需要清运了',
},
{
name: '其他',
},
{
name: '提交',
}
]
if (userType.value === '用户') {
reason.unshift({
name: '长时间无人接单',
})
}
return reason
})
const dataList = ref([]);
const paging = ref(null);
const firstLoaded = ref(false)
/**
* 取消订单
* @param {string} orderId
*/
const handleCancelOrder = (orderId) => {
currentCancelOrderId.value = orderId
cancelShow.value = true
}
const handleClose = (e) => {
cancelShow.value = false
}
/**
* 跳转公司详情
* @param {*} val
*/
const goDetail = (val) => {
uni.$u.route({
url: `pages/home-info/clean/company-detail/index?companyId=${val.garOrderCompanyId}`,
})
}
const selectClick = (index) => {
currentCancelName.value = index.name;
}
/**
* 提交取消订单
*/
const submitFunction = (otherReason) => {
let reason = otherReason
if (currentCancelName.value != "其他") {
reason = currentCancelName.value
}
if (!reason) {
uni.$u.toast("请提供取消订单的原因")
return
}
let params = {
garOrderId: currentCancelOrderId.value,
garCancelFlag: 1,
garReason: reason
}
updateOrder(params).then(res => {
if (res.data.success) {
cancelShow.value = false
uni.$u.toast("取消成功")
paging.value.reload();
}
})
}
const handleClick = (orderId) => {
uni.$u.route({
url: `pages/order-info/order-other/detail/index`,
params: {
orderId: orderId
}
})
}
/**
* 订单评价
* @param {*} orderId
*/
const handleUserEvaluate = (orderId, userType) => {
uni.$u.route(`pages/order-info/order-other/evaluate/index?orderId=${orderId}&userType=${userType}`)
}
// list集合
const queryList = (pageNo, pageSize) => {
//这里的pageNo和pageSize会自动计算好,直接传给服务器即可
//这里的请求只是演示,请替换成自己的项目的网络请求,并在网络请求回调中通过paging.value.complete(请求回来的数组)将请求结果传给z-paging
// request.queryList({ pageNo, pageSize }).then(res => {
// //请勿在网络请求回调中给dataList赋值!!只需要调用complete就可以了
queryOrderList({ type: type.value, evaluateFlag: evaluateFlag.value, pageNo, pageSize }).then((res) => {
paging.value.complete(res.data.data.list);
firstLoaded.value = true
}).catch(res => {
//如果请求失败写paging.value.complete(false),会自动展示错误页面
//注意,每次都需要在catch中写这句话很麻烦,z-paging提供了方案可以全局统一处理
//在底层的网络请求抛出异常时,写uni.$emit('z-paging-error-emit');即可
paging.value.complete(false);
})
}
onLoad((options) => {
type.value = options.type;
uni.setNavigationBarTitle({
title: options.title
})
if (options.evaluateFlag) {
evaluateFlag.value = options.evaluateFlag;
}
})
</script>
<style lang="scss" scoped>
.content-container {
height: 100%;
width: 100%;
.order {
width: 90%;
background-color: #ffffff;
margin: 20rpx auto;
border-radius: 20rpx;
box-sizing: border-box;
padding: 20rpx;
font-size: 28rpx;
&:active {
background-color: #f3f4f6;
opacity: 0.8;
transition: opacity 0.3s;
-webkit-transition: opacity 0.3s;
-moz-transition: opacity 0.3s;
-ms-transition: opacity 0.3s;
}
.top {
display: flex;
justify-content: space-between;
.left {
display: flex;
align-items: center;
.store {
margin: 0 10rpx;
font-size: 32rpx;
font-weight: bold;
}
}
}
.item {
display: flex;
align-items: center;
margin: 20rpx 0 0;
.left {
margin-right: 20rpx;
image {
width: 160rpx;
height: 160rpx;
border-radius: 10rpx;
}
}
.content {
.title {
font-size: 28rpx;
line-height: 50rpx;
}
.type {
margin: 10rpx 0;
font-size: 24rpx;
color: $u-tips-color;
}
.delivery-time {
color: #e5d001;
font-size: 24rpx;
}
}
}
.total {
margin-top: 20rpx;
text-align: right;
font-size: 24rpx;
.total-price {
font-size: 32rpx;
}
}
.bottom {
display: flex;
margin-top: 20rpx;
padding: 0 10rpx;
justify-content: space-between;
align-items: center;
.btn {
line-height: 52rpx;
width: 160rpx;
border-radius: 26rpx;
border: 2rpx solid $u-border-color;
font-size: 26rpx;
text-align: center;
color: $u-info-dark;
}
.btn--hover {
background-color: $u-success-light;
}
.evaluate {
color: $u-warning-dark;
border-color: $u-warning-dark;
}
}
}
.centre {
text-align: center;
margin: 200rpx auto;
font-size: 32rpx;
image {
width: 164rpx;
height: 164rpx;
border-radius: 50%;
margin-bottom: 20rpx;
}
.tips {
font-size: 24rpx;
color: #999999;
margin-top: 20rpx;
}
.btn {
margin: 80rpx auto;
width: 200rpx;
border-radius: 32rpx;
line-height: 64rpx;
color: #ffffff;
font-size: 26rpx;
background: linear-gradient(270deg, rgba(249, 116, 90, 1) 0%, rgba(255, 158, 1, 1) 100%);
}
}
}
</style>