更新记录

1.0.2(2020-10-13)

添加判断蓝牙是否已经连接方法; 优化连接逻辑等;

1.0.0(2020-09-27)

汉印蓝牙打印:文本、图片、条形码、二维码、电子面单等等


平台兼容性

Android Android CPU类型 iOS
适用版本区间:4.4 - 11.0 armeabi-v7a:未测试,arm64-v8a:未测试,x86:未测试 ×

原生插件通用使用流程:

  1. 购买插件,选择该插件绑定的项目。
  2. 在HBuilderX里找到项目,在manifest的app原生插件配置中勾选模块,如需要填写参数则参考插件作者的文档添加。
  3. 根据插件作者的提供的文档开发代码,在代码中引用插件,调用插件功能。
  4. 打包自定义基座,选择插件,得到自定义基座,然后运行时选择自定义基座,进行log输出测试。
  5. 开发完毕后正式云打包

付费原生插件目前不支持离线打包。
Android 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/android
iOS 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/ios

注意事项:使用HBuilderX2.7.14以下版本,如果同一插件且同一appid下购买并绑定了多个包名,提交云打包界面提示包名绑定不一致时,需要在HBuilderX项目中manifest.json->“App原生插件配置”->”云端插件“列表中删除该插件重新选择


汉印打印机

一、注册插件

const print = uni.requireNativePlugin('HY-Print');

二、获取蓝牙设备列表

  • 获取列表
    print.bluetoothList({
                }, result => {
                    const msg = JSON.stringify(result);
                    console.log(msg)
                    modal.toast({
                        message: msg,
                        duration: 1.5
                    });
                });
  • 响应结果 {"list":[{"btAddress":"FC:58:FA:A1:D8:D0","btName":"HM-Z3-D8D0"}],"msg":"搜索完成"}

三、连接蓝牙

  • 判断蓝牙是否已经连接

    连接蓝牙前需要判断是否已经连接,如果已经连接不能重复连接,否则会失败

    print.bluetoothConnectState(result => {
                    //{"state":true} or {"state":false}
                    const msg = JSON.stringify(result);
                    console.log(msg)
                    modal.toast({
                        message: msg,
                        duration: 1.5
                    });
                });
  • 连接蓝牙

print.bluetoothConnect({
                    btAddress: 'FC:58:FA:A1:D8:D0',//蓝牙地址
                    btName: 'HM-Z3-D8D0'//蓝牙名称
                }, result => {
                    const msg = JSON.stringify(result);
                    console.log(msg)
                    modal.toast({
                        message: msg,
                        duration: 1.5
                    });
                });

四、打印

print.bluetoothPrint({
                    content: '命令内容' //打印命令内容
                }, result => {
                    const msg = JSON.stringify(result);
                    console.log(msg)
                    modal.toast({
                        message: msg,
                        duration: 1.5
                    });
                });

五、命令示例

    var path =
        "! 0 200 200 1060 1\r\n" +
        "EG 33 66 15 20\r\n" +
        "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007FFFF000000FFFFFFFF01E1E003C0001FFFFF000FFFFFC00000000000000000001FFFFEFC0000FFFFFFFF01E1E003C0FE1FFFFF0FEFFFFFC00000000000000000003FFFF9FF00000003E00001E1E003C0FE1E00000FE0C00F800000000000000000003FFFF7FF80000003E00003E1F007C0001E00000001F03F000000000000000000007FFFEFFF80000003E0000FFFFFFFF8001E00000001FC7E00000000000000000000FFFFDFFFC0000007C0000FFFFFFFF8001E00000001FFFC00000000000000000001FFFFBFFFE0000007C00001E1E003C0001E0000000FFFFFC0000000000000000003FFFFBFFFE000FFFFFFFF01E1E003C0041E00000FEFFFFFC0000000000000000003FFFF3FFFF000FFFFFFFF01E1E003C0FE1E00000FEF8783C0000000000000000007FFFE1FFFF800F800000F01E1E003C0FE1E00000FEF87C3C0000000000000000007FFFC0FFFF800F000000F01E1E003C01E1E000001EF87C3C000000000000000000FFFFC07FFFC00F800000F01E1E003C01E1E000001EFFFFFC000000000000000001FFFF807FFFE00F800000F01E1E003C01E1E000001EFFFFFC000000000000000001FFFF003FFFE00F800000F01E1E003C01E1E000001EF87C3C000000000000000003FFFE001FFFF00F000000F01E1E003C01E1E000001EF8783C000000000000000003FFFE000FFFF00FFFFFFFF01E1E003C01E1E000001EFFFFFC000000000000000007FFFC000FFFF80FFFFFFFF01E1E007C01E1E000001EFFFFFC000000000000000007FFF80007FFF80FFFFFFFF01E1E00FC01E1E000001EF87C3C00000000000000000FFFF80003FFFC0F000000F01E1FFFF801E1E000001EF8783C00000000000000000FFFF00003FFFC0F000000F01E1FFFF001E1E000001EF87C3C00000000000000000FFFE00001FFFC0F800000F01E0FFFE001E1E000001EF87C7C00000000000000000FFFE00001FFFE0F800000F01E00000001E1E000001EF87C7800000000000000000FFFC00000FFFC0F000001F01E00000003E1E000003E000000000000000000000007FFC00000FFF80F800003F01E00000003C1E000003E000000000000000000000003FFC000007FF00FFFFFFFE01FFFFFFF87C1FFFFF03FFFFFFE000000000000000004FF8000007FE00FFFFFFFC01FFFFFFF87C1FFFFF07FFFFFFE0000000000000000033F8000003F18000000000000000000040000000040000000000000000000000003E300000000F0000000000000000000000000000000000000000000000000000001FF0000003FE0000000000000000000000000000000000000000000000000000000FFF80007FFE0000000000000000000000000000000000000000000000000000000FFFE000FFFC00000000000000000000000000000000000000000000000000000007FFF001FFF800000000000000000000000000000000000000000000000000000003FFF807FFF0006801281C0718007F08081807C027C0E00F00000000000000000001FFFC0FFFF000FF0FF87F0FFC00FF8C18FF8FF87FC3F83F80000000000000000001FFFE1FFFE000C18C006180C000C00630C18C0C60030C30C0000000000000000000FFFFBFFFC000C18C00C080C000C00370C0CC0C60060420400000000000000000007FFFBFFFC000C18C006000C000C003E0C0CC0C60030030000000000000000000007FFF1FFF8000FF0FF83E00C000FF01C0C18FFC7FC3F01F000000000000000000003FFE0FFF0000FF8FF80F80C000FF01C0FF0FF07FC07C07C00000000000000000001FFC07FF1800C18C0001C0C000C003E0C00C3060000E00E00000000000000000001FF803FE0940C0CC00C0C0C000C00770C00C1860060660600000000000000000000FF001FC09C0C18C00E0C0C000C00638C00C1C600706706000000000000000000003E000F80000FF8FFC7F80C000FF8C18C00C0E7FE3FC3FC00000000000000000000000000000007E07FC1F008000FF980CC004063FC1F80F8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\r\n" +
        "PAGE - WIDTH 576\r\n" +
        "SETMAG 2 2\r\n" +
        "TEXT 8 0 380 8 快递包裹\r\n" +
        "SETMAG 1 1\r\n" +
        "TEXT 8 0 10 100 2019年9月21日11:09:49\r\n" +
        "TEXT 8 0 270 100 第1/1个\r\n" +
        //条形码
        "BARCODE-TEXT 7 0 5\r\n" +
        "BARCODE 128 1 3 100 130 130 1106745891514\r\n" +
        "BARCODE-TEXT OFF\r\n" +
        // 大方框
        "BOX 1 270 580 830 2\r\n" +
        "SETMAG 3 3\r\n" +
        "TEXT 8 0 80 290 深圳123A45\r\n" +
        "SETMAG 1 1\r\n" +
        "LINE 1 380 580 380 2\r\n" +
        // ---集字方框
        "BOX 10 390 70 455 5\r\n" +
        "SETMAG 2 2\r\n" +
        "TEXT 8 0 17 400 集\r\n" +
        "SETMAG 3 3\r\n" +
        "TEXT 8 0 90 385 深圳\r\n" +
        "SETMAG 1 1\r\n" +
        "LINE 1 460 580 460 2\r\n" +
        //图标
        "EG 9 79 10 505 00000003FFC00000000000007FFFFC000000000003FFFFFF80000000000FFFFFFFE0000000003FFFFFFFF800000000FFFFFFFFFE00000001FFFFFFFFFF80000007FFFFFFFFFFC000000FFFF8003FFFE000001FFFC00007FFF000003FFE000000FFF800007FFC0000003FFC0000FFF00000001FFE0001FFE0380E000FFF0001FFC0381E0003FF0003FF80381C0001FF8007FF00381C0000FFC007FE1838380000FFC007FC1C383800007FE00FF81C387FFFF83FE00FF81C387FFFF83FE01FF01C38FFFFF01FF01FF01C38F007001FF01FF01C39F007000FF01FE01C39F007000FF83FE01C3BF007000FF83FE01C3BB807000FF83FE01C3B380F000FF83FE01C38380E000FF83FE01C381C0E0007F83FE01C381C1E000FF83FE01C381E1C000FF83FE01C780E3C000FF81FE01FF80F38000FF81FE01FF807F8000FF01FF03F3803F0000FF01FF03C3801E0001FF00FF0183803F0001FE00FF8003807FC003FE007F800381F3F003FC007FC00387E1FC07FC003FE0039F807F87F8003FE003BF001F8FF8001FF003BC00071FF0001FF8011000003FF0000FFC000000007FE00007FF00000000FFE00007FF80000003FFC00003FFE0000007FF800001FFF800003FFF800001FFFF0000FFFF000000FFFFF01FFFFE0000007FFFFFFFFFFE0000007FFFFFFFFFFC0000003FFFFFFFFFF80000001FFFFFFFFFF00000000FFFFFFFFFF00000000FFFFFFFFFE000000007FFFFFFFFC000000003FFFFFFFF8000000001FFFFFFFF0000000000FFFFFFFF0000000000FFFFFFFE00000000007FFFFFFC00000000003FFFFFF800000000001FFFFFF000000000000FFFFFE0000000000007FFFFC0000000000003FFFFC0000000000003FFFF80000000000001FFFF00000000000000FFFE000000000000007FFC000000000000003FF8000000000000001FF0000000000000000FE00000000000000007C00000000000000003800000000000000001000000000\r\n" +
        "TEXT 8 0 80 480 金xx 13800139000\r\n" +
        "SETMAG 1 1\r\n" +
        "TEXT 8 0 80 510 科技南十二路金蝶\r\n" +
        "TEXT 8 0 80 540 软件\r\n" +
        "TEXT 8 0 80 570 园A栋\r\n" +
        "LINE 1 650 580 650 2\r\n" +
        // 反转变黑
        "SETMAG 2 2\r\n" +
        "TEXT 8 0 20 670 寄\r\n" +
        "SETMAG 1 1\r\n" +
        "TEXT 8 0 20 730 白小递\r\n" +
        "TEXT 8 0 20 760 138 0013 8000\r\n" +
        "LINE 250 650 250 830 2\r\n" +
        "LINE 405 680 405 830 2\r\n" +
        "LINE 1 830 580 830 2\r\n" +
        // 二维码
        "BARCODE QR 255 675 M 2 U 7\r\n" +
        "MA,1106745891514\r\n" +
        "ENDQR\r\n" +
        "LINE 405 740 580 740 2\r\n" +
        "SETMAG 1 1\r\n" +
        "TEXT 8 0 415 660 已验视\r\n" +
        "TEXT 8 0 415 750 签字栏\r\n" +
        "TEXT 8 0 10 840 文件一件\r\n" +
        "TEXT 8 0 470 930 已验视\r\n" +
        "PRINT\r\n";

六、定制服务

QQ:690898091

QQ群:475527470

隐私、权限声明

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

蓝牙权限、位置信息权限

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

插件不采集任何数据

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

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