更新记录
1.0.1(2025-04-09)
优化
1.0.0(2025-04-08)
- usb连接,打印文本、二维码等
平台兼容性
App |
快应用 |
微信小程序 |
支付宝小程序 |
百度小程序 |
字节小程序 |
QQ小程序 |
HBuilderX 3.6.8,Android:4.4,iOS:不支持,HarmonyNext:不支持 |
× |
× |
× |
× |
× |
× |
钉钉小程序 |
快手小程序 |
飞书小程序 |
京东小程序 |
鸿蒙元服务 |
× |
× |
× |
× |
× |
H5-Safari |
Android Browser |
微信浏览器(Android) |
QQ浏览器(Android) |
Chrome |
IE |
Edge |
Firefox |
PC-Safari |
× |
× |
× |
× |
× |
× |
× |
× |
× |
得实集团打印机
开发文档
- 集成插件步骤请参考 https://www.cnblogs.com/wenrisheng/p/18323027
接口文档
如需更多接口请联系作者
import {
UTSDascom
} from "@/uni_modules/wrs-uts-dascom"
let dascom = new UTSDascom()
// 获取所有的usb设备
let result = dascom.getAllUSB()
let usbs = result.usbs
if(usbs) {
if(usbs.length > 0) {
let items = []
for(let i = 0; i < usbs.length; i ++) {
let device = usbs[i]
items.push(JSON.stringify(device))
}
this.showActionSheet(items, (index)=>{
let device = usbs[index]
let params = {}
params["deviceId"] = device.deviceId
let hasUsbPermission = dascom.hasPermission(params)
if(hasUsbPermission) {
// usb已经授权
let openResult = dascom.openDevice(params)
let suc = openResult.suc
if(suc) {
this.showMsg("连接成功")
} else {
this.showMsg("连接失败:" + JSON.stringify(openResult))
}
} else {
// usb没有授权时,先请求usb权限
dascom.requestPermission(params, (resp)=>{
let granted = resp.granted
if(granted) {
let openResult = dascom.openDevice(params)
let suc = openResult.suc
if(suc) {
this.showMsg("连接成功")
} else {
this.showMsg("连接失败:" + JSON.stringify(openResult))
}
} else {
this.showMsg("usb授权失败")
}
})
}
})
} else {
this.showMsg("没有识别到usb设备")
}
} else {
this.showMsg("没有识别到usb设备")
}
dascom.disconnect()
dascom.DSZPLLabelStart()
- 用于定义标签的长度。使用连续介质 (不会按间隙、空白、刻痕、凹槽或穿孔分成单独标签的介质) 时必须使用此命令
//
dascom.DSZPLSetPageLength({len: 0.5 + y})
//
dascom.DSZPLSetPaperOffset({pageWidth: 4})
dascom.DSZPLPrintText({
darkness: 30,
horizontal: x, // inch
vertical: y, // inch
height: 1, // 字体宽
width: 1, // 字体高
text: "Hello"
})
//
dascom.DSZPLPrintQRCode({
darkness: 30,
horizontal: x,
vertical: y + 2,
QRsize: 4, // 大小
correct: "L", // 纠错级别, L、M、Q、H
content: "Hello"
})
//
dascom.DSZPLLabelEnd()
//
dascom.DSZPLSetCutter({
iQty: 1, // 打印总的标签数
enableCutter: true // true暂停和切纸值(暂停之间的标签) false 无暂停
})