liangjin
2021-03-25 19f91bd79fa4ce2c50dfb5b44b0ebfc4f01baeae
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
<!--
 * @Date: 2019-08-30 14:08:02
 * @LastEditors: 小明丶
 * @LastEditTime: 2020-11-16 16:44:00
 * @Description:
 -->
<template>
    <div class="getQRCode">
        <!-- <x-header title="扫码办理" :left-options="{backText:''}" style="background-color:#3A3A3A;"></x-header> -->
    <van-nav-bar title="扫码办理" left-text="返回" left-arrow @click-left="onClickLeft" style="line-height: 43px;">
        <i class="iconfont iconzuojiantou" slot="left" style="font-size: 25px;"></i>
    </van-nav-bar>
        <div class="black-block" :style="{background:$store.state.backColor}"></div>
        <div class="order-info">
            <div style="text-align: center;">
                <img class="qrcodeImg" :src="qrCode" alt="qrCode">
            </div>
            <!-- <p class="notice">扫一扫,办理分期业务</p> -->
            <div class="cell-cont-item-style">
                <span class="title">活动名称</span>
                <span class="value">{{params.contName}}</span>
            </div>
            <div class="cell-item-style">
                <span class="title">合约期</span>
                <span class="value">{{params.term}}</span>
            </div>
            <div class="cell-item-style">
                <span class="title">担保金额</span>
                <span class="value">{{params.guaranteedAmt}}</span>
            </div>
        </div>
        <f-confirm v-model="showModal" showIcon iconClass='scene_Staging-shenhezhong' iconColor='#fff' @on-confirm='onSubmit' :showCancelBtn='false'>
            <div>支付完成</div>
        </f-confirm>
        <f-confirm v-model="Invalid" showIcon iconClass='scene_Staging-shenhezhong' iconColor='#fff' :showCancelBtn='false'>
            <div>当前二维码已经失效,请重新下单</div>
        </f-confirm>
    </div>
</template>
<script>
    import QRCode from 'qrcode';
 
    export default {
        name: 'getQRCode',
        data() {
            return {
                qrCode: '',
                orderId:"",
                timer: '', //轮询定时器
                showModal: false, //模态窗提示
                Invalid: false, //模态窗提示
                params: {
                    contName: '',
                    guaranteedAmt:0,
                    term: 0,
                    monGiftAmt:0
                }
            }
        },
        methods:{
            onClickLeft() {
                this.$router.go(-1);
            },
            //轮询查询订单状态
            orderSts() {
                this.timer = setInterval(() => {
                    this.$api.wxScoreOrderStatus({ id: this.orderId }).then(
                        res => {
                            let orderStatus = res.body.orderStatus;
                            if (orderStatus != 2&& orderStatus != 0) {
                                clearInterval(this.timer);
                                this.showModal = true;
                            } else if (orderStatus == 2) {
                                clearInterval(this.timer);
                                this.Invalid = true;
                            }
                        },
                        err => {
                            err, clearInterval(this.timer);
                        }
                    );
                }, 3000);
            },
            // 支付成功确定
            onSubmit() {
                let queryObj = { orderId: this.orderId};
                this.$router.push({
                    path: '/product/wxScore-detail',
                    query: queryObj
                });
            }
        },
        created() {
            this.params = { ...this.$route.query };
            this.orderId = this.$route.query.orderId;
            let url = this.$route.query.qrCode;
            if (this.timer) {
                clearInterval(this.timer);
            }
            QRCode.toDataURL(
                url,
                {
                    margin: 1,
                    width: 400
                },
                (err, url) => {
                    this.qrCode = url;
                    this.orderSts();
                }
            );
        },
        beforeRouteLeave (to, from, next) {
            if (this.timer) {
                clearInterval(this.timer);
            }
            next()
        },
    }
</script>
<style lang="less" scoped>
@import '../../../style/mixin';
 
.getQRCode {
    position: relative;
    background: #F3F4F5;
    min-height: 100%;
    padding-bottom: 40px;
    .vux-header {
        &:after {
            border-bottom: none !important;
        }
    }
    .vux-header-title {
        span {
            color: #ffffff;
        }
    }
    .left-arrow {
        &:before {
            border-color: #ffffff !important;
        }
    }
    .black-block {
        margin-top: -11px;
        width: 100%;
        height: 150px;
        background:linear-gradient(-45deg,rgba(104,98,133,1),rgba(76,69,113,1));
    }
    .order-info {
        height:587px;
        width: 351px;
 
        box-sizing: border-box;
        border-radius: 6px;
        background-color: #ffffff;
        padding-top: 28px;
        position: absolute;
 
        top: 85px;
        left: 50%;
        transform: translateX(-50%);
        .cell-cont-item-style {
            width: 80%;
            margin: 0 3%;
            padding: 0 5%;
            height: 50px;
            line-height: 20px;
            background: #FAFAFA;
            font-size: 16px;
            // box-sizing: border-box;
            // padding-bottom: 10px;
            // margin-bottom: 40px;
            // border-bottom: 1px solid #dddddd;
            .flexLayout(space-between, center, row);
            .title {
                text-align: left;
                color: #666666;
            }
            .value {
                text-align: right;
                color: #333333;
                // font-size: 14px;
            }
        }
        .cell-item-style {
            width: 80%;
            margin: 0 3%;
            padding: 0 5%;
            height: 50px;
            line-height: 50px;
            background: #FAFAFA;
            font-size: 16px;
            // box-sizing: border-box;
            // padding-bottom: 10px;
            // margin-bottom: 40px;
            // border-bottom: 1px solid #dddddd;
            .flexLayout(space-between, center, row);
            .title {
                text-align: left;
                color: #666666;
            }
            .value {
                text-align: right;
                color: #333333;
                // font-size: 14px;
            }
        }
        .last-cell {
            margin-bottom: 25px !important;
            height:100px;
        }
        .qrcodeImg {
            width: 190px;
            height: 190px;
            background:rgba(255,255,255,1);
            border:6px solid rgba(223,212,255,1);
            border-radius:8px;
            margin-bottom: 37px;
        }
        .notice {
            color: #3a3a3a;
            font-size: 12px;
        }
    }
    .agreenBox {
    width: 80vw;
    height: 70vh;
    padding: 60px 20px 30px 20px;
    position: relative;
  }
  .agreen-html {
    width: 100%;
    height: 100%;
    overflow: scroll;
    box-sizing: border-box;
  }
  .close-agreen {
    .lh(30px);
    .flex(center, center);
 
    .van-icon {
      font-size: @font-16;
    }
  }
  .btn-box{
      &{
          margin-top: 520px;
          text-align: center;
      }
      button{
          width: 90vw;
          height:44px;
          background:rgba(137,110,219,1);
          border-radius:22px;
          color: #fff;
          border: 0;
          outline: none;
      }
  }
}
</style>