0.2.0 • Published 2 years ago
dr-vue-ble v0.2.0
dr-vue-ble
ble
Install
npm install dr-vue-ble
npx cap sync
API
echo(...)
getConnectedDevices(...)
connect(...)
isConnect(...)
printer(...)
getStatus()
disconnect()
getMacAddress()
SNBC 打印机桥梁
打印时参数:
const qr:any = {
type: 2, // 打印类型 1 1d 2 二维码 3 文字
x: 0, // 横坐标,单位点。
y: 0, // 纵坐标,单位点。
data: 'No12365574892145', // 内容
eCCLever: "M", // 安全级别。'H'表示极高可靠性级别, 'Q'表示高可靠性级别, 'M'表示标准级别, 'L'表示高密度级别
cellWidth: 80, // 模块宽度。
model: 2, // 条码模式, 1为原始模式,2为增强模式
};
const oneD:any = {
type: 1, // 打印类型 1 1d 2 二维码 3 文字
x: 160, // 横坐标,单位点。
y: 0, // 纵坐标,单位点。
data: '0023695', // 内容
rotation: 0,// 0 0度,1 90,2 180, 3 270
height: 80, // 条码高度,单位:点。
narrowbarWidth: 3, // 窄条宽度,单位:点。
wideBarwidth: 6, // 宽条宽度,单位:点。
};
const textArea:any = {
type: 3, // 打印类型 1 1d 2 二维码 3 文字
x: 0, // 起始区域横坐标,单位点。
y: 160, // 起始区域纵坐标,单位点。
x2: 600, // 结束区域横坐标,单位点。 自动换行为宽
y2: 480, // 结束区域纵坐标,单位点。 自动换行为高
data: '测试一段文字。。。。。。。。测试一段文字。。。。。。。。测试一段文字。。。。。。。。测试一段文字。。。。。。。。测试一段文字。。。。。。。。', // 内容
area: 0, // 选择0居左、2局右或1居中
fontSize: 24, // 窄条宽度,单位:点。
bold: 0, // 当设置1时,字体加粗;设置为0时,字体不加粗
Reverse: 0, //当设置1时,打印方式黑底白字;设置为0时,打印方式为白底黑字
wrap: 1, // 自动换行为 1
lineSpace: 1
};
const page: {width: number, hight: number, item: any[]} = {
width: 600, // 布局宽
hight: 800, // 布局高
item: [ ]
}
echo(...)
echo(options: { value: string; }) => Promise<{ value: string; }>
测试
Param | Type |
---|---|
options | { value: string; } |
Returns: Promise<{ value: string; }>
getConnectedDevices(...)
getConnectedDevices(options: { value: string; }) => Promise<{ value: any; }>
获取已连接设备
Param | Type |
---|---|
options | { value: string; } |
Returns: Promise<{ value: any; }>
connect(...)
connect(options: { address: string; }) => Promise<{ code: any; }>
连接新北洋打印机
Param | Type |
---|---|
options | { address: string; } |
Returns: Promise<{ code: any; }>
isConnect(...)
isConnect(options: { address: string; }) => Promise<{ code: any; }>
判断蓝牙是否打开
Param | Type |
---|---|
options | { address: string; } |
Returns: Promise<{ code: any; }>
printer(...)
printer(options: { value: string; }) => Promise<{ code: any; }>
打印
Param | Type |
---|---|
options | { value: string; } |
Returns: Promise<{ code: any; }>
getStatus()
getStatus() => Promise<{ code: any; }>
获取打印机状态
Returns: Promise<{ code: any; }>
disconnect()
disconnect() => Promise<{ code: any; }>
断开
Returns: Promise<{ code: any; }>
getMacAddress()
getMacAddress() => Promise<{ address: any; }>
获取mac地址
Returns: Promise<{ address: any; }>