更新记录

2.1(2024-03-29)

优化使用说明

2.0.3(2024-01-07)

组件优化

2.0.2(2023-07-03)

组件优化

查看更多

平台兼容性

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

cc-defineQRCode

二维码小程序已上线,小程序扫码体验地址

图片

我的技术微信公众号

查看更多前端组件和框架信息,请关注我的技术微信公众号【前端组件开发】

图片

使用方法

 #引入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">{{ '预约号码:' + ' ' + myFormatData.yyh}}
        </text>

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

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

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

    </view>
</template>

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

    export default {
        data() {
            return {
                // 二维码标识串
                qrcodeText: 'eoruw20230528',
                // 二维码尺寸
                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>

<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协议

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