提交 b7a98f8c authored 作者: 刘旭's avatar 刘旭

完成pda打印操作

上级 ed8bbafb
......@@ -23,6 +23,7 @@
"@dcloudio/uni-mp-toutiao": "3.0.0-alpha-3061620221230002",
"@dcloudio/uni-mp-weixin": "3.0.0-alpha-3061620221230002",
"@dcloudio/uni-quickapp-webview": "3.0.0-alpha-3061620221230002",
"dayjs": "^1.11.8",
"node-sass": "^7.0.1",
"pinia": "^2.0.21",
"pinia-plugin-persistedstate": "^3.1.0",
......
......@@ -2,7 +2,7 @@
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app';
</script>
<style lang="scss">
@import './static/iconfont/iconfont.css';
@import './static/iconfont.css';
@import 'vk-uview-ui/index.scss';
@import './scss/common.scss';
......
......@@ -59,14 +59,7 @@
{
"path": "pages/blueTooth/index",
"style": {
"navigationBarTitleText": "连接蓝牙",
"navigationBarBackgroundColor": "#f6f6f6"
}
},
{
"path": "pages/blueTooth/printTest",
"style": {
"navigationBarTitleText": "测试标签打印",
"navigationStyle": "custom",
"navigationBarBackgroundColor": "#f6f6f6"
}
}
......
<template>
<!-- <u-form :model="formData" label-width="75" :border-bottom="true">
<u-form-item label="领料单号" prop="oddNumbers">
<u-input v-model="formData.oddNumbers" />
</u-form-item>
<u-line />
<u-form-item label="备注" prop="remarks">
<u-input v-model="formData.remarks" />
</u-form-item>
</u-form> -->
<view class="form">
<view v-for="item in metadataList" :key="item.key" class="form-item">
<view class="label">{{ item.label }}</view>
......
export default {
panels: [
{
name: null,
height: 50,
width: 70,
paperHeader: 0,
paperFooter: 141.73228346456693,
printElements: [
{
options: {
left: 10.5,
top: 7.5,
height: 32,
width: 120,
field: 'barcode',
testData: 'XS888888888',
fontSize: 12,
lineHeight: 18,
textAlign: 'left',
textType: 'barcode',
title: '条形码',
},
printElementType: { title: '条形码', type: 'text' },
},
{
options: {
left: 10.5,
top: 58.5,
height: 16,
width: 120,
field: 'date',
testData: '2020-01-01',
fontSize: 6.75,
fontWeight: '700',
textAlign: 'left',
textContentVerticalAlign: 'middle',
title: '业务日期',
},
printElementType: { title: '业务日期', type: 'text' },
},
{
options: {
left: 10.5,
top: 78,
height: 16,
width: 120,
field: 'tel',
testData: '18888888888',
fontSize: 6.75,
fontWeight: '700',
textAlign: 'left',
textContentVerticalAlign: 'middle',
title: '客户电话',
right: 132,
bottom: 94,
vCenter: 72,
hCenter: 86,
},
printElementType: { title: '客户电话', type: 'text' },
},
{
options: {
left: 141,
top: 78,
height: 50,
width: 50,
field: 'qrcode',
testData: 'XS888888888',
fontSize: 12,
lineHeight: 18,
textType: 'qrcode',
title: '二维码',
right: 190.25,
bottom: 127.25,
vCenter: 165.25,
hCenter: 102.25,
coordinateSync: false,
widthHeightSync: false,
qrCodeLevel: 0,
},
printElementType: { title: '二维码', type: 'text' },
},
{
options: {
left: 10.5,
top: 97.5,
height: 16,
width: 120,
field: 'tel',
testData: '18888888888',
fontSize: 6.75,
fontWeight: '700',
textAlign: 'left',
textContentVerticalAlign: 'middle',
title: '客户电话',
},
printElementType: { title: '客户电话', type: 'text' },
},
{
options: {
left: 10.5,
top: 115.5,
height: 16,
width: 120,
field: 'order',
testData: 'XS888888888',
fontSize: 6.75,
fontWeight: '700',
textAlign: 'left',
textContentVerticalAlign: 'middle',
title: '订单编号',
},
printElementType: { title: '订单编号', type: 'text' },
},
],
paperNumberLeft: 168,
paperNumberTop: 123,
paperNumberDisabled: true,
watermarkOptions: {
content: '',
fillStyle: 'rgba(184, 184, 184, 0.3)',
fontSize: '14px',
rotate: 25,
width: 200,
height: 200,
timestamp: false,
format: 'YYYY-MM-DD HH:mm',
},
},
],
}
......@@ -22,7 +22,6 @@ onLoad(async () => {
const { subSystem, permTag: formId } = JSON.parse(uni.getStorageSync('pageData'))
const { data: res } = await getBusinessList({ formId, subSystem, mobile: true })
sLoading()
formListRef.value.init()
if (res.code === 200) handleLoadData(res.data)
})
......
<template>
<div class='app-container'></div>
</template>
<script setup lang='ts'>
import { ref } from 'vue'
</script>
<style lang = "scss" scoped>
</style>
<!-- <template>
<view class="content">
<view class="body">
<view>
<textarea class="result" v-model="state.returnResult"></textarea>
</view>
<textarea class="input" @input="inputEvent" />
<view style='margin-top:4%'>
<u-button type='primary' @tap='labelTest' :loading='state.isLabelSend' :disabled='state.isLabelSend'>
标签测试
</u-button>
</view>
<u-button type="warning" @tap="front">向前拉动</u-button>
<u-button type="warning" @tap="after">向后拉动</u-button>
<picker style='margin:20px' mode='selector' :range='state.buffSize' :value='state.buffIndex'
@change='buffBindChange'>
当前每次发送字节数为(点击可更换):{{ state.buffSize[state.buffIndex] }}
</picker>
<picker style='margin:20px' mode='selector' :range='state.printNum' :value='state.printNumIndex'
@change='printNumBindChange'>
当前打印份数(点击可更换):{{ state.printNum[state.printNumIndex] }}
</picker>
<view style='margin-top:4%; display: flex; flex-direction: row;'>
<canvas canvas-id='edit_area_canvas'
:style="{ width: state.canvasWidth + 'px', height: state.canvasHeight + 'px' }"></canvas>
</view>
</view>
</view>
</template>
<script setup lang='ts'>
import { reactive, toRefs } from 'vue'
import { useBlueTooth } from '@/store/modules/bluetooth';
import { onLoad, onShow, onReady, onUnload } from '@dcloudio/uni-app';
import { createNew } from '../../utils/ble/tsc'
onLoad(() => {
let { BLEInformation } = blueTooth;
})
onReady(() => {
let list = [] as any[]
let numList = []
let j = 0
for (let i = 20; i < 200; i += 10) {
list[j] = i;
j++
}
for (let i = 1; i < 10; i++) {
numList[i - 1] = i
}
state.buffSize = list;
state.oneTimeData = list[0];
state.printNum = numList;
state.printerNum = numList[0];
})
onShow(() => {
// const ctx = uni.createCanvasContext("edit_area_canvas", state);
// if (app.globalData.platform == "android") {
// ctx.translate(width, height)
// ctx.rotate(180 * Math.PI / 180)
// }
})
onUnload(() => {
// let that = state;
// let {
// BLEInformation
// } = that.Bluetooth;
// uni.closeBLEConnection({
// deviceId: BLEInformation.deviceId,
// success: function(res) {
// console.log("关闭蓝牙成功")
// },
// })
})
const state: any = reactive({
sendContent: "",
looptime: 0,
currentTime: 1,
lastData: 0,
oneTimeData: 0,
returnResult: "",
canvasWidth: 1050,
canvasHeight: 750,
buffSize: [],
buffIndex: 0,
printNum: [],
printNumIndex: 0,
printerNum: 1,
currentPrint: 1,
isReceiptSend: false,
isLabelSend: false
})
const blueTooth = useBlueTooth()
const front = () => {
let command = createNew()
command.setFeed(1)
}
const after = () => {
let command = createNew()
command.setBackFeed(1)
}
const inputEvent = (e: any) => state.sendContent = e.detail.value;
const labelTest = () => {
let canvasWidth = state.canvasWidth
let canvasHeight = state.canvasHeight
// x 和 y: 文字的起始位置坐标,以毫米为单位。
// font: 字体类型,可以是预装载的或者外部下载的字体。
// x_ 和 y_: 水平和垂直缩放比例,范围为 0 - 10,可调整字体大小。
// str: 要打印的文字内容。
// codetype: 条形码类型,支持 CODE128、CODE39、CODE93 等多种类型。
// height: 条码的高度,以毫米为单位。
// readable: 是否在条形码下方打印可读的文字标签。0 表示不打印,1 表示打印。
// narrow 和 wide: 条形码线条的宽度比例,范围为 1 - 10。
// content: 条形码所表示的内容。
let command = createNew()
command.setSize(70, 52); // 设置页面大小
command.setGap(0); //传感器
command.setCls(); //清除打印机缓存
command.setText(40, 50, 'TSS24.BF2', 1, 1, 'WMS编码号');
command.setBarCode(200, 40, 'EAN8', 64, 1, 3, 3, '1234567');
command.setText(40, 100, 'TSS24.BF2', 1, 1, '佳博智汇');
command.setText(40, 140, 'TSS24.BF2', 1, 1, 'h测试数字12345678');
command.setText(40, 180, 'TSS24.BF2', 1, 1, 'g测试数字12345678');
command.setText(40, 220, 'TSS24.BF2', 1, 1, 'f测试数字12345678');
command.setText(40, 260, 'TSS24.BF2', 1, 1, 'e测试数字12345678');
command.setText(40, 300, 'TSS24.BF2', 1, 1, 'd测试数字12345678');
command.setText(40, 340, 'TSS24.BF2', 1, 1, 'c测试数字12345678');
command.setText(40, 380, 'TSS24.BF2', 1, 1, 'b测试数字12345678');
command.setQR(300, 180, 'L', 8, 'A', 'www.smarnet.cc佳博智汇');
uni.canvasGetImageData({
canvasId: 'edit_area_canvas',
x: 0,
y: 0,
width: canvasWidth,
height: canvasHeight,
success: function (res) {
command.setBitmap(60, 0, 1, res)
},
complete: function () {
command.setPagePrint()
state.isLabelSend = true;
prepareSend(command.getData())
}
})
}
const printNumBindChange = (res: any) => {
let index = res.detail.value
let num = state.printNum[index]
state.printNumIndex = index;
state.printerNum = num;
}
const buffBindChange = (res: any) => {
let index = res.detail.value
let time = state.buffSize[index]
state.buffIndex = index;
state.oneTimeData = time;
}
//准备发送,根据每次发送字节数来处理分包数量
const prepareSend = (buff: any[]) => {
console.log(buff.length, 'buff.length');
let time = state.oneTimeData
let looptime = (Number(buff.length) / Number(time));
let lastData = (Number(buff.length) % Number(time));
console.log(looptime + "---" + lastData)
state.looptime = looptime + 1;
state.lastData = lastData;
state.currentTime = 1;
Send(buff)
}
//分包发送
const Send = (buff: any) => {
let {
currentTime,
looptime: loopTime,
lastData,
oneTimeData: onTimeData,
printerNum: printNum,
currentPrint } = state;
let buf;
let dataView;
if (currentTime < loopTime) {
buf = new ArrayBuffer(onTimeData)
dataView = new DataView(buf)
for (var i = 0; i < onTimeData; ++i) {
dataView.setUint8(i, buff[(currentTime - 1) * onTimeData + i])
}
} else {
buf = new ArrayBuffer(lastData)
dataView = new DataView(buf)
for (var i = 0; i < lastData; ++i) {
dataView.setUint8(i, buff[(currentTime - 1) * onTimeData + i])
}
}
console.log("第" + currentTime + "次发送数据大小为:" + buf.byteLength)
let BLEInformation = blueTooth.BLEInformation
plus.bluetooth.writeBLECharacteristicValue({
deviceId: BLEInformation.deviceId,
serviceId: BLEInformation.writeServiceId,
characteristicId: BLEInformation.writeCharaterId,
value: buf,
success: function (res) {
console.log(res)
},
fail: function (e) {
console.log(e)
},
complete: function () {
currentTime++
if (currentTime <= loopTime) {
state.currentTime = currentTime;
Send(buff)
} else {
uni.showToast({
title: '已打印第' + currentPrint + '张',
})
if (currentPrint == printNum) {
state.looptime = 0;
state.lastData = 0;
state.currentTime = 1;
state.isReceiptSend = false;
state.isLabelSend = false;
state.currentPrint = 1;
} else {
currentPrint++;
state.currentPrint = currentPrint;
state.currentTime = 1;
Send(buff)
}
}
}
})
}
defineExpose({
...toRefs(state)
})
</script>
<style lang = "scss" scoped>
.input {
text-align: top;
width: 90%;
height: 150px;
margin-left: 4%;
margin-right: 4%;
margin-top: 10px;
margin-bottom: 12px;
border: 1px solid slategray;
}
.receiver_info_scroll_view {
width: 90%;
height: 200px;
margin-left: 4%;
margin-right: 4%;
margin-top: 10px;
margin-bottom: 25px;
border: 1px solid black;
}
.result {
width: 90%;
height: 150px;
border: 1px solid black;
margin-left: 4%;
margin-bottom: 4%;
margin-top: 5%;
}
button {
width: 90%;
margin-left: 5%;
margin-right: 5%;
}
.switch {
float: right;
margin-right: 20px;
margin-bottom: 16px;
}
text {
color: #fff;
display: block;
}
input {
color: gainsboro;
float: left;
}
.v_net_ssid {
width: 100%;
background: #fff;
}
.v_net_passw {
width: 100%;
background: antiquewhite;
}
.swiper {
width: 100%;
height: 100%;
}
</style> -->
\ No newline at end of file
......@@ -17,6 +17,7 @@ import { ref, onMounted } from 'vue'
import { getMenuTree } from '@/api/apply';
import headers from '@/components/header/index.vue'
const list = [{
image: 'https://cdn.uviewui.com/uview/swiper/1.jpg',
title: '昨夜星辰昨夜风,画楼西畔桂堂东'
......@@ -30,7 +31,7 @@ const list = [{
title: '谁念西风独自凉,萧萧黄叶闭疏窗,沉思往事立残阳'
}]
const menuList = ref()
const toBlueTooth = () => uni.navigateTo({ url: '/pages/blueTooth/index' })
// const toBlueTooth = () => uni.navigateTo({ url: '/pages/blueTooth/blueTooth' })
let swiperHeight = ref('250')
const tapGridItem = (row: any) => {
......
@font-face {
font-family: "custom-icon";
/* Project id 3607036 */
src: url('https://at.alicdn.com/t/c/font_3607036_y4hl42aa2g.woff2?t=1686627317404') format('woff2'),
url('https://at.alicdn.com/t/c/font_3607036_y4hl42aa2g.woff?t=1686627317404') format('woff'),
url('https://at.alicdn.com/t/c/font_3607036_y4hl42aa2g.ttf?t=1686627317404') format('truetype');
}
.custom-icon {
font-family: "custom-icon" !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.custom-icon-lanya1:before {
content: "\e65f";
}
.custom-icon-lanya:before {
content: "\ec4a";
}
.custom-icon-fujian:before {
content: "\e601";
}
.custom-icon-shangchuandaochu:before {
content: "\e8c6";
}
.custom-icon-shouyefill:before {
content: "\e750";
}
.custom-icon-sandiantu:before {
content: "\e679";
}
.custom-icon-tubiao-zhexiantu:before {
content: "\eb96";
}
.custom-icon-shezhixitongshezhigongnengshezhishuxing:before {
content: "\e795";
}
.custom-icon-caidan1:before {
content: "\e653";
}
.custom-icon-bingtu:before {
content: "\e6bb";
}
.custom-icon-shujudaping:before {
content: "\e742";
}
.custom-icon-zhuzhuangtu:before {
content: "\e650";
}
.custom-icon-list2:before {
content: "\e655";
}
.custom-icon-caidan:before {
content: "\e652";
}
.custom-icon-erweima:before {
content: "\e6bd";
}
.custom-icon-shuxingguanli:before {
content: "\e625";
}
.custom-icon-line-barcodeboxtiaoxingma-02:before {
content: "\e717";
}
.custom-icon-Icon_kebianjibiaoge:before {
content: "\e60b";
}
.custom-icon-sousuo:before {
content: "\e600";
}
.custom-icon-dingdan:before {
content: "\e737";
}
.custom-icon-wodeyushe:before {
content: "\e633";
}
.custom-icon-dingdan-copy:before {
content: "\e738";
}
.custom-icon-sousuo-copy:before {
content: "\e739";
}
.custom-icon-wodeyushe-copy:before {
content: "\e73a";
}
\ No newline at end of file
@font-face {
font-family: "iconfont";
/* Project id 3968711 */
src: url('https://at.alicdn.com/t/c/font_3968711_3t9kuqee2v2.eot?t=1681376908623');
/* IE9 */
src: url('https://at.alicdn.com/t/c/font_3968711_3t9kuqee2v2.eot?t=1681376908623#iefix') format('embedded-opentype'),
/* IE6-IE8 */
url('https://at.alicdn.com/t/c/font_3968711_3t9kuqee2v2.woff2?t=1681376908623') format('woff2'),
url('https://at.alicdn.com/t/c/font_3968711_3t9kuqee2v2.woff?t=1681376908623') format('woff'),
url('https://at.alicdn.com/t/c/font_3968711_3t9kuqee2v2.ttf?t=1681376908623') format('truetype'),
url('https://at.alicdn.com/t/c/font_3968711_3t9kuqee2v2.svg?t=1681376908623#iconfont') format('svg');
}
.iconfont {
font-family: "iconfont" !important;
font-family: "custom-icon";
/* Project id 3607036 */
src:
url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAA+UAAsAAAAAH/gAAA9EAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHFQGYACGQgqsMKMoATYCJANgCzIABCAFhQsHgngbehozozaTtHJJ9n9I4IZMeA21pwCKkEKolsymWtAgC+aTNq33SniueU3vaYrTwS6Wwg3SI9lrJxXzFw5eM5SSB7412p/dOTOPmCTR6JKIeBNLhUeiaScksTQLnmgnw9M2/8HBBBwHJ+YRbQXHAicWJzhXBmdFcWtcZGDt/1aX0Ww/ZF6d+ZKdXN+THGpAx9j1A25/REMBOYu0SqssB1oOOUXMXRmcc5ufD/zf1CXTSp7aKTj+Wl5x7SmODKlj5WzpCQS2ybhfxV5txR4gQP2d/z0DBRAw736m7T8EVzvguO15sib57UF+Sh/KkHJGAO7kAKjHI0ChAO2kPTU5KSeMn+rcOjS+XSkTEj3GZn+wCnksjEfEe4c5lnE7AirN2yjb/rrrEPgyXLsKFTnrBuLRw2V/7gTGWBY1tUG5oRR72piHp0rI7mVnAU+Crx9+UQUGmZKcc0X7zu447eBz8DZm5Bol/4Q0NxW0nqEEOaZbpmSN+mColgs8HZBK1buLvgFgXL+oPIVUlUZgYiUgZGkxlPYVLgUXWWzLvx9/s+J3zJEAasj4oY6ZdScTjJtkQ04PvngpNMk1qteiWq0KNTb9T16lOg2atWrSpkqJclGZjFCKDFINYV6ynQQ4oIlEAeQke0AjSQmoJ2GAFlIsoJoUD6glJQAqSASghpQFCKQWQClpCFBJ2geoo3ABNFCMATRTjAW0UmgATRTBgjK6SBBVgS4WRCWgWw6Acr4fB0R+rbArc0Zp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QHibqP147+RVANfJu8JnbvYKT7mNaoB/htDy2elvwN/JHLLqDk6UeO1pyW3hN7hGKur3+0BT//rGB9jh4LydZ3MskWWi/L4AMioeLMuJKWqY/kcYoNE2rsyzNStrYAAAAAA==') format('woff2');
}
.custom-icon {
font-family: "custom-icon" !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-yiruwenjianjia:before {
content: "\e648";
}
.icon-yichuwenjianjia:before {
content: "\e647";
}
.icon-qitachuku:before {
content: "\e613";
}
.icon-qitaruku:before {
content: "\e614";
}
.icon-navicon-kcpdd:before {
.custom-icon-lanya1:before {
content: "\e65f";
}
.icon-dayin:before {
content: "\e609";
.custom-icon-lanya:before {
content: "\ec4a";
}
.icon-chuku:before {
.custom-icon-fujian:before {
content: "\e601";
}
.icon-ruku:before {
content: "\e606";
.custom-icon-shangchuandaochu:before {
content: "\e8c6";
}
.icon-dayinji:before {
content: "\e618";
.custom-icon-shouyefill:before {
content: "\e750";
}
.icon-kucunpandian-:before {
content: "\e646";
.custom-icon-sandiantu:before {
content: "\e679";
}
.icon-dagou:before {
content: "\e782";
.custom-icon-tubiao-zhexiantu:before {
content: "\eb96";
}
.icon-chuku1:before {
content: "\e60a";
.custom-icon-shezhixitongshezhigongnengshezhishuxing:before {
content: "\e795";
}
.icon-tuihuo:before {
content: "\e649";
.custom-icon-caidan1:before {
content: "\e653";
}
.icon-xingtuxuetang-dayin-:before {
content: "\e605";
.custom-icon-bingtu:before {
content: "\e6bb";
}
.icon-dayin1:before {
content: "\e718";
.custom-icon-shujudaping:before {
content: "\e742";
}
.icon-yuancailiaotuiliaoshangjia:before {
content: "\e600";
.custom-icon-zhuzhuangtu:before {
content: "\e650";
}
.icon-tubiaozhizuomoban-01:before {
content: "\e636";
.custom-icon-list2:before {
content: "\e655";
}
.icon-zizhudayindayin:before {
content: "\e607";
.custom-icon-caidan:before {
content: "\e652";
}
.icon-shengchantuiliaobeifen2x:before {
content: "\e604";
.custom-icon-erweima:before {
content: "\e6bd";
}
.icon-caidanlan-shengchan-shengchanruku:before {
content: "\e661";
.custom-icon-shuxingguanli:before {
content: "\e625";
}
.icon-tuiliaojilu:before {
content: "\e651";
.custom-icon-line-barcodeboxtiaoxingma-02:before {
content: "\e717";
}
.icon-shengchanlingliao:before {
content: "\e657";
.custom-icon-Icon_kebianjibiaoge:before {
content: "\e60b";
}
.custom-icon-sousuo:before {
content: "\e600";
}
.icon-jianyandan:before {
content: "\e68b";
.custom-icon-dingdan:before {
content: "\e737";
}
.icon-dayin2:before {
content: "\eca6";
.custom-icon-wodeyushe:before {
content: "\e633";
}
.icon-dingliaoruku:before {
content: "\e6f9";
.custom-icon-dingdan-copy:before {
content: "\e738";
}
.icon-caigouruku:before {
content: "\e6fa";
.custom-icon-sousuo-copy:before {
content: "\e739";
}
.icon-tiaomachaxun:before {
content: "\e617";
.custom-icon-wodeyushe-copy:before {
content: "\e73a";
}
\ No newline at end of file
import { ref, reactive } from 'vue'
import { useBlueTooth } from '@/store/modules/bluetooth';
export const useBlueTooths = () => {
const blueTooth = useBlueTooth()
const BLEInformation = reactive({
serviceId: 0,
writeCharacter: false,
readCharacter: false,
notifyCharacter: false,
services: '',
})
const blueToothList = ref([] as any)
const services = ref([] as any)
// 封装uniapp的api
const uniAsyncPromise = (name: string, options?: any): Promise<any> => {
const uniApi: any = uni
return new Promise((resolve, reject) => {
uniApi[name]({
...options,
success: function (res: any) {
resolve(res)
},
fail: function (res: any) {
reject(res)
},
})
})
}
const startSearch = () => {
uniAsyncPromise('openBluetoothAdapter').then(() => {
uniAsyncPromise('getBluetoothAdapterState').then((res: any) => {
// 蓝牙适配器是否可用
if (res.available) {
// 蓝牙适配器是否可用
if (res.available) {
// 是否正在搜索设备
if (res.discovering)
return uni.showToast({ title: '正在搜索附近打印机设备', icon: 'none' })
//获取蓝牙设备信息
getBluetoothDevices()
} else uni.showModal({ title: '提示', content: '本机蓝牙不可用' })
}
})
})
}
const getBluetoothDevices = async () => {
try {
await startBluetoothDeviceDiscovery();
await wait(4000);
await fillBluetoothDevices();
} catch (e) {
console.log("getBluetoothDevices Error:", e);
}
finally {
await stopBluetoothDeviceDiscovery();
await uni.hideLoading()
}
};
// 开始搜索蓝牙设备
const startBluetoothDeviceDiscovery = async () => {
uni.showLoading({ title: '扫描中' })
await new Promise((resolve, reject) => {
uni.startBluetoothDevicesDiscovery({
success: resolve,
fail: reject,
});
});
plus.bluetooth.onBluetoothDeviceFound(onBluetoothDeviceFound);
};
// 监听蓝牙设备
const onBluetoothDeviceFound = (result: any) => {
const arr = blueToothList.value;
const devices: any[] = [];
const listArr = result.devices;
for (let i = 0; i < listArr.length; ++i) {
if (listArr[i].name && listArr[i].name !== "未知设备") {
const arrNew = arr.filter(
(item: any) => item.deviceId === listArr[i].deviceId
);
if (arrNew.length === 0) devices.push(listArr[i]);
}
}
blueToothList.value = arr.concat(devices);
console.log('onBluetoothDeviceFound', blueToothList.value);
};
// 填充蓝牙设备列表
const fillBluetoothDevices = async () => {
await new Promise((resolve: Function) => {
plus.bluetooth.getBluetoothDevices({
success: (res: any) => {
const devices: any[] = [];
const listArr = res.devices;
for (let i = 0; i < listArr.length; ++i) {
if (listArr[i].name && listArr[i].name !== "未知设备") {
devices.push(listArr[i]);
}
}
blueToothList.value = devices
console.log("fillBluetoothDevices:", blueToothList.value);
resolve();
},
});
});
};
// 等待
const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
const chooseBluetooth = (deviceId: string) => {
let BLEInformation = blueTooth.BLEInformation
stopBluetoothDeviceDiscovery()
BLEInformation.serviceId = 0
BLEInformation.writeCharacter = false
BLEInformation.readCharacter = false
BLEInformation.notifyCharacter = false
uni.showLoading({ title: '正在连接' })
plus.bluetooth.createBLEConnection({
deviceId,
success(res: any) {
console.log('createBLEConnection success:', res);
BLEInformation.deviceId = deviceId;
blueTooth.$patch({
BLEInformation
})
uni.hideLoading()
setTimeout(() => {
getSeviceId();
});
},
fail(e) {
errorCodeTip(e.errCode);
uni.hideLoading();
}
})
}
const getSeviceId = async () => {
const { deviceId } = blueTooth.BLEInformation;
console.log('BLEInformation.deviceId:', deviceId);
// 等待1.5秒后获取蓝牙设备服务信息
await new Promise(resolve => setTimeout(resolve, 1500));
// 获取蓝牙设备服务信息并更新服务列表
const { services: s } = await new Promise((resolve, reject) => {
plus.bluetooth.getBLEDeviceServices({
deviceId,
success: resolve,
fail: reject,
});
});
services.value = s;
getCharacteristics();
}
const getCharacteristics = async () => {
const num = BLEInformation.serviceId
const { deviceId } = blueTooth.BLEInformation;
// 获取蓝牙设备特征值信息
const { characteristics } = await new Promise((resolve, reject) => {
plus.bluetooth.getBLEDeviceCharacteristics({
deviceId,
serviceId: services.value[num].uuid,
success: resolve,
fail: reject,
});
});
// 遍历特征值列表,获取写、读、通知特征值ID和服务ID
for (let i = 0; i < characteristics.length; i++) {
const { uuid, properties } = characteristics[i];
// console.log(uuid, properties, 'characteristics[i]');
if (!BLEInformation.notifyCharacter && properties.notify) {
blueTooth.BLEInformation.notifyCharaterId = uuid;
blueTooth.BLEInformation.notifyServiceId = services.value[num].uuid;
blueTooth.$patch({
BLEInformation: blueTooth.BLEInformation
})
BLEInformation.notifyCharacter = true;
}
if (!BLEInformation.writeCharacter && properties.write) {
blueTooth.BLEInformation.writeCharaterId = uuid;
blueTooth.BLEInformation.writeServiceId = services.value[num].uuid;
blueTooth.$patch({
BLEInformation: blueTooth.BLEInformation
})
BLEInformation.writeCharacter = true;
}
if (!BLEInformation.readCharacter && properties.read) {
blueTooth.BLEInformation.readCharaterId = uuid;
blueTooth.BLEInformation.readServiceId = services.value[num].uuid;
blueTooth.$patch({
BLEInformation: blueTooth.BLEInformation
})
BLEInformation.readCharacter = true;
}
}
// 如果找不到对应的写、读、通知特征值,则继续查找下一个服务的特征值
if (!BLEInformation.writeCharacter ||
!BLEInformation.notifyCharacter ||
!BLEInformation.readCharacter) {
BLEInformation.serviceId = num + 1;
if (num === services.length - 1) {
console.log('找不到该读写的特征值');
uni.showModal({
title: '提示',
content: '找不到该读写的特征值',
});
} else {
await getCharacteristics();
}
} else openControl();
}
const openControl = () => {
uni.navigateBack({ delta: 1 })
}
const stopBluetoothDeviceDiscovery = (deviceId?: string) => {
const options = {
success: (res: any) => {
console.log('stop:', res);
},
fail: (e: any) => {
console.log('stop:', e);
errorCodeTip(e.errCode);
},
} as any;
if (deviceId) {
options.deviceId = deviceId;
}
uni.stopBluetoothDevicesDiscovery(options);
};
// 错误码提示
const errorCodeTip = (code: number) => {
const errorTips: any = {
0: "正常",
10000: "未初始化蓝牙适配器",
10001: "当前蓝牙适配器不可用",
10002: "没有找到指定设备",
10003: "连接失败",
10004: "没有找到指定服务",
10005: "没有找到指定特征值",
10006: "当前连接已断开",
10007: "当前特征值不支持此操作",
10008: "其余所有系统上报的异常",
10009: "Android 系统特有,系统版本低于 4.3 不支持 BLE"
}
if (errorTips[code]) {
uni.showToast({
title: errorTips[code],
icon: 'none',
});
}
}
return {
blueToothList,
startSearch,
chooseBluetooth,
uniAsyncPromise,
stopBluetoothDeviceDiscovery
}
}
import tsplInstruct from './instruct'
const dpi: number = 203
let command = tsplInstruct()
const dot = (pt: number) => {
return (pt * dpi) / 72
}
const setLevel = (level: number | string) => {
switch (level) {
case '1':
level = 'L'
break;
case '2':
level = 'H'
break;
case '3':
level = 'Q'
break;
default:
level = 'M'
break;
}
return level
}
export const generateInstruct = (panels: any, blueTooth: any) => {
command.clearCommand()
command.setSize(panels.width, panels.height) //设定卷标纸的宽度和长度
command.setGap(2) // 定义两张卷标纸间的垂直间距距离
command.setCls(); //清除打印机缓存
panels.printElements.map((item: any) => {
if (item.printElementType.type === 'text') {
switch (item.options.textType) {
case 'qrcode':
case 'barcode':
item.printElementType.type = item.options.textType
break
}
}
})
panels.printElements.map((item: any) => {
let {
left,
top,
width,
height,
fontSize,
field,
title,
hideTitle,
textAlign,
textContentVerticalAlign,
fontWeight,
lineHeight,
testData,
barcodeMode,
qrCodeLevel
} = item.options
left = dot(left)
top = dot(top)
width = dot(width)
height = dot(height)
lineHeight = dot(lineHeight || fontSize || 9)
// console.log(
// left,
// top,
// width,
// height,
// fontSize,
// field,
// title,
// hideTitle,
// textAlign,
// textContentVerticalAlign,
// fontWeight,
// lineHeight,
// testData,
// barcodeMode,
// qrCodeLevel);
switch (item.printElementType.type) {
case 'text':
command.setText(left, top, 'TSS24.BF2', 1, 1, `${hideTitle ? '' : title || ''}${!hideTitle && field ? ':' : ''}${testData || ''}`)
break;
case 'qrcode':
command.setQR(left, top, setLevel(qrCodeLevel), 7, 'A', testData)
break;
case 'barcode':
command.setBarCode(left, top, '128', height, `${hideTitle ? 0 : 1}`, 2, 2, testData);
break;
}
})
command.setPagePrint()
const uint8Array = new Uint8Array(command.getData());
let opt = {
deviceId: blueTooth.BLEInformation.deviceId,
serviceId: blueTooth.BLEInformation.writeServiceId,
characteristicId: blueTooth.BLEInformation.writeCharaterId,
value: uint8Array,
lasterSuccess: onSendSuccess,
onceLength: 20,
};
sendDataToDevice(opt)
}
export const sendDataToDevice = (options: any) => {
return new Promise((resolve, reject) => {
let byteLength = options.value.byteLength
console.log(byteLength, 'byteLength');
//这里默认一次20个字节发送
const speed = options.onceLength //20;
if (byteLength > 0) {
uni.writeBLECharacteristicValue({
...options,
value: options.value.slice(0, byteLength > speed ? speed : byteLength),
success(res) {
if (byteLength > speed) {
resolve(
sendDataToDevice({
...options,
value: options.value.slice(speed, byteLength),
})
)
} else {
options.lasterSuccess && options.lasterSuccess()
resolve(null)
}
},
fail(res) {
reject()
},
})
}
})
}
const onSendSuccess = () => { }
\ No newline at end of file
import { TextEncoder } from 'text-encoding'
export const createNew = () => {
const tsplInstruct = () => {
var jpPrinter = {} as any
var data = ''
var command = [] as any
......@@ -136,7 +136,7 @@ export const createNew = () => {
jpPrinter.addCommand(data)
}
jpPrinter.setReference = function (x: any, y: any) {
jpPrinter.setReference = function (x: number, y: number) {
//设置坐标原点,与打印方向有关
data = 'REFERENCE ' + x + ',' + y + '\r\n'
jpPrinter.addCommand(data)
......@@ -166,7 +166,7 @@ export const createNew = () => {
jpPrinter.addCommand(data)
}
jpPrinter.setBar = function (x: any, y: any, width: any, height: any) {
jpPrinter.setBar = function (x: number, y: number, width: any, height: any) {
//绘制线条
data = 'BAR ' + x + ',' + y + ',' + width + ',' + height + '\r\n'
jpPrinter.addCommand(data)
......@@ -211,7 +211,7 @@ export const createNew = () => {
jpPrinter.addCommand(data)
}
jpPrinter.setText = function (x: any, y: any, font: any, x_: any, y_: any, str: any) {
jpPrinter.setText = function (x: number, y: number, font: string, x_: number, y_: number, str: string) {
//打印文字
data =
'TEXT ' +
......@@ -233,7 +233,7 @@ export const createNew = () => {
jpPrinter.addCommand(data)
}
jpPrinter.setQR = function (x: any, y: any, level: any, width: any, mode: any, content: any) {
jpPrinter.setQR = function (x: number, y: number, level: string, width: any, mode: any, content: string) {
//打印二维码
data =
'QRCODE ' +
......@@ -255,8 +255,8 @@ export const createNew = () => {
}
jpPrinter.setBarCode = function (
x: any,
y: any,
x: number,
y: number,
codetype: any,
height: any,
readable: any,
......@@ -288,7 +288,7 @@ export const createNew = () => {
jpPrinter.addCommand(data)
}
jpPrinter.setBitmap = function (x: any, y: any, mode: any, res: any) {
jpPrinter.setBitmap = function (x: number, y: number, mode: any, res: any) {
//添加图片,res为画布参数
// console.log(res)
var width: any = (((Number(res.width) + 7) / 8) * 8) / 8
......@@ -353,5 +353,10 @@ export const createNew = () => {
jpPrinter.getData = function () {
return command
}
jpPrinter.clearCommand = function () {
command = []
}
return jpPrinter
}
export default tsplInstruct;
const CONFIG: any = {
// 开发环境配置
development: {
assetsPath: 'http://192.168.60:81', // 静态资源路径
baseUrl: 'http://192.168.0.46', // 后台接口请求地址
assetsPath: 'http://192.168.1.83', // 静态资源路径
baseUrl: 'http://192.168.1.83', // 后台接口请求地址
// baseUrl: 'http://192.168.0.8', // 后台接口请求地址
hostUrl: 'http://192.168.0.60:81', // H5地址(前端运行地址)
hostUrl: 'http://192.168.1.83', // H5地址(前端运行地址)
websocketUrl: '', // websocket服务端地址
},
// 生产环境配置
......
......@@ -45,11 +45,11 @@ export default defineConfig({
https: false, // 默认用http方式
proxy: {
'/lowcodeplatform-system': {
target: 'http://192.168.0.58',
target: 'http://192.168.1.83',
// target: 'http://192.168.0.8',
},
'/wms-system': {
target: 'http://192.168.0.58',
target: 'http://192.168.1.83',
// target: 'http://192.168.0.8',
},
},
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -1908,6 +1908,11 @@ dashdash@^1.12.0:
dependencies:
assert-plus "^1.0.0"
dayjs@^1.11.8:
version "1.11.8"
resolved "https://registry.npmmirror.com/dayjs/-/dayjs-1.11.8.tgz#4282f139c8c19dd6d0c7bd571e30c2d0ba7698ea"
integrity sha512-LcgxzFoWMEPO7ggRv1Y2N31hUf2R0Vj7fuy/m+Bg1K8rr+KAs1AEy4y9jd5DXe8pbHgX+srkHNS7TH6Q6ZhYeQ==
debug@2.6.9, debug@^2.2.0, debug@^2.3.3:
version "2.6.9"
resolved "https://registry.npmmirror.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论