xuxy
2024-06-24 66a346cb7119e0cc08f108b71d2e7280f132dc4e
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
<template>
    <view class="bussiness-order-detail">
        <view class="name" v-if="type==='travel'&&dto.items&&dto.items.length==1">{{dto.items[0].name || '-'}}</view>
        <view class="name">{{dto.orderNo || dto.tripName || '-'}}</view>
        <view class="price" >{{dto.statusStr=='CLOSED'&&'已关闭' || dto.statusStr ||'已支付'}}<span v-if="type!=='travel'">: <span class="dot">¥
            </span>{{dto.paymentAmount ||'0.0'}}</span></view>
        <view class="price">总金额: <span class="dot">¥ </span>{{dto.totalAmount || dto.price ||'0.0'}}</view>
 
        <view class="time m-t-12">
            下单时间:&nbsp;&nbsp;{{ dto.createdDate || '-'}}
        </view>
        <!--         <view class="time">
            支付时间:&nbsp;&nbsp;{{ dto.paymentTime || '-'}}
        </view> -->
        <view class="info-user info" v-if="type!=='travel'">
            <view class="flex">
                <view class="line"></view>
                <view class="title">下单商品</view>
            </view>
            <view class="flex scroll-canteen m-t-12">
                <scroll-view class="flex scroll-view" :scroll-x="true" style="max-width: 640rpx;" v-if="dto.items">
                    <view class="flex">
                        <view v-for="each of dto.items" class="item-each">
                            <image :src="each.cover" class="cover"></image>
                            <view class="cover-name word-e">{{each.name}}({{each.num || 0}}件)</view>
                        </view>
                    </view>
                </scroll-view>
                <view v-if="!dto.items">
                    暂无
                </view>
            </view>
        </view>
        <view class="info-user info">
            <view class="flex">
                <view class="line"></view>
                <view class="title">用户信息</view>
            </view>
            <view class="user">
                <view class="">
                    姓名:&nbsp;&nbsp;{{dto.nickName || dto.customer ||'暂无'}}
                </view>
                <view class="">
                    手机:&nbsp;&nbsp;{{dto.tel || dto.customerTel ||'暂无'}}
                </view>
                <view class="" v-if="type!=='travel'">
                    地址:&nbsp;&nbsp;{{dto.customerAddress || dto.customerAddress ||'暂无'}}
                </view>
            </view>
        </view>
        <view class="info-wuliu info">
            <view class="flex">
                <view class="line"></view>
                <view class="title">行程详情</view>
                <view class="button-green-text m-l-a m-r-0 " @click="toKbDetail"
                    v-if="type==='good'&&dto.deliveryNo&&dto.deliveryName">
                    查看物流详情
                </view>
            </view>
            <view class="status-list">
                <uni-section v-if="list2.length>0">
                    <uni-steps :options="list2" active-icon="checkbox" active-color="#04BA97" :active="active"
                        direction="column" />
                </uni-section>
                <view v-if="list2.length==0">
                    暂无
                </view>
            </view>
        </view>
 
        <view class="info-user info" v-if="type!=='travel'&&currentInfo.id&&!currentInfo.openId&&dto.status!=='REFUND'&&dto.checkStatus!=='COMPLETED'">
            <view class="flex">
                <view class="line"></view>
                <view class="title">送达凭证</view>
                <view class="button-green-text m-l-a m-r-0" v-if="dto.status!=='COMPLETED'" @click="uploadFile">上传
                </view>
 
            </view>
            <view class="m-t-12">
                <view v-if="uploadFiles&&uploadFiles.length>0" class="flex ">
                    <view v-for="(url) of uploadFiles" class="file-text m-r-10 m-b-5" :key="url">
                        <image :src="url" @click="deletePic(index)"
                            style="width: 180rpx ;height: 180rpx;border: 1px solid #333;"></image>
                    </view>
                </view>
            </view>
 
        </view>
        <view style="min-height: 100rpx;">
 
        </view>
        <view class="button-green" @click="oporder"
            v-if="(type=='travel'&&dto.status=='P' || type!=='travel')&&dto.checkStatus!=='COMPLETED'&&dto.status!=='REFUND'&&currentInfo.id&&!currentInfo.openId"
            style="position: fixed;left: 30rpx;right: 30rpx;bottom: 40rpx;width: auto;">
            {{ type=='travel'&&'扫码核销' 
            || type=='canteen'&&'确认送达' 
            || type=='good'&&'确认送达' 
            || type=='shop'&&'确认送达'  || '-'}}
        </view>
    </view>
