liangjin
2021-04-01 423acbcecdfd0e50f7b3311245c41948a418029c
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
 
<template>
    <div class="lthyjQrcode">
        <v-navbar title="扫码办理"></v-navbar>
        <div class="bj">
            <div class="qrcodeBox">
                <div class="qrcode">
                    <img :src="qrCodeBase64Url" alt="qrcode" v-if="qrCodeBase64Url">
                    <img :src="dataUrl" alt="" v-else >
                </div>
                <p class="notice">二维码失效时间为半小时请尽快提供给用户进行扫码</p>
            </div>
        </div>
    </div>
</template>
<script>
    import html2canvas from 'html2canvas';
    import QRCode from 'qrcode';
 
    export default {
        name: 'contract-qrcode',
        data() {
            return {
                dataUrl: '',
                qrCodeBase64Url: '',
                params: ''
            }
        },
        methods: {
            clickLeft() {
                this.$router.go(-1)
            }
        },
        created(){
            QRCode.toDataURL(
                JSON.stringify(this.$route.query.str), {
                    margin: 0,
                    width: 400
                },
                (err, url) => {
                    if (err) console.error(err);
                    this.dataUrl = url;
                    setTimeout(() => {
                        html2canvas(document.getElementById('QRCode')).then(
                            canvas => {
                                this.qrCodeBase64Url = canvas.toDataURL(
                                    'image/jpeg'
                                );
                            }
                        );
                    }, 100);
                }
            );
        }
    }
 
</script>
<style lang="less" scoped>
    .lthyjQrcode {
        width: 100%;
        height: 100%;
        background: #F3F4F5;
        .bj {
            width: 100%;
            height: 150px;
            background: linear-gradient(-45deg, #686285, #4C4571);
            position: relative;
            .qrcodeBox {
                position: absolute;
                top: 40px;
                left: 5.5%;
                width: 89%;          
                height: 287px;
                background: #FFFFFF;
                border-radius: 3px;
                display: flex;
                flex-direction: column;
                align-items: center;
                .qrcode {
                    width: 190px;
                    height: 190px;    
                    border: 1px solid #514B75;
                    margin-top: 28px;
                    display: flex;
                    flex-direction: column;
                    align-items: center;
                    justify-content: center;
                    img {
                        width: 182px;
                        height: 182px;
                    }
                }
                .notice {
                    font-size: 12px;
                    font-family: PingFang SC;
                    font-weight: 500;
                    color: #333333;
                    line-height: 18px;
                    text-align: center;
                    margin-top: 16px;
                }
            }
        }
    }
</style>