按钮位置调整方便操作 打印取消一个无法使用的uf8库 预览测试打印成功

This commit is contained in:
QunSheng Lin 2025-04-15 13:57:01 +08:00
parent 9116015e19
commit 1e0f4d35a2
5 changed files with 40 additions and 38 deletions

View File

@ -13,6 +13,15 @@
</block> </block>
</view> </view>
</view> </view>
<view class="page-section-demo switch-list">
<view class="switch-item">
<!-- checked:是否被选中初始状态默认开关 onChangechecked 改变时触发event.detail={value:checked}。 -->
启动
<switch onChange="switchopenBluetoothAdapter" aria-label="{{switchopenBluetoothAdapter ? 'switch opened' : 'switch closed'}}" />
搜索
<switch onChange="startBluetoothDevicesDiscovery" aria-label="{{startBluetoothDevicesDiscovery ? 'switch opened' : 'switch closed'}}" />
</view>
</view>
<view class="page"> <view class="page">
<view class="page-description"></view> <view class="page-description"></view>
<view class="page-section"> <view class="page-section">
@ -41,15 +50,6 @@
</view> </view>
</view> </view>
<progress percent="{{percent}}" active/> <progress percent="{{percent}}" active/>
<view class="page-section-demo switch-list">
<view class="switch-item">
<!-- checked:是否被选中初始状态默认开关 onChangechecked 改变时触发event.detail={value:checked}。 -->
启动
<switch onChange="switchopenBluetoothAdapter" aria-label="{{switchopenBluetoothAdapter ? 'switch opened' : 'switch closed'}}" />
搜索
<switch onChange="startBluetoothDevicesDiscovery" aria-label="{{startBluetoothDevicesDiscovery ? 'switch opened' : 'switch closed'}}" />
</view>
</view>
<view class="page"> <view class="page">
<view class="page-description"></view> <view class="page-description"></view>
<view class="page-section"> <view class="page-section">

View File

@ -154,8 +154,13 @@ Component({
if (item.fineCode3Names && Array.isArray(item.fineCode3Names)) { if (item.fineCode3Names && Array.isArray(item.fineCode3Names)) {
// 遍历 fineCode3Names 数组 // 遍历 fineCode3Names 数组
item.fineCode3Names.forEach((value) => { item.fineCode3Names.forEach((value) => {
// 将可能的浮点数转换为文本
const nameValue = typeof item.name === 'number'? item.name.toString() : item.name;
const colorValue = typeof item.color_id_2[1] === 'number'? item.color_id_2[1].toString() : item.color_id_2[1];
const codeValue = typeof value === 'number'? value.toString() : value;
// 拼接要打印的内容 // 拼接要打印的内容
value = `name ${item.name[1]}.color ${item.color_id_2[1]}.code ${value}`; value = `name ${nameValue}.color ${colorValue}.code ${codeValue}`;
// 去除中文和[]符号 // 去除中文和[]符号
value = value.replace(/[\u4e00-\u9fa5\[\]]/g, ''); value = value.replace(/[\u4e00-\u9fa5\[\]]/g, '');
allValuesToPrint.push(value); allValuesToPrint.push(value);
@ -165,6 +170,7 @@ Component({
} }
const totalCodes = allValuesToPrint.length; const totalCodes = allValuesToPrint.length;
let sentCodes = 0; let sentCodes = 0;
let totalChunks = 0; let totalChunks = 0;
@ -180,8 +186,10 @@ Component({
TEXT 20,350,"2",0,1,1,"${code}" TEXT 20,350,"2",0,1,1,"${code}"
PRINT 1,1 PRINT 1,1
`; `;
const encoder = new TextEncoder('utf-8');
const commandBuffer = encoder.encode(command); // const encoder = new TextEncoder('utf-8');
// const commandBuffer = encoder.encode(command);
const commandBuffer = Buffer.from(command, 'utf-8');
const hexValue = Array.from(commandBuffer) const hexValue = Array.from(commandBuffer)
.map(byte => byte.toString(16).padStart(2, '0')) .map(byte => byte.toString(16).padStart(2, '0'))
.join(''); .join('');
@ -211,9 +219,9 @@ Component({
TEXT 20,350,"2",0,1,1,"${currentCode}" TEXT 20,350,"2",0,1,1,"${currentCode}"
PRINT 1,1 PRINT 1,1
`; `;
const encoder = new TextEncoder('utf-8'); // const encoder = new TextEncoder('utf-8');
const commandBuffer = encoder.encode(command); // const commandBuffer = encoder.encode(command);
const commandBuffer = Buffer.from(command, 'utf-8');
// 将二进制数据转换为 hex 编码 // 将二进制数据转换为 hex 编码
const hexValue = Array.from(commandBuffer) const hexValue = Array.from(commandBuffer)
.map(byte => byte.toString(16).padStart(2, '0')) .map(byte => byte.toString(16).padStart(2, '0'))

View File

@ -1,9 +1,3 @@
{ {
"component": true, "component": true
"properties": {
"printdata": {
"type": "Object",
"value": {}
}
}
} }

View File

@ -1,7 +1,7 @@
<view> <view>
<bluetooth-component printdata="{{printdata}}" /> <bluetooth-component/>
<view a:for="{{fineCode3Names}}" a:key="*this" class="order-item" data-info="{{item.fineCode}}"> <view a:for="{{fineCode3Names}}" a:key="*this" class="order-item" data-info="{{item.fineCode}}">
<image class="image" src="../../../../../../../static/images/胜佳纺织.png" /> <image class="image"/>
<view class="order-details"> <view class="order-details">
name:{{item.name || '无货号'}}. color: {{item.color_id_2 || '无色号'}} . code: {{item.fineCode || '无细码'}} name:{{item.name || '无货号'}}. color: {{item.color_id_2 || '无色号'}} . code: {{item.fineCode || '无细码'}}
</view> </view>

View File

@ -8,7 +8,7 @@
</view> </view>
<navigator <navigator
open-type="navigate" open-type="navigate"
url="/pages/deal/saleOrder/kanban/saleOrderKanban" url="/pages/deal/deal"
class="confirm-button" class="confirm-button"
> >
返回 返回