</template>
 
<script>
    export default {
        methods: {
            toKbDetail() {
                if (this.dto.deliveryNo && this.dto.deliveryName && this.dto.deliveryNo.trim() && this.dto.deliveryName
                    .trim()) {
                    uni.navigateTo({
                        url: `plugin://kdPlugin/index?num=${this.dto.deliveryNo.trim()}&appName=${this.dto.deliveryName.trim()}`,
                    })
                } else {
                    this.$message.showToast('尚未设置物流信息')
                }
 
            },
            async oporder() {
                if (this.type == 'travel') {
                    await this.$message.confirm('确定核销吗?')
                    //扫二维码确认
                    let that = this
                    uni.scanCode({
                        success: async function(res) {
                            console.log('条码内容:' + res.result);
                            var dto = undefined
                            try {
                                dto = JSON.parse(res.result)
                                if (!!dto['tripId']) {
                                    //请求核销
                                    if (dto['tripId'] !== that.id) {
                                        that.$message.showToast('非此活动二维码')
                                    } else {
 
                                        that.$message.showLoading()
                                        const {
                                            code
                                        } = await that.$http.request('get',
                                            '/api/trip/employee/check/user/trip', {
                                                params: {
                                                    userId: that.userId,
                                                    tripId: that.id,
                                                }
                                            })
                                        that.$message.hideLoading()
                                        if (code == 0) {
                                            that.$message.showToast('核销成功')
                                            that.dto.status = 'G'
                                        }
                                    }
 
                                } else {
                                    that.$message.showToast('二维码格式不正确扫码失败')
                                }
                            } catch (e) {
                                that.$message.showToast('二维码格式不正确扫码失败')
                            }
                        },
                        fail() {
                            that.$message.showToast('扫码失败')
 
                        }
                    });
 
 
 
                } else {
                    //都要凭证:employeeArriveImage
                    if (this.uploadFiles.length == 0) {
                        this.$message.showToast('请至少上传一张送达凭证')
                        return
                    }
                    await this.$message.confirm('确定送达吗?')
 
                    var checkurl = ''
                    if (this.type == 'canteen') {
                        checkurl = '/api/canteen/employee/order/set/arrive'
                    }
                    if (this.type == 'shop') {
                        checkurl = '/api/buy/employee/order/set/arrive'
                    }
                    if (this.type == 'good') {
                        checkurl = '/api/wabao/employee/order/set/arrive'
                    }
                    var dto = {
                        id: this.id,
                        employeeArriveImage: JSON.stringify(this.uploadFiles)
                    }
                    this.$message.showLoading()
                    const {
                        code
                    } = await this.$http.request('post', checkurl, {
                        data: dto
                    })
                    this.$message.hideLoading()
                    if (code == 0) {
                        this.$message.showToast('操作成功')
                        //刷新状态
                        setTimeout(() => {
                            this.getDetail()
                        }, 500)
                    }
 
                }
 
            },
            async deletePic(index) {
                await this.$message.confirm('删除此凭证吗?')
                this.uploadFiles.splice(index, 1)
            },
            async uploadFile() {
                //选择图片or相册
                if (this.uploadFiles.length >= 6) {
                    this.$message.showToast('至多上传6张送达凭证')
                    return
                }
                const that = this
                uni.chooseImage({
                    count: 6, // 最多可以选择的图片张数,默认9
                    sizeType: ['original', 'compressed'], //original 原图,compressed 压缩图,默认二者都有
                    sourceType: ['album',
                        'camera'
                    ], //album 从相册选图,camera 使用相机,默认二者都有。如需直接开相机或直接选相册,请只使用一个选项
                    success: function({
                        errMsg,
                        tempFiles
                    }) {
                        if (errMsg === 'chooseImage:ok') {
                            that.$message.showLoading()
                            for (var file of tempFiles) {
                                that.$http.upload(file.path).then(res => {
                                    var url = res.data && res.data.length > 0 && res.data[0].url
                                    that.uploadFiles.push(url)
                                })
                            }
                            that.$message.hideLoading()
 
                        }
 
                    },
                    error: function() {}
                })
            },
            async getDetail() {
                this.$message.showLoading()
 
                {
                    const {
                        data
                    } = await this.$http.request('get', this.api, {
                        params: {}
                    })
                    this.dto = {
                        ...data
                    }
                }
                if (this.type !== 'travel' || this.dto.orderId) {
                    const {
                        data
                    } = await this.$http.request('get', '/api/order/get/' + (this.type == 'travel' ? this.dto.orderId :
                        this.id), {
                        params: {}
                    })
                    if (data) {
                        this.dto = {
                            ...this.dto,
                            ...data
                        }
                    }
 
                }
                if (this.type !== 'travel') {
                    //设置物流
                    this.list2 = []
                    this.list2.push({
                        title: '买家下单',
                        desc: this.dto.createdDate || '待下单'
                    })
                    if (this.dto.createdDate) {
                        this.active = 1
                    }
                    this.list2.push({
                        title: '买家支付',
                        desc: this.dto.paymentTime || '待支付'
                    })
                    if (this.dto.paymentTime) {
                        this.active = 2
                    }
                    this.list2.push({
                        title: !this.dto.employeeArriveTime && '骑手配送中' || '骑手已核销',
                        desc: this.dto.employeeArriveTime || '-'
                    })
                    if (this.dto.employeeArriveTime) {
                        this.active = 3
                    }
                    
                    if(this.type=='good'){
                        this.list2.push({
                            title: !this.dto.deliverySignTime && '待签收' || '快递送达',
                            desc: this.dto.deliverySignTime || '-'
                        })
                        if (this.dto.deliverySignTime) {
                            this.active = 3
                        }
                        if (this.dto.refundTime) {
                            this.list2.push({
                                title: '退款',
                                desc: this.dto.refundTime || '待退款'
                            })
                            this.active = 4
                        }
                    }else{
                        if (this.dto.refundTime) {
                            this.list2.push({
                                title: '退款',
                                desc: this.dto.refundTime || '待退款'
                            })
                            this.active = 4
                        }
                    }
                    
 
 
                    
 
 
                } else {
                    //出去玩的页面
                    this.list2 = []
                    this.active = 1
                    this.list2.push({
                        title: !(this.dto.createdDate || this.dto.time) && '待下单' || '已下单',
                        desc: this.dto.createdDate || this.dto.time || '-'
                    })
 
                    this.list2.push({
                        title: !this.dto.getOnTime && '待上车' || '已上车',
                        desc: this.dto.getOnTime || '-'
                    })
                    this.list2.push({
                        title: !this.dto.overTime && '活动进行中' || '活动结束',
                        desc: this.dto.overTime || '-'
                    })
                    if (this.dto.getOnTime) {
                        this.active = 2
                    }
                    if (this.dto.overTime) {
                        this.active = 3
                    }
                }
                this.$message.hideLoading()
                console.log('order-detail', this.dto)
 
            }
        },
 
        data() {
            return {
                tabs: [{
                        name: '团购',
                        id: 'shop',
                        api: '/api/buy/employee/order/get/',
                        // apiuser:'/api/buy/customer/group/get/'
                    },
                    {
                        name: '粗去玩',
                        id: 'travel',
                        api: '/api/trip/employee/get/user/check?id='
                        // api: '/api/order/get/'
                    },
                    {
                        name: '每日维C',
                        id: 'canteen',
                        api: '/api/canteen/employee/order/get/'
 
                    },
                    {
                        name: '挖宝商品',
                        id: 'good',
                        api: '/api/wabao/employee/order/get/'
 
                    },
                ],
                api: '',
                type: '',
                userId: '',
                id: '',
                dto: {
 
                },
                order: {
 
                },
                active: 0,
                list2: [],
                uploadFiles: [],
            }
        },
        onLoad(options) {
            this.type = options.type || ''
            this.id = options.id || ''
            this.userId = options.userId || ''
            for (var item of this.tabs) {
                if (item.id == this.type) {
                    //出去玩比较特殊处理一下,是针对活动里的某个人,而非整体,其他都是整体
                    if(this.currentInfo.id&&!this.currentInfo.openId){
                        //商家
                        if (this.type == 'travel') {
                            // this.api += '&userId=' + this.userId
                            this.api = item.api + this.userId
                        } else {
                            // if(this.currentInfo.id&&!this.currentInfo.openId){
                            //     //普通用户
                            //     if(item.apiuser){
                            //         this.api = item.apiuser + this.id
                            //     }else{
                            //         this.api = item.api + this.id
                                    
                            //     }
                            // }else{
                            this.api = item.api + this.id
                            // }
                        }
                    }else{
                        //学生
                        this.api = '/api/order/get/' + this.id
                    }
                    
                    break
                }
            }
            this.getDetail()
 
 
        },
 
 
    }
</script>
 
<style lang="scss" scoped>
    @import './bussiness-order-detail.scss'
</style>