更新记录

1.0.13(2025-05-28)

更新示例项目

1.0.12(2025-05-28)

修改readme

1.0.11(2025-05-28)

添加uniapp使用参考项目

查看更多

平台兼容性

uni-app x

Chrome Safari Android iOS 鸿蒙 微信小程序
- - 5.0 × × ×

优博讯PDA扫码插件

本插件集成了优博讯SDK,如果不需要集成PDA的SDK,可以使用 通用PDA扫码插件https://ext.dcloud.net.cn/plugin?name=hh-pda

插件使用说明

插件市场附带的示例项目是基于uniapp-x的,要是想体验在uniapp上的使用效果,请参考此项目https://gitcode.com/hu382337381/you_bo_xun_sao_ma_cha_jian_u_n_i_a_p_p_shi_li

简单使用,只需初始化并注册扫码监听即可,如下所示,更多api使用可以参考示例项目中的详细使用

<template>
    <view class="content">
        <text>扫码图片:</text>
        <view class="image">
            <image class="image-content" :src="base64Image"></image>
        </view>
        <text>扫码码值:</text>
        <view class="code">
            <text class="f-s-14">{{code}}</text>
        </view>
    </view>
</template>

<script setup>
    import { initScanner, registerScanner, unregisterScanner, getCode, getImage, sendGetImage } from "@/uni_modules/hh-ubx-pda";

    const code = ref('');
    const base64Image = ref("");

    const init = () => {
        //初始化pda
        initScanner();
        //注册扫码监听
        registerScanner();
        uni.showToast({
            title: "初始化成功!",
            icon: "none",
            mask: false
        })
    }

    onLoad(() => {
        init();
        //获取扫码值
        getCode(_code => {
            code.value = _code;
            //发送获取图片的请求
            sendGetImage();
        });
        //获取扫码图片,图片为base64格式
        getImage(_img => {
            base64Image.value = _img;
        });
    });

    onUnload(() => {
        //移除扫码监听
        unregisterScanner();
        uni.showToast({
            title: "移除扫码监听!",
            icon: "none",
            mask: false
        })
    })
</script>

<style lang="scss" scoped>
    .content {
        width: 100%;
        height: 100%;
        padding: 15rpx;
        display: flex;
        flex-direction: column;
    }

    .image {
        width: 100%;
        height: 200px;
        border: 1px solid rgb(41, 78, 162);

        >.image-content {
            width: 100%;
            height: 100%;
        }
    }

    .code {
        width: 100%;
        height: 35px;
        border: 1px solid rgb(41, 78, 162);
        margin-top: 15rpx;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
    }

    .action-btn-list {
        margin-top: 15rpx;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;

        >.action-btn {
            width: 33.33%;
            padding: 20 15px;
            background-color: rgb(41, 78, 162);
            border-radius: 2px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            border: 1px solid #ccc;

            >.f-s-14,
            .f-s-12 {
                color: #fff;
            }

            &:hover {
                background-color: #fff;
            }
        }
    }
</style>

隐私、权限声明

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

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

插件不采集任何数据

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

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