移动系统liao
2025-02-17 557c2711a3e103ebc3d0492344eca9730d5e92b2
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
<template>
    <view>
        <u-toast ref="uToast" /><u-no-network></u-no-network>
        <u-navbar title="服务核销码" safeAreaInsetTop fixed placeholder>
            <view class="coreshop-navbar-left-slot" slot="left">
                <u-icon name="arrow-left" size="19" @click="goNavigateBack"></u-icon>
                <u-line direction="column" :hairline="false" length="16" margin="0 8px"></u-line>
                <u-icon name="home" size="22" @click="goHome"></u-icon>
            </view>
            <view slot="right">
            </view>
        </u-navbar>
        <view class="coreshop-list menu-avatar">
            <view class="coreshop-bg-white coreshop-padding-10 coreshop-solid-bottom coreshop-flex coreshop-justify-between">
                <view class="u-line-2 coreshop-font-weight-bold">{{ info.title }}</view>
                <view class="coreshop-width-fit-content" @click="goServicesDetail(info.id)">
                    <u-button size="mini">详情</u-button>
                </view>
            </view>
            <view class="coreshop-list-item">
                <view class="coreshop-avatar radius lg">
                    <image class='services-img' :src="info.thumbnail" mode="widthFix"></image>
                </view>
                <view class="content">
                    <view class="coreshop-text-gray coreshop-font-sm coreshop-flex coreshop-flex-nowrap">
                        <view class="u-line-3">{{ info.description }}</view>
                    </view>
                </view>
            </view>
            <view class="coreshop-bg-white coreshop-padding-10 coreshop-solid-bottom">
                <view class="coreshop-text-gray coreshop-font-xs coreshop-flex coreshop-flex-nowrap coreshop-padding-10">
                    订单编号:{{serviceOrderId}}
                </view>
                <view class="coreshop-text-gray coreshop-font-xs coreshop-flex coreshop-flex-nowrap coreshop-padding-10">
                    兑换级别:
                    <view class="coreshop-width-fit-content coreshop-padding-right-5" v-if="info.allowedMemberships && info.allowedMemberships.length>0" v-for="(item, index) in info.allowedMemberships" :key="index">
                        <u-tag :text="item" mode="light" size="mini" class="coreshop-margin-right-5" />
                    </view>
                </view>
                <view class="coreshop-text-gray coreshop-font-xs coreshop-flex coreshop-flex-nowrap coreshop-padding-10">
                    兑换门店:
                    <view class="coreshop-width-fit-content coreshop-padding-right-3" v-if="info.consumableStores && info.consumableStores.length>0" v-for="(item, index) in info.consumableStores" :key="index">
                        <view class="coreshop-bg-orange-light sm  coreshop-padding-4 coreshop-margin-right-5">{{item}}</view>
                    </view>
                </view>
            </view>
        </view>
 
        <view class="coreshop-padding-left-15 coreshop-padding-right-15 coreshop-padding-top-15">
            <u-subsection :list="items" :current="current" :animation="true" @change="onClickItem" active-color="#ff9900"></u-subsection>
        </view>
 
 
 
        <view class="taobao">
            <view class="ticket" :class="item.status==3?'grayscale':''" v-if="listData.length" v-for="(item, index) in listData" :key="index" @click="showQrcodeBox(index)">
                <view class="left">
                    <view class="introduce">
                        <view class="top" v-if="current==0">
                            核销码:<text class="big">{{item.redeemCode}}</text>
                        </view>
                        <view class="topD" v-if="current!=0">
                            核销码:<text class="big">{{item.redeemCode}}</text>
                        </view>
                        <view class="type">{{item.validityType==1?'长期有效':'限时间段内消费'}}</view>
                        <view class="date u-line-1" v-if="item.validityStartTime && item.validityEndTime">{{item.validityStartTime}} 至 {{item.validityEndTime}}</view>
                    </view>
                </view>
                <view class="right  coreshop-flex coreshop-align-center coreshop-justify-center">
                    <view class="coreshop-width-fit-content">
                        <u-button text="正常" type="info" plain size="mini" v-if="item.status==0"></u-button>
                        <u-button text="过期" type="default" plain size="mini" v-if="item.status==1"></u-button>
                        <u-button text="作废" type="warning" plain size="mini" v-if="item.status==2"></u-button>
                        <u-button text="已核销" type="success" plain size="mini" v-if="item.status==3"></u-button>
                    </view>
                </view>
            </view>
            <u-loadmore :status="status" :icon-type="iconType" :load-text="loadText" margin-top="20" margin-bottom="20" />
        </view>
        <u-popup :show="show" mode="center" width="180px" height="180px" @close="close">
            <canvas canvas-id="qrcode" style="width: 180px; height: 180px; " />
        </u-popup>
    </view>
</template>
 
<script>
    import uQRCode from '@/common/utils/uqrcode.js'
 
    export default {
 
        computed: {
        },
        data() {
            return {
                items: ['正常', '过期', '作废', '已核销'],
                current: 0,
 
                page: 1,
                limit: 10,
                listData: [],
                serviceOrderId: '',
                info: {},
                show: false,
                status: 'loadmore',
                iconType: 'flower',
                loadText: {
                    loadmore: '轻轻上拉',
                    loading: '努力加载中',
                    nomore: '实在没有了'
                }
            };
        },
        onLoad(e) {
            this.serviceOrderId = e.id;
            this.getServicesById();
            this.getServicesTickets();
        },
        onShow() {
        },
        onReachBottom() {
            if (this.status === 'loadmore') {
                this.getServicesTickets()
            }
        },
        methods: {
            // tab点击切换
            onClickItem(index) {
                if (this.current !== index) {
                    this.current = index;
                    this.page = 1;
                    this.listData = [];
                    this.getServicesTickets();
                }
            },
            getServicesById() {
                let _this = this;
                let data = {
                    id: this.serviceOrderId
                }
                this.$u.api.getServicesById(data).then(res => {
                    if (res.status) {
                        this.info = res.data;
                    } else {
                        _this.$u.toast(res.msg)
                    }
                })
            },
            getServicesTickets() {
                let _this = this;
                let data = {
                    id: this.serviceOrderId,
                    status: this.current,
                    page: this.page,
                    limit: this.limit
                }
                this.status = 'loading'
 
                this.$u.api.getServicesTickets(data).then(res => {
                    if (res.status) {
                        let _list = res.data
                        this.listData = [...this.listData, ..._list]
 
                        if (res.data.count > _this.listData.length) {
                            _this.page++
                            _this.status = 'loadmore'
                        } else {
                            _this.status = 'nomore'
                        }
                    } else {
                        _this.$u.toast(res.msg)
                    }
                })
            },
            close() {
                this.show = false
            },
            showQrcodeBox(index) {
                if (this.current != 0) {
                    return;
                }
                let _this = this;
                var item = _this.listData[index];
                if (item.status == 0) {
                    _this.make(item.redeemCode);
                    _this.show = true;
                }
            },
            make(textStr) {
                console.log(textStr);
                console.log(uQRCode);
                uQRCode.make({
                    canvasId: 'qrcode',
                    componentInstance: this,
                    text: textStr,
                    size: 180,
                    margin: 30,
                    backgroundColor: '#ffffff',
                    foregroundColor: '#000000',
                    fileType: 'jpg',
                    correctLevel: uQRCode.errorCorrectLevel.H,
                    success: res => {
                        console.log(res)
                    }
                })
            }
        }
    };
</script>
 
<style lang="scss" scoped>
    @import "details.scss";
</style>