liangjin
2021-03-30 6644b5af8235790eb5fd4c4265ce99aa90b134f1
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
<!--
 * @Author: 小明丶
 * @Date: 2020-03-19 13:48:16
 * @LastEditors: 小明丶
 * @LastEditTime: 2020-03-23 10:15:36
 * @Description: 信用购花呗二维码页面
 -->
<template>
    <div class="getQRCode">
    <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"></div>
        <div class="order-info">
            <img class="qrcodeImg" :src="qrCode" alt="qrcode">
            <!-- <p class="notice">扫一扫,办理分期业务</p> -->
            <div class="cell-item-style">
                <span class="title">分期金额</span>
                <span class="value">{{params.capitalAmt}}元</span>
            </div>
            <div class="cell-item-style">
                <span class="title">花呗分期手续费率</span>
                <span class="value">{{params.zfbRate}}%</span>
            </div>
            <div class="cell-item-style">
                <span class="title">智享服务费率</span>
                <span class="value">{{params.platRate}}%</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.totalAmount}}元</span>
            </div>
            <p style="width:94%;margin-left:3%;text-align:left;padding-top:14px">
                <span style="color:#999999;font-size:12px">请主动向用户展示</span>
                <span style="color:#896EDB;font-size:12px" @click="ShowAgreen=true">《用户协议》</span>
                <span style="color:#999999;font-size:12px">,扫描二维码则视为用户同意此协议。</span>
            </p>
        </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>
        <van-popup v-model="ShowAgreen">
        <div class="agreenBox">
          <div class="agreen-html" v-html="Agreend"></div>
          <div class="close-agreen" @click="ShowAgreen = false">
            <van-icon name="close" />
          </div>
        </div>
      </van-popup>
    </div>
</template>
<script>
    import QRCode from 'qrcode';
 
    export default {
        name: 'getQRCode',
        data() {
            return {
                ShowAgreen:false,
                Agreend:'',
                qrCode: '',
                orderId:"",
                timer: '', //轮询定时器
                showModal: false, //模态窗提示
                Invalid: false, //模态窗提示
                params: {
                    totalAmount: 0,
                    term: 0,
 
                }
            }
        },
        methods:{
            onClickLeft() {
                this.$router.go(-1);
            },
            //轮询查询订单状态
            orderSts() {
                this.timer = setInterval(() => {
                    this.$api.hbOrderFindOrderSts({ orderId: this.orderId }).then(
                        res => {
                            if (res.body.orderStatus == 1) {
                                clearInterval(this.timer);
                                this.showModal = true;
                            } else if (res.body.orderStatus == 2) {
                                clearInterval(this.timer);
                                this.Invalid = true;
                            } else if (res.body.orderStatus == 3) {
                                clearInterval(this.timer);
                                this.showModal = true;
                            }
                        },
                        err => {
                            err, clearInterval(this.timer);
                        }
                    );
                }, 10000);
            },
            // 支付成功确定
            onSubmit() {
                let queryObj = { id: this.orderId,whereGo:1};
                if(this.$route.query.typeId){
                    queryObj.typeId = this.$route.query.typeId;
                }
                this.$router.push({
                    path: '/product/xyg-hb-detail',
                    query: queryObj
                });
            }
        },
        created() {
            this.Agreend = agreement3
            this.params = { ...this.$route.query };
            this.orderId = this.$route.query.orderId;
            if (this.timer) {
                clearInterval(this.timer);
            }
            let url = window.sessionStorage.getItem('xygHbpayQrCodeUrl');
            QRCode.toDataURL(
                url,
                {
                    margin: 1,
                    width: 400
                },
                (err, url) => {
                    if (err) console.error(err);
                    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%;
    .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;
        text-align: center;
        box-sizing: border-box;
        border-radius: 6px;
        background-color: #ffffff;
        padding-top: 28px;
        position: absolute;
        top: 85px;
        left: 50%;
        transform: translateX(-50%);
        .cell-item-style {
            width: 80%;
            margin: 0 3%;
            padding: 0 7%;
            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 {
                color: #666666;
            }
            .value {
                color: #333333;
                // font-size: 14px;
            }
        }
        .last-cell {
            margin-bottom: 25px !important;
        }
        .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;
    }
  }
}
</style>