更新记录

1.0.1(2021-11-16)

1.0.1版本上线


平台兼容性

Android Android CPU类型 iOS
适用版本区间:4.4 - 7.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原生插件配置”->”云端插件“列表中删除该插件重新选择


TryCatch-Print 插件使用说明

本插件功能为PDA设备调用打印功能

插件的使用

引入插件

const printer = uni.requireNativePlugin('tryCatch-print');

调用打印方法

let globalConfig = {

    content: [
        // 粗体文字
        {
            type: 'string',
            text: 'tryCatch-print',
            fontSize: '25',
            bold: true
        },
        // 打印文字
        {
            type: 'string',
            text: 'hello tryCatch-print',
            fontSize: '20',
            bold: false
        },
        // 指定 x,y
        {
            type: 'string',
            text: 'hello tryCatch-print',
            fontSize: '20',
            x: 240,
            y: 50,
            bold: false
        },
        {
            type: 'string',
            text: '1.hello tryCatch-print!!\n2.hello tryCatch-print!!\n3.hello tryCatch-print!!',
            absoluteText:'你好世界',
            x: 320, //设置absoluteText的x坐标
            fontSize: '20',
            bold: false
        },
        // 打印图片
        {
            type: 'image',
            text: '灰太狼:',
            fontSize: '20',
            url: 'https://hubi.work/file/huitailang.jpg',
            imageWidth: 250,
            imageHeight: 250
        }
    ]
}
printer.print(globalConfig, (res) => {
    console.log('print回调执行 返回:' + JSON.stringify(res))
    uni.showToast({
        title: JSON.stringify(res),
        icon: 'none',
        duration: 2000
    });
})

接口参数说明

printer.print(globalConfig,callback) 返回 200 为打印成功, 返回 500 为打印错误,并携带 err 为错误信息。

code err 说明
200 打印成功
500 错误信息 打印失败

globalConfig参数说明

参数 类型 默认值 描述
maxPageHeight int 4000 最大页面大小,如超出会抛出异常,按实际情况设置
fontSize float 20 全局字体大小,优先级小于Data的fontSize
globalMarginTop int 60 打印内容距离纸张的上边距
globalMarginBottom int 60 打印内容距离纸张的下边距
content array [] 打印内容

content参数说明

content 为要打印的内容数组 内容对象参数如下

参数 类型 默认值 描述
type string 打印的类型 string,image
url string 当type为image生效,图片url路径
x float 绝对定位x,绝对定位优先级高,与y同时指定生效
y float 绝对定位y,绝对定位优先级高,与x同时指定生效
rotate float 图片旋转度数
fontSize float 字体大小
bold bool 是否粗体
marginBottom int 下边距
lastMarginBottom int 结束行的下边距 在原有下边距的基础上面相加
imageWidth int 图片宽度
imageHeight int 图片高度

常见问题

如有问题可联系作者QQ:1535892832

隐私、权限声明

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

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

插件不采集任何数据

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

许可协议

作者未提供license.md

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