11
xuxy
2024-06-26 6dafb32ab46ff04e1131dfd52abd6067aeda0da0
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
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
<template>
    <view class="bussiness-order">
        <!-- 团购、粗去玩、深夜食堂、挖宝商品 -->
        <!--         <view style="position: fixed;left: 0;right: 0;top: 0;background-color: #fff;height: 84rpx;z-index: 999;">
        
        </view>
        <view style="height: 100rpx;"></view> -->
        <top-tabs :tabs="statusList" :flg.sync="tabIndex" @change="changeTab"></top-tabs>
 
        <!-- 根据tab不同显示不同信息 -->
        <view class="bussiness-order-items" style="min-height: calc(100vh - 200rpx);">
            
            <no-data v-if="!list||list.length==0" style="width: 100%;"></no-data>
            <view class="order-item" v-for="(item,index) of list" :key="index" :class="[type||'']" @click="op(item)">
                <view class="name">{{item.title||item.name || item.orderNo || '-'}}</view>
                <view class="time" v-if="type=='travel'">{{item.startTimeStr}} 到 {{item.endTimeStr}}</view>
                <view class="time" v-if="type!=='travel'">下单时间: {{item.createdDate}}</view>
                <view class="flex scroll-canteen" v-if="type=='canteen'">
                    <scroll-view class="flex scroll-view" :scroll-x="true" style="max-width: 500rpx;" v-if="item.items">
                        <view class="flex">
                            <view v-for="each of item.items" class="item-each">
                                <image :src="each.cover" class="cover"></image>
                                <view class="cover-name word-e">
                                <!-- {{each.num}} -->
                                <!-- <spanstyle="font-weight: 600;color: #000;">&nbsp;&nbsp;x&nbsp;&nbsp;</span> -->
                                {{each.name}}({{each.num || 0}}件)</view>
                            </view>
                        </view>
                    </scroll-view>
                    <view style="min-width: 100rpx;margin-left: auto;">
                        <view class="price"><span class="dot">¥</span>{{item.totalAmount ||'0.0'}}
                        </view>
                        <view class="num-tip">共{{getItemsNum(item.items)||0}}件</view>
                    </view>
                </view>
 
 
                <view class="v-line"></view>
                <view class="flex peoples" v-if="type=='travel'">
                    <view class="flex">
                        <view class="icons">
                            <view class="flex">
                                <view class="total">总计: ¥ </view>
                                <view class="price">{{item.price||'0.0'}}</view>
                            </view>
                            <view class="desc">
                                {{item.currentNum||0}}人上车
                            </view>
                        </view>
 
                    </view>
                    <view class="card-list-item-button-green">
                        详情
                    </view>
                </view>
 
                <!-- 具体的一些信息 -->
                <view class="infos" v-if="type!=='travel'">
                    <view class="flex">
                        <view class="info-user-name flex flex1">
                            <uni-icons type="person-filled" class="icon"></uni-icons>
                            {{item.customer}}
                        </view>
                        <view class="info-user-tel flex flex1">
                            <uni-icons type="phone-filled" class="icon"></uni-icons>
                            {{item.customerTel}}
                        </view>
                    </view>
                    <view class="info-user-address flex">
                        <uni-icons type="location-filled" class="icon"></uni-icons>
                        {{item.customerAddress}}
                    </view>
 
                </view>
            </view>
        </view>
        <!-- 根据不同加载不同的继续的底部 -->
        <view v-if="false">
            <view v-if="type=='shop'" class="order-container">
                <card-list-item :type="type" :dto="item" v-for="(item,index) in list" :key="index"></card-list-item>
            </view>
            <view v-if="type=='travel'" class="order-container">
                <card-list-item :type="type" :dto="item" v-for="(item,index) in list" :key="index"></card-list-item>
            </view>
            <view v-if="type=='canteen'" class="order-container">
                <!-- 时间,状态 -->
                <view class="order-item good-item" v-for="(item,index) in list" :key="index">
                    <view class="flex ">
                        <view class="time">下单: {{item.createdDate}}</view>
                        <view class="status">{{item.statusStr}}</view>
                    </view>
 
                    <view class="flex">
                        <!-- overfi -->
                        <scroll-view class="flex scroll-view" :scroll-x="true" v-if="item.items">
                            <view v-for="each of item.items" class="item-each">
                                <image :src="each.cover" class="cover"></image>
                                <!-- 文字缩写 -->
                                <view class="cover-name word-e">{{each.name}}</view>
                            </view>
                        </scroll-view>
                        <view style="min-width: 100rpx;margin-left: auto;">
                            <view class="price"><span class="dot">¥</span>{{item.paymentAmount||'0.0'}}</view>
                            <view class="num-tip">共{{item.items&&item.items.length||0}}件</view>
                        </view>
                    </view>
                    <view class="address">
                        {{item.customerAddress}}
                    </view>
                </view>
                <!-- 货物单 -->
                <!-- 地址 -->
            </view>
            <view v-if="type=='good'" class="order-container">
                <view class="order-item good-item" v-for="(item,index) in list" :key="index">
                    <view class="flex ">
                        <view class="time">下单: {{item.createdDate}}</view>
                        <view class="status">{{item.statusStr}}</view>
                    </view>
                    <view class="flex">
                        <image class="cover" :src="item.items[0].cover"></image>
                        <view>
                            <view class="name">{{item.items[0].name}}</view>
                            <!-- <view>介绍尺码</view> -->
                            <view class="price"><span class="dot">¥</span>{{item.paymentAmount||'0.0'}}</view>
                        </view>
                    </view>
                    <!--         <view class="buttons">
                        <view class="button-wuliu button">查看物流</view>
                        <view class="button-shouhuo button">确认收货地址</view>
                    </view> -->
                </view>
            </view>
        </view>
 
        <footer-msg :more="page.total>0&&page.total>page.current*page.size"></footer-msg>
 
 
        <uni-popup ref="popup_travel_people" type="bottom">
            <view class="popup-form">
                <!-- 背景图片 -->
                <view class="p10 close-parent">
                    <!-- 报名用户 -->
                    <top-tabs :tabs="tripOrderStatusList" :flg.sync="peopleStatusIndex" @change="refreshPeople"></top-tabs>
 
                    <uni-icons class="close" type="closeempty" @click="closeMorePeople"></uni-icons>
                </view>
                <view class="title">
                    已有{{tripUserList&&tripUserList.length || 0}}人报名
                </view>
                <view class="title" @click.stop="toScan({})" style="color: #e1000e;text-align: center;margin-top: 40rpx;margin-bottom: 40rpx;">
                    点击扫码核销
                </view>
                <view style="min-height: 400rpx;max-height: 900rpx;overflow-y: scroll;">
                    <view v-if="tripUserList">
                        <view :key="index" v-for="(people,index) of tripUserList" class="p10 flex">
                            <view class="people-name m-l-0 m-r-10">{{index+1}}.</view>
                            <image :src="people.cover||people.picture" class="people-img"></image>
                            <view class="people-name">{{people.nickName}}</view>
<!-- 
                            <view class="button-red-tmp m-l-a" v-if="people.status=='P'" @click="toScan(people)">
                                扫码核销
                            </view> -->
                            <view class="button-green-tmp m-l-a" @click="toDetail(people)">
                                详情
                            </view>
                        </view>
                    </view>
 
                </view>
 
                <image src="../../../static/imgs/travel/chuqu.png" class="bottom-img"></image>
                <view class="bottom-info">——出去,一起更好玩——</view>
            </view>
        </uni-popup>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                type: '',
                typename: '',
                tabIndex: 0,
                query: {
                    checkStatus: '',
                },
                dstatusList: [{
                    id: '',
                    name: '全部'
                }, {
                    id: 'PENDING',
                    name: '未送达',
                }, {
                    id: 'COMPLETED',
                    name: '已送达',
                }],
                tripOrderStatusList: [{
                    id: '',
                    name: '全部'
                }, {
                    id: 'P',
                    name: '未上车',
                }, {
                    id: 'G',
                    name: '已上车',
                }, {
                    id: 'O',
                    name: '已结束',
                }],
                // dstatusList: [{
                //     id: '',
                //     name: '全部'
                // },{
                //     id: 'PREPAYMENT',
                //     name: '已支付',
                // }, {
                //     id: 'REFUND',
                //     name: '已退款',
                // }, {
                //     id: 'COMPLETED',
                //     name: '已完成',
                // }],
                // dstatusList: [{
                //     id: '',
                //     name: '全部'
                // }, {
                //     id: 'P',
                //     name: '未上车',
                // }, {
                //     id: 'COMPLETED',
                //     name: '已上车',
                // }],
                statusList: [],
                tabs: [{
                        name: '团购',
                        id: 'shop',
                        api: '/api/buy/employee/order/list'
                    },
                    {
                        name: '粗去玩',
                        id: 'travel',
                        api: '/api/trip/employee/list/mine',
                        status: [],
                        // status: [{
                        //     id: '',
                        //     name: '全部'
                        // }, {
                        //     id: 'PENDING',
                        //     name: '未核销',
                        // }, {
                        //     id: 'COMPLETED',
                        //     name: '已核销',
                        // }]
                        // status: [{
                        //     id: '',
                        //     name: '全部'
                        // }, {
                        //     id: 'P',
                        //     name: '未上车',
                        // }, {
                        //     id: 'G',
                        //     name: '已上车',
                        // }, {
                        //     id: 'O',
                        //     name: '已结束',
                        // }]
                    },
                    {
                        name: '每日维C',
                        id: 'canteen',
                        api: '/api/canteen/employee/order/list',
                        // status: [{
                        //     id: '',
                        //     name: '全部'
                        // }, {
                        //     id: 'PENDING',
                        //     name: '未送达',
                        // }, {
                        //     id: 'COMPLETED',
                        //     name: '已送达',
                        // }]
 
                    },
                    {
                        name: '挖宝商品',
                        id: 'good',
                        api: '/api/wabao/employee/order/list'
 
                    },
                ],
                tripUserList: [],
                curTripId: '',
                peopleStatusIndex: 0,
            }
        },
        onLoad(options) {
            this.type = options.type || ''
            // var index = -1
            this.statusList = this.dstatusList
            for (var item of this.tabs) {
                // index++
                if (item.id == this.type) {
                    // this.tabIndex = index
                    this.listApi = item.api
                    this.typename = item.name
                    if (item.status) {
                        this.statusList = item.status
                    }
                    uni.setNavigationBarTitle({
                        title: this.typename || ''
                    })
                    break
                }
            }
            this.refresh()
 
 
        },
        onReachBottom() {
            this.page.current += 1
            this.getMore()
        },
        methods: {
            getItemsNum(arr) {
                var a = 0
                if (arr) {
                    for (var item of arr) {
                        a += item.num || 0
                    }
                }
 
                return a
            },
            openMorePeople() {
                this.$refs.popup_travel_people.open()
 
            },
            closeMorePeople() {
                this.$refs.popup_travel_people.close()
            },
            toTravelDetail(row){
                this.toDetail(row)
            },
            op(row) {
                if (this.type == 'travel') {
                    this.showPeoples(row)
                     // if (this.type == 'canteen')
                } else {
                    //去详情
                    this.toDetail(row)
                }
            },
            async showPeoples(row) {
                //展示用户列表,然后选择一个看详情
                // this.tripUserList = row.
 
                this.peopleStatusIndex = 0
                this.curTripId = row.id
                await this.initShowPeople('')
                this.openMorePeople()
 
            },
            async refreshPeople(e) {
                // console.log('refreshPeople',e)
                this.peopleStatusIndex = e
                var status = this.tripOrderStatusList[e].id
                await this.initShowPeople(status)
            },
            async initShowPeople(status) {
                this.$message.showLoading()
                const {
                    data
                } = await this.$http.request('get', '/api/trip/employee/list/user/check', {
                    params: {
                        tripId: this.curTripId,
                        size: 2000,
                        status: status
                    }
                })
                this.$message.hideLoading()
                this.tripUserList = data.records || []
            },
            toDetail(row) {
                var url = `/pages/order/bussiness-order/bussincess-order-detail?type=${this.type}`
                if (this.type == 'travel') {
                    url += `&id=${row.tripId}&userId=${row.id}`
                } else {
                    url += `&id=${row.orderId || row.id}`
                }
                // console.log('url',url,row)
                uni.navigateTo({
                    url: url
                })
            },
            toScan(row={}) {
                // toScan
                let that = this
                uni.scanCode({
                    success: function(res) {
                        // console.log('条码类型:' + res.scanType);
                        console.log('条码内容:' + res.result);
                        var dto = undefined
                        try {
                            dto = JSON.parse(res.result)
                            if (!!dto['tripId']) {
                                //请求核销
                                if(!dto['userId']){
                                    that.$message.showToast('用户不存在')
                                }else{
                                    if (dto['tripId'] !== that.curTripId) {
                                        that.$message.showToast('非此活动二维码')
                                    } else {
                                        that.checkTrip(dto['tripId'], dto['userId'])
                                    }
                                }
 
                            } else {
                                that.$message.showToast('二维码格式不正确扫码失败')
                            }
                        } catch (e) {
                            that.$message.showToast('二维码格式不正确扫码失败')
                        }
                    },
                    fail() {
                        that.$message.showToast('扫码失败')
 
                    }
                });
            },
            async checkTrip(tripId, userId) {
                //核销
                await this.$message.confirm('确定核销吗?')
                this.$message.showLoading()
 
                const {
                    code
                } = await this.$http.request('get', '/api/trip/employee/check/user/trip', {
                    params: {
                        userId: userId,
                        tripId: tripId,
                    }
                })
                this.$message.hideLoading()
                if (code == 0) {
                    this.$message.showToast('核销成功')
                    this.refreshPeople(this.peopleStatusIndex)
                }
            },
            refresh() {
                //获取
                console.log('refresh')
                this.page.current = 1
                this.getList()
            },
            changeTab(e) {
                this.query.checkStatus = this.statusList[e].id
                // console.log('this.type', this.type, this.tabs, e)
 
                // this.list = []
                // for (var item of this.statusList) {
                //     if (item.id == this.type) {
                //         this.listApi = item.api
                //         break
                //     }
                // }
                this.refresh()
            },
        }
    }
</script>
 
<style lang="scss" scoped>
    @import '../order.scss'
</style>