doum
2 天以前 1dcd8399c853ef724133d4d1ad0d700db0f293e7
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
<template>
    <view class="box">
        <view class="title">输入自提码</view>
        <view class="input">
            <input type="number" v-model="code" placeholder="请输入6位自提码" />
        </view>
        <view class="btn" v-if="!loading" @click="confirmDo">确认</view>
        <view class="btn1" v-if="loading" >正在查询</view>
        <view class="footer" @click="scanCodeDo">
            <image src="/pagesA/static/ic_saoma@2x.png" mode="widthFix"></image>
            <text>扫码核销</text>
        </view>
        <u-popup :show="show1" round="15" :safeAreaInsetBottom="false" mode="center">
            <view class="tc">
                <view class="tc-contemt">
                    <view class="tc-contemt-title">订单查询结果</view>
                    <view class="tc-contemt-nr">
                        订单【{{info.code}}】不满足核销条件!
                    </view>
                </view>
                <view class="tc-btn">
                    <view class="tc-btn-item" @click="show1=false ">确认</view>
                </view>
            </view>
        </u-popup>
    </view>
</template>
 
<script>
    import QRCode from 'qrcode';
    import { mapState } from 'vuex'
    export default {
        computed: {
            ...mapState(['navHeight', 'statusbarHeight','shopInfo', 'shopToken'])
        },
        data() {
            return {
                code:null,
                show1:false,
                loading:false,
                id:null,
                info:{}
            };
        },
        onShow() {
            this.loading =false
            this.show1 =false
            this.info={}
            this.code =''
            this.checkShopLogin()
        },
        onLoad(options) {
        },
        methods:{
            scanCodeDo(){
                this.code = ''
                var that =this
                uni.scanCode({
                    success: function (res) {
                        console.log('条码类型:' + res.scanType);
                        console.log('条码内容:' + res.result);
                        // 处理扫描结果
                        that.code = res.result
                        that.confirmDo()
                    },
                    fail: function (err) {
                        uni.showToast({
                            title:'扫码失败',
                            icon:'error'
                        })
                    }
                });
            },
            async confirmDo(){
                if(this.code ){
                    this.getShopDetail()
                }
            },
            jumpWriteoffA(){
                if(this.info && this.info.orderId){
                    uni.navigateTo({
                        url: '/pagesA/pages/write-off-a/write-off-a?id='+this.info.orderId
                    })
                }
            },
            jumpBack(){
                uni.navigateBack({delta:1})
            }, 
             getShopDetail(){
                if(this.loading){
                    return
                }
                this.loading =true
                var that =this 
                that.$u.api.getOrderDetailByCode({exchangeCode:this.code,tokenType:1  })
                .then(res=>{
                    console.log(res)
                    if (res.code === 200) {
                        that.info = res.data 
                        if(res.data.orderStatus == 1 && res.data.receiveType ==1){
                            that.jumpWriteoffA()
                        }else{
                            this.show1 = !this.show1
                            this.loading =false
                        }
                    } 
                }).catch(e=>{
                    this.loading =false
                }).finally(e=>{
                    // this.loading =false
                })
            },
            checkShopLogin(){
                var that =this
                if( this.shopInfo ==null || this.shopInfo.id==null ||  this.shopToken==null || this.shopToken==''){
                    uni.navigateTo({
                        url: '/pages/login/login'
                    })
                } 
            },
        }
    }
</script>
 
<style lang="scss" scoped>
    .box {
        width: 100vw;
        height: 100vh;
        display: flex;
        padding-top: 198rpx;
        box-sizing: border-box;
        align-items: center;
        flex-direction: column;
        background: linear-gradient( 180deg, #C8F3FF 0%, #FFFFFF 52.19%, #FFFFFF 100%);
        .title {
            font-weight: 600;
            font-size: 34rpx;
            color: #222222;
        }
        .input {
            width: 630rpx;
            height: 88rpx;
            padding: 0 30rpx;
            box-sizing: border-box;
            background: #FFFFFF;
            border-radius: 50rpx;
            border: 2rpx solid #004096;
            margin-top: 40rpx;
            input {
                width: 100%;
                height: 100%;
                font-weight: 400;
                font-size: 32rpx;
                color: #111111;
                text-align: center;
            }
        }
        .btn1{
            width: 630rpx;
            height: 88rpx;
            line-height: 88rpx;
            text-align: center;
            background: #666666;
            border-radius: 44rpx;
            font-weight: 600;
            font-size: 32rpx;
            color: #FFFFFF;
            margin-top: 40rpx;
        }
        .btn {
            width: 630rpx;
            height: 88rpx;
            line-height: 88rpx;
            text-align: center;
            background: #004096;
            border-radius: 44rpx;
            font-weight: 600;
            font-size: 32rpx;
            color: #FFFFFF;
            margin-top: 40rpx;
        }
        .footer {
            display: flex;
            align-items: center;
            margin-top: 48rpx;
            image {
                width: 40rpx;
                height: 40rpx;
                margin-right: 12rpx;
            }
            text {
                font-weight: 400;
                font-size: 28rpx;
                color: #004096;
            }
        }
    }
</style>