更新记录
1.0.0(2026-08-07)
双端蓝牙与局域网; printHtml / printImage; 局域网支持 protocol=framed(TCP 10001 多格式)。ESC 透传 19100 与 UDP 发现保留。对齐 HBuilderX 4.71+ uni_modules 平台声明; 完善隐私声明与原生配置。
平台兼容性
uni-app(4.11)
| Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
|---|---|---|---|---|---|---|---|---|
| × | √ | × | × | √ | × | 5.0 | 12 | × |
| 微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 小红书小程序 | 快应用-华为 | 快应用-联盟 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| × | × | × | × | × | × | × | × | × | × | × | × |
breao-jolimarkprint 使用说明
映美(Jolimark)便携打印 UTS 插件。面向 uni-app Vue3 的 App 端(Android / iOS)。
当前版本:1.0.0
- 蓝牙:Android 经典 SPP;iOS BLE(Service ee / 特征 ee01)
- 局域网:UDP 发现 10002;ESC 透传 19100;多格式帧 10001(HTML / ESC / PNG)
- 打印:
printText/printBytes/printHtml/printImage - 不包含映美云 HTTP API、USB、TSC 标签设计器
1. 环境要求
- HBuilderX 4.11 及以上
- uni-app Vue3
- 仅 App-Android / App-iOS(不支持 H5、小程序、鸿蒙)
- 真机调试须制作自定义基座;正式发版须购买授权后走云端传统打包(不支持离线打包、安心打包)
- 授权绑定唯一 appid + 包名
2. 安装与引入
将插件目录放入工程的 uni_modules/breao-jolimarkprint,或从插件市场导入后同步。
业务代码引用:
import {
init,
destroy,
startBluetoothScan,
stopBluetoothScan,
connectBluetooth,
startLanDiscover,
stopLanDiscover,
connectLan,
disconnect,
printText,
printBytes,
printHtml,
printImage,
getConnectionState,
} from '@/uni_modules/breao-jolimarkprint'
示例组件:uni_modules/breao-jolimarkprint/components/jolimark-print-demo/jolimark-print-demo.vue
3. 快速开始
3.1 蓝牙
init({
transport: 'bluetooth',
modelHint: 'CFP-535B',
debug: true,
onDisconnected(res) {
console.log('被动断开', res.address)
},
success() {
startBluetoothScan({
timeout: 10000,
includeBonded: true,
success(res) {
const d = res.devices && res.devices[0]
if (!d) return
// Android:MAC;iOS:必须用扫描返回的 UUID
connectBluetooth({
address: d.address,
timeout: 15000,
success() {
printText({ content: 'Hello Jolimark\n第二行' })
},
})
},
})
},
})
3.2 局域网 ESC 透传(19100)
init({
transport: 'lan',
success() {
startLanDiscover({
timeout: 3000,
success(res) {
const d = res.devices && res.devices[0]
connectLan({
host: (d && d.host) || '192.168.1.100',
protocol: 'esc',
success() {
printText({ content: 'LAN ESC OK' })
},
})
},
})
},
})
3.3 局域网多格式(10001,HTML / PNG)
init({
transport: 'lan',
success() {
connectLan({
host: '192.168.1.100',
protocol: 'framed',
success() {
printHtml({
html: '<html><body><div>映美 HTML</div></body></html>',
paperType: 1,
paperWidth: 58,
})
},
})
},
})
用毕调用 disconnect 与 destroy。
4. API 说明
| 方法 | 说明 |
|---|---|
init |
初始化。transport(bluetooth / lan)、modelHint、debug、onDisconnected |
destroy |
释放资源 |
startBluetoothScan / stopBluetoothScan |
蓝牙扫描;可选 timeout、includeBonded |
connectBluetooth |
按 address 连接。Android 为 MAC;iOS 为扫描结果中的 UUID |
startLanDiscover / stopLanDiscover |
UDP 10002 发现 |
connectLan |
host;protocol 为 esc(默认,19100)或 framed(10001);可选 port、timeout |
disconnect |
断开当前连接 |
printText |
文本;默认 GBK;局域网 framed 模式会包 ESC 帧 |
printBytes |
字节;raw: true 时不封装协议帧 |
printHtml |
映美 HTML。蓝牙随时可用;局域网须 protocol: 'framed' |
printImage |
PNG 的 ArrayBuffer。局域网须 framed |
getConnectionState |
状态查询;局域网可含 lanProtocol |
回调约定:各方法支持 success / fail / complete。
5. 能力矩阵
| 能力 | Android | iOS |
|---|---|---|
| 蓝牙扫描 / 连接 | SPP(MAC) | BLE(UUID) |
printText / printBytes |
支持 | 支持 |
printHtml / printImage |
支持 | 支持 |
| LAN UDP 发现 | 支持 | 支持 |
| LAN esc 19100 | 支持 | 支持 |
| LAN framed 10001 | 支持 | 支持 |
注意:
- 局域网在
esc模式下调用printHtml/printImage会返回 9030006,请改用protocol: 'framed' printImage请传 PNG 原始字节,勿直接传 JPEG
6. 权限说明
Android
- 蓝牙:
BLUETOOTH、BLUETOOTH_ADMIN(API 不超过 30);BLUETOOTH_SCAN、BLUETOOTH_CONNECT(Android 12+) - 定位:
ACCESS_FINE_LOCATION、ACCESS_COARSE_LOCATION - 网络:
INTERNET、ACCESS_NETWORK_STATE、ACCESS_WIFI_STATE、CHANGE_WIFI_MULTICAST_STATE
iOS
NSBluetoothAlwaysUsageDescriptionNSBluetoothPeripheralUsageDescriptionNSLocalNetworkUsageDescription
插件不采集、不上传任何数据。打印内容仅经本机蓝牙或局域网发至已连接的映美打印机。不调用映美云 HTTP API。
7. 平台注意
iOS
- 蓝牙连接须先
startBluetoothScan,再使用结果中的address(UUID,不是 MAC) - 局域网打印须授权本地网络
- 真机须自定义基座
Android
- 蓝牙为经典 SPP;首次扫描会申请权限
- 与手机、打印机须同一局域网(勿开 AP 隔离)
局域网协议选择
| protocol | 默认端口 | 适用 |
|---|---|---|
esc |
19100 | ESC 文本/字节透传 |
framed |
10001 | HTML / PNG / 带帧 ESC |
8. 错误码
| 码 | 含义 |
|---|---|
| 9030003 | 未 init |
| 9030004 | 蓝牙未开启或权限问题 |
| 9030005 | 未连接打印机 |
| 9030006 | 参数无效(含 LAN 非 framed 却调 HTML/PNG) |
| 9030007 | 当前平台不支持(如 H5、小程序) |
| 9030008 | 驱动无法创建 |
| 9030009 | transport 不匹配 |
| 9030010 | 能力未实现 |

收藏人数:
购买普通授权版(
试用
赞赏(0)
下载 0
赞赏 0
下载 12490847
赞赏 1939
赞赏
京公网安备:11010802035340号