更新记录

1.0(2023-05-28)

插件初始化


平台兼容性

Vue2 Vue3
App 快应用 微信小程序 支付宝小程序 百度小程序 字节小程序 QQ小程序
HBuilderX 3.7.0 app-vue app-nvue
钉钉小程序 快手小程序 飞书小程序 京东小程序
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari

基于uQRCode封装简单快速实用全端二维码生成插件

使用方法


 #引入js文件
import uQRCode from '@/common/uqrcode.js'

    <view class="canvas">
            <!-- 二维码插件 width height设置宽高 -->
            <canvas canvas-id="qrcode" :style="{width: `${qrcodeSize}px`, height: `${qrcodeSize}px`}" />
        </view>

HTML代码部分


<template>
    <view class="content">

        <view class="canvas">
            <!-- 二维码插件 width height设置宽高 -->
            <canvas canvas-id="qrcode" :style="{width: `${qrcodeSize}px`, height: `${qrcodeSize}px`}" />
        </view>

        <text class="list-text">{{ '预约号码:' + ' ' + this.myFormatData.yyh}}
        </text>

        <text class="list-text"> {{ '预约窗口:' + '  ' + this.myFormatData.bsdmc}}
        </text>

        <text class="list-text"> {{ '业务类型:' + '  ' + this.myFormatData.Yylxmc}}
        </text>

        <text class="list-text"> {{ '预约日期:' + '  ' + this.myFormatData.yyrq}}
        </text>

    </view>
</template>

JS代码 (引入组件 填充数据)


<script>
    import Vue from 'vue';
    import uQRCode from '@/common/uqrcode.js'

    export default {
        data() {
            return {
                // 二维码标识串
                qrcodeText: '',
                // 二维码尺寸
                qrcodeSize: 136,

                // 最终生成的二维码图片
                qrcodeSrc: '',
                myFormatData:{'yyh':'eoruw20230528','bsdmc':'窗口1','Yylxmc':'租金缴纳','yyrq':'预约日期'},
            }
        },
        onLoad(e) {

            this.make();
        },
        methods: {

            make() {
                uni.showLoading({
                    title: '二维码生成中',
                    mask: true
                })

                uQRCode.make({
                    canvasId: 'qrcode',
                    text: this.qrcodeText,
                    size: this.qrcodeSize,
                    margin: 10,
                    success: res => {
                        this.qrcodeSrc = res
                        console.log('qrcodeSrc = ' + this.qrcodeSrc);
                    },
                    complete: () => {
                        uni.hideLoading()
                    }
                })
            },

        }
    }
</script>

CSS


<style>
    page {
        background-color: #FFFFFF;
    }

    .content {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        margin-top: var(--status-bar-height);
    }

    .text {
        display: flex;
        justify-content: center;
        margin-top: 46rpx;
        margin-bottom: 6rpx;
        font-size: 36rpx;
        height: 44rpx;
        color: #333333;
    }

    .canvas {
        margin-top: 50rpx;
        margin-bottom: 36rpx;
        text-align: center;
    }

    .list-text {
        display: flex;
        justify-content: center;
        width: 100%;
        line-height: 60rpx;
        font-size: 28rpx;
        color: #666666;
    }

    .button {
        width: 88%;
        margin-top: 52rpx;

    }
</style>

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问