From fc1a5059e586ab6d41fc3ec3bfacb727accc4765 Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期一, 15 十二月 2025 14:52:02 +0800
Subject: [PATCH] 核磅录入打印装箱单
---
pages/wareHouse/nuclearScale/nuclearscalerecord.vue | 602 +++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 408 insertions(+), 194 deletions(-)
diff --git a/pages/wareHouse/nuclearScale/nuclearscalerecord.vue b/pages/wareHouse/nuclearScale/nuclearscalerecord.vue
index d80cbfe..c70221d 100644
--- a/pages/wareHouse/nuclearScale/nuclearscalerecord.vue
+++ b/pages/wareHouse/nuclearScale/nuclearscalerecord.vue
@@ -2,15 +2,18 @@
<view class="page">
<view class="finishProductIn-locno-bg" />
<u-navbar
- title="鏍哥璁板綍"
+ title=""
:background="background"
:border-bottom="false"
:title-bold="true"
title-color="#000"
back-icon-color="#000"
>
- <view class="navbar-right" slot="right" @click="goPrintAll">
- 鍏ㄩ儴鎵撳嵃
+ <view class="navbar-right" slot="right">
+ <text class="bluetooth-btn" @click="searchDevice">
+ {{ connectedDevice ? `宸茶繛鎺ワ細${connectedDevice.name}` : "杩炴帴钃濈墮" }}
+ </text>
+ <text class="print-all-btn" @click="goPrintAll">鍏ㄩ儴鎵撳嵃</text>
</view>
</u-navbar>
<view class="wrap">
@@ -45,7 +48,9 @@
@click="selectNo(item)"
>
<view class="content-header">
- <view class="content-header-title">{{ index + 1 }}</view>
+ <view class="content-header-title">{{
+ list.length - index
+ }}</view>
</view>
<view class="content-body">
<view class="row-list">
@@ -54,7 +59,7 @@
<view class="_label-name">鎵规鍙凤細</view>
</view>
<view class="_content">
- {{ item.outBatchNo }}
+ {{ item.batchNo }}
</view>
</view>
<view class="row-list">
@@ -63,7 +68,7 @@
<view class="_label-name">浜у搧鎻忚堪锛�</view>
</view>
<view class="_content">
- {{ item.netWeight }}
+ {{ item.partDescription }}
</view>
</view>
<view class="row-list">
@@ -81,7 +86,7 @@
<view class="_label-name">姣涢噸锛�</view>
</view>
<view class="_content">
- {{ item.grossWeight }}
+ {{ item.newGrossWeight }}
</view>
</view>
<view class="row-list">
@@ -90,7 +95,7 @@
<view class="_label-name">鐩橀噸锛�</view>
</view>
<view class="_content">
- {{ item.trayWeight }}
+ {{ item.newWeight }}
</view>
</view>
<view class="row-list">
@@ -99,7 +104,7 @@
<view class="_label-name">鍑�閲嶏細</view>
</view>
<view class="_content">
- {{ item.value5 }}
+ {{ item.newNetWeight }}
</view>
</view>
<view class="row-list">
@@ -108,7 +113,7 @@
<view class="_label-name">鏍哥閲嶉噺锛�</view>
</view>
<view class="_content">
- {{ item.netWeight }}
+ {{ item.verificationWeight }}
</view>
</view>
<view class="row-list">
@@ -117,7 +122,7 @@
<view class="_label-name">鍙夎溅鐩橀噸锛�</view>
</view>
<view class="_content">
- {{ item.value7 }}
+ {{ item.forkliftWeight }}
</view>
</view>
</view>
@@ -165,6 +170,8 @@
</template>
<script>
import content_bg from "@/static/custom/finishProductIn/locNoBg.png";
+import bluetooth from "@/common/bluetoothPrinter.js";
+
const jcapi = uni.requireNativePlugin("JCSDK-JCApiModule");
// 浜岀淮鐮佺被鍨�
@@ -210,7 +217,7 @@
listDevice: [], //钃濈墮璁惧鏁版嵁
printQueue: [], // 鎵撳嵃闃熷垪
printing: false, // 鏄惁姝e湪鎵撳嵃
- printDensity: 3, // 榛樿鎵撳嵃娴撳害
+ printDensity: 10, // 榛樿鎵撳嵃娴撳害
labelType: 1, // 榛樿鏍囩绫诲瀷
// 1锛氶棿闅欑焊
// 2锛氶粦鏍囩焊
@@ -220,42 +227,55 @@
printMode: 2, // 榛樿鎵撳嵃妯″紡
// 1锛氱儹鏁�
// 2锛氱儹杞嵃
- connectedDevice: null, // 宸茶繛鎺ョ殑鎵撳嵃鏈�
- connectionStatus: "disconnected", // 杩炴帴鐘舵��: disconnected, connecting, connected
+ connectedDevice: null,
+ connectionStatus: "disconnected",
printStatus: "idle", // 鎵撳嵃鐘舵��: idle, printing, error
errorMessage: "", // 閿欒淇℃伅
+ verificationNo: "",
+ failedPrintJobs: [],
};
},
- onLoad() {
- this.getlist();
- // 鍒濆鍖朣DK
- jcapi.initSDK();
- // 鐩戝惉椤电爜鍥炶皟
- jcapi.didReadPrintCountInfo(function (r) {
- console.log(r);
+ onLoad(options) {
+ this.verificationNo = JSON.parse(
+ decodeURIComponent(options.verificationNo)
+ );
+
+ bluetooth.init();
+
+ bluetooth.onChange(({ connectedDevice, connectionStatus }) => {
+ this.connectedDevice = connectedDevice;
+ this.connectionStatus = connectionStatus;
});
- // 鐩戝惉閿欒鍥炶皟
- jcapi.didReadPrintErrorInfo((r) => {
- console.log(r);
- if (r.code == 23) {
- // 鎵撳嵃鏈烘柇寮�杩炴帴
- this.connectedDevice = null;
- uni.showToast({
- icon: "none",
- title: "鎵撳嵃鏈鸿繛鎺ュ凡鏂紑锛岃閲嶆柊杩炴帴",
- duration: 2 * 1000,
- });
- } else {
- uni.showToast({
- icon: "none",
- title: JSON.stringify(r),
- duration: 2 * 1000,
- });
- }
- });
+ this.getlist();
+ },
+
+ // 椤甸潰鍗歌浇鏃朵笉涓诲姩鏂紑钃濈墮杩炴帴锛屼繚鎸佽繛鎺ョ姸鎬�
+ onUnload() {
+ // 涓嶆墽琛屾柇寮�杩炴帴鎿嶄綔锛屼繚鎸佽摑鐗欒繛鎺�
},
methods: {
+ // restoreBluetoothConnection() {
+ // try {
+ // // 浠庢湰鍦板瓨鍌ㄨ幏鍙栦箣鍓嶄繚瀛樼殑杩炴帴淇℃伅
+ // const savedConnection = uni.getStorageSync("bluetoothConnection");
+ // if (savedConnection && savedConnection.address) {
+ // console.log("灏濊瘯鎭㈠钃濈墮杩炴帴:", savedConnection);
+ // // 鐩存帴璁剧疆涓哄凡杩炴帴鐘舵�侊紝閬垮厤涓嶅繀瑕佺殑閲嶈繛
+ // // 瀹為檯杩炴帴鐘舵�佷細閫氳繃SDK鐨勫洖璋冭嚜鍔ㄦ洿鏂�
+ // this.connectedDevice = savedConnection;
+ // this.connectionStatus = "connected";
+ // console.log("钃濈墮杩炴帴鐘舵�佸凡鎭㈠");
+
+ // // 楠岃瘉杩炴帴鏄惁鐪熺殑鏈夋晥锛岄�氳繃鍙戦�佷竴涓畝鍗曠殑鍛戒护鎴栨鏌ョ姸鎬�
+ // // 杩欓噷涓嶆墽琛屽疄闄呯殑閲嶈繛鎿嶄綔锛岃�屾槸渚濊禆SDK鐨勮繛鎺ョ姸鎬佸洖璋�
+ // // 濡傛灉杩炴帴宸叉柇寮�锛孲DK浼氶�氳繃didReadPrintErrorInfo鍥炶皟閫氱煡鎴戜滑
+ // }
+ // } catch (e) {
+ // console.error("鎭㈠钃濈墮杩炴帴澶辫触:", e);
+ // this.connectionStatus = "disconnected";
+ // }
+ // },
getmoreList() {
if (this.pageSize >= this.total) {
this.status = "nomore";
@@ -268,12 +288,29 @@
}, 1000);
},
getlist() {
- this.$u.api.workReporting
- .getWorkshopOrder({
+ this.$u.api.NuclearScaleEntry.queryPacking({
+ current: this.pageNum,
+ size: this.pageSize,
+ verificationNo: this.verificationNo,
+ }).then((res) => {
+ this.list = res.data;
+ this.total = res.data.length;
+ if (this.pageSize >= this.total) {
+ this.status = "nomore";
+ } else {
+ this.status = "loadmore";
+ }
+ });
+ },
+ search(value) {
+ if (value) {
+ this.list = [];
+ this.pageSize = 10;
+ this.$u.api.NuclearScaleEntry.queryPacking({
current: this.pageNum,
size: this.pageSize,
- })
- .then((res) => {
+ moNo: value,
+ }).then((res) => {
this.list = res.data.records;
this.total = res.data.total;
if (this.pageSize >= this.total) {
@@ -282,57 +319,19 @@
this.status = "loadmore";
}
});
- },
- search(value) {
- if (value) {
- this.list = [];
- this.pageSize = 10;
- this.$u.api.workReporting
- .getWorkshopOrder({
- current: this.pageNum,
- size: this.pageSize,
- moNo: value,
- })
- .then((res) => {
- this.list = res.data.records;
- this.total = res.data.total;
- if (this.pageSize >= this.total) {
- this.status = "nomore";
- } else {
- this.status = "loadmore";
- }
- });
} else {
this.getlist();
}
},
- // 妫�鏌ヨ摑鐗欒繛鎺ョ姸鎬�
- async checkBluetoothConnection() {
- if (!this.connectedDevice) {
- this.connectionStatus = "disconnected";
- return false;
- }
-
- // 璁剧疆涓鸿繛鎺ヤ腑鐘舵��
- this.connectionStatus = "connecting";
-
- // 澧炲己杩炴帴鐘舵�佹娴�
- return new Promise((resolve) => {
- // 绠�鍖栬繛鎺ョ姸鎬佹娴嬶紝鐩存帴浣跨敤宸茶褰曠殑杩炴帴鐘舵��
- if (this.connectedDevice) {
- this.connectionStatus = "connected";
- resolve(true);
- } else {
- this.connectionStatus = "disconnected";
- uni.showToast({
- icon: "none",
- title: "鎵撳嵃鏈烘湭杩炴帴锛岃鍏堣繛鎺�",
- duration: 2000,
- });
- resolve(false);
- }
- });
+ checkBluetoothConnection() {
+ return bluetooth.isConnected();
},
+
+ // // 鐩存帴浣跨敤宸茶褰曠殑杩炴帴鐘舵�侊紝閬垮厤涓嶅繀瑕佺殑杩炴帴妫�鏌�
+ // // 瀹為檯杩炴帴鐘舵�佷細閫氳繃SDK鐨勫洖璋冭嚜鍔ㄦ洿鏂�
+ // this.connectionStatus = "connected";
+ // return true;
+ // },
// 娣诲姞鍒版墦鍗伴槦鍒�
addToPrintQueue(items) {
@@ -407,11 +406,13 @@
uni.showModal({
title: "鎻愮ず",
content: "鏄惁鎵撳嵃瑁呯鍗曪紵",
- showCancel: true,
- success: async function (res) {
+ success(res) {
if (res.confirm) {
- // 娣诲姞鍒版墦鍗伴槦鍒�
- that.addToPrintQueue(item);
+ // 鎸� batchNo 鍚堝苟
+ const sameBatchList = that.list.filter(
+ (i) => i.batchNo === item.batchNo
+ );
+ that.addToPrintQueue(sameBatchList);
}
},
});
@@ -435,14 +436,14 @@
moveHandle() {},
maskclose() {},
//鎵撳嵃浜岀淮鐮�
- async printQrCode(item) {
+ printQrCode(item) {
return new Promise(async (resolve, reject) => {
- const params = {
- rwMatlBindId: item.id
- };
+ // const params = {
+ // rwMatlBindId: item.id
+ // };
try {
- let res = await this.$u.api.dailyPaper.zongjianLabelInfo(params)
- if (!res.data) {
+ // let res = await this.$u.api.dailyPaper.zongjianLabelInfo(params)
+ if (!item) {
this.$refs.uToast.show({
title: "鏈煡璇㈠埌璇ユ爣绛句俊鎭紒",
type: "warning ",
@@ -451,8 +452,14 @@
return;
}
- // 浠嶢PI鍝嶅簲涓彁鍙栨墍闇�鏁版嵁
- const { ht, lj, ljms, fh, scdt, scph, fhdw, shdw } = res.data;
+ const ht = item.contractNo;
+ const lj = item.partNo;
+ const ljms = item.ccontrProModel;
+ const fh = item.newNetWeight;
+ const scdt = item.productionDate;
+ const scph = item.batchNo;
+ const shdw = item.customerName;
+ const fhdw = "姹熶笢鍚堥噾鎶�鏈湁闄愬叕鍙�";
// 鍒濆鍖栫敾鏉�
jcapi.initDrawingBoard({
@@ -462,7 +469,17 @@
});
// 缁樺埗浜岀淮鐮�
- const qrContent = `ht:${ht}\nlj:${lj}\nljms:${ljms}\nfh:${fh}\nscdt:${scdt}\nscph:${scph}\nfhdw:${fhdw}\nshdw:${shdw}`;
+ const qrContent = {
+ company: item.customerNo,
+ line_no: item.lineNo,
+ lot_batch_no: item.batchNo,
+ order_no: item.contractNo,
+ part_no: item.partNo,
+ total_qty: item.newNetWeight,
+ qty_arrived: item.newNetWeight,
+ release_no: item.relNo,
+ };
+
jcapi.drawLabelQrCode({
x: 43.5,
y: 2,
@@ -478,8 +495,8 @@
this.getDrawLabelLine(1, 6, 42, 0.3, 0, LineType.Solid);
this.getDrawLabelLine(1, 11, 42, 0.3, 0, LineType.Solid);
this.getDrawLabelLine(1, 16, 42, 0.3, 0, LineType.Solid);
- this.getDrawLabelLine(1, 21, 42, 0.3, 0, LineType.Solid);
- this.getDrawLabelLine(1, 27, 67, 0.3, 0, LineType.Solid);
+ this.getDrawLabelLine(1, 23, 42, 0.3, 0, LineType.Solid);
+ this.getDrawLabelLine(1, 27.5, 67, 0.3, 0, LineType.Solid);
this.getDrawLabelLine(1, 32, 67, 0.3, 0, LineType.Solid);
this.getDrawLabelLine(1, 37, 67, 0.3, 0, LineType.Solid);
this.getDrawLabelLine(1, 42, 67, 0.3, 0, LineType.Solid);
@@ -491,26 +508,263 @@
this.getDrawLabelLine(68, 1, 0.5, 46, 0, LineType.Solid); // 绔栫嚎3
// 缁樺埗鏂囨湰
- this.getDrawLabelText(3,2.5,40,8,"涓ぉ绉戞妧瑁呯娓呭崟",2.5,0,LineModeType.AutoHeight,0,0,1,1,1);
- this.getDrawLabelText(2,7,25,8,"鍚堝悓鍙�:",2.5,0,LineModeType.AutoHeight,0,0,0,1,1);
- this.getDrawLabelText(2,12,25,8,"闆朵欢鍙�:",2.5,0,LineModeType.AutoHeight,0,0,0,1,1);
- this.getDrawLabelText(2,17,25,8,"闆朵欢鎻忚堪:",2.5,0,LineModeType.AutoHeight,0,0,0,1,1);
- this.getDrawLabelText(2,22.5,25,8,"鍙戣揣/瑁呯鏁�:",2.5,0,LineModeType.AutoHeight,0,0,0,1,1);
- this.getDrawLabelText(2,27.5,25,8,"鐢熶骇鏃ユ湡:",2.5,0,LineModeType.AutoHeight,0,0,0,1,1);
- this.getDrawLabelText(2,32.5,25,8,"鐢熶骇鎵瑰彿:",2.5,0,LineModeType.AutoHeight,0,0,0,1,1);
- this.getDrawLabelText(2,37.5,25,8,"鍙戣揣鍗曚綅:",2.5,0,LineModeType.AutoHeight,0,0,0,1,1);
- this.getDrawLabelText(2,42.5,25,8,"鏀惰揣鍗曚綅:",2.5,0,LineModeType.AutoHeight,0,0,0,1,1);
+ this.getDrawLabelText(
+ 3,
+ 2.5,
+ 40,
+ 8,
+ "涓ぉ绉戞妧瑁呯娓呭崟",
+ 2.5,
+ 0,
+ LineModeType.AutoHeight,
+ 0,
+ 0,
+ 1,
+ 1,
+ 1
+ );
+ this.getDrawLabelText(
+ 2,
+ 7,
+ 25,
+ 8,
+ "鍚堝悓鍙�:",
+ 2.5,
+ 0,
+ LineModeType.AutoHeight,
+ 0,
+ 0,
+ 0,
+ 1,
+ 1
+ );
+ this.getDrawLabelText(
+ 2,
+ 12,
+ 25,
+ 8,
+ "闆朵欢鍙�:",
+ 2.5,
+ 0,
+ LineModeType.AutoHeight,
+ 0,
+ 0,
+ 0,
+ 1,
+ 1
+ );
+ this.getDrawLabelText(
+ 2,
+ 17,
+ 25,
+ 8,
+ "闆朵欢鎻忚堪:",
+ 2.5,
+ 0,
+ LineModeType.AutoHeight,
+ 0,
+ 0,
+ 0,
+ 1,
+ 1
+ );
+ this.getDrawLabelText(
+ 2,
+ 23.5,
+ 25,
+ 8,
+ "鍙戣揣/瑁呯鏁�:",
+ 2.5,
+ 0,
+ LineModeType.AutoHeight,
+ 0,
+ 0,
+ 0,
+ 1,
+ 1
+ );
+ this.getDrawLabelText(
+ 2,
+ 28.5,
+ 25,
+ 8,
+ "鐢熶骇鏃ユ湡:",
+ 2.5,
+ 0,
+ LineModeType.AutoHeight,
+ 0,
+ 0,
+ 0,
+ 1,
+ 1
+ );
+ this.getDrawLabelText(
+ 2,
+ 32.5,
+ 25,
+ 8,
+ "鐢熶骇鎵瑰彿:",
+ 2.5,
+ 0,
+ LineModeType.AutoHeight,
+ 0,
+ 0,
+ 0,
+ 1,
+ 1
+ );
+ this.getDrawLabelText(
+ 2,
+ 37.5,
+ 25,
+ 8,
+ "鍙戣揣鍗曚綅:",
+ 2.5,
+ 0,
+ LineModeType.AutoHeight,
+ 0,
+ 0,
+ 0,
+ 1,
+ 1
+ );
+ this.getDrawLabelText(
+ 2,
+ 42.5,
+ 25,
+ 8,
+ "鏀惰揣鍗曚綅:",
+ 2.5,
+ 0,
+ LineModeType.AutoHeight,
+ 0,
+ 0,
+ 0,
+ 1,
+ 1
+ );
// 濉厖鍙傛暟鍊�
- this.getDrawLabelText(11,7,30,8,ht,2.5,0,LineModeType.AutoHeight,0,0,0,0,1);
- this.getDrawLabelText(11,12,32,8,lj,2.5,0,LineModeType.AutoHeight,0,0,0,0,1);
- this.getDrawLabelText(14,17,30,8,ljms,2.5,0,LineModeType.AutoHeight,0,0,0,0,1);
- this.getDrawLabelText(17,22.5,27,8,fh,2.5,0,LineModeType.AutoHeight,0,0,0,0,1);
- this.getDrawLabelText(14,27.5,55,8,scdt,2.5,0,LineModeType.AutoHeight,0,0,0,0,1);
- this.getDrawLabelText(14,32.7,55,8,scph,2.5,0,LineModeType.AutoHeight,0,0,0,0,1);
- this.getDrawLabelText(14,37.5,55,8,fhdw,2.5,0,LineModeType.AutoHeight,0,0,0,0,1);
- this.getDrawLabelText(14,42.5,55,8,shdw,2.5,0,LineModeType.AutoHeight,0,0,0,0,1);
-
+ this.getDrawLabelText(
+ 11,
+ 7,
+ 30,
+ 8,
+ ht,
+ 2.5,
+ 0,
+ LineModeType.AutoHeight,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1
+ );
+ this.getDrawLabelText(
+ 11,
+ 12,
+ 32,
+ 8,
+ lj,
+ 2.5,
+ 0,
+ LineModeType.AutoHeight,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1
+ );
+ this.getDrawLabelText(
+ 14,
+ 17,
+ 30,
+ 8,
+ ljms,
+ 2.5,
+ 0,
+ LineModeType.AutoHeight,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1
+ );
+ this.getDrawLabelText(
+ 17,
+ 23.5,
+ 27,
+ 8,
+ fh,
+ 2.5,
+ 0,
+ LineModeType.AutoHeight,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1
+ );
+ this.getDrawLabelText(
+ 14,
+ 28.5,
+ 55,
+ 8,
+ scdt,
+ 2.5,
+ 0,
+ LineModeType.AutoHeight,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1
+ );
+ this.getDrawLabelText(
+ 14,
+ 32.7,
+ 55,
+ 8,
+ scph,
+ 2.5,
+ 0,
+ LineModeType.AutoHeight,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1
+ );
+ this.getDrawLabelText(
+ 14,
+ 37.5,
+ 55,
+ 8,
+ fhdw,
+ 2.5,
+ 0,
+ LineModeType.AutoHeight,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1
+ );
+ this.getDrawLabelText(
+ 14,
+ 42.5,
+ 55,
+ 8,
+ shdw,
+ 2.5,
+ 0,
+ LineModeType.AutoHeight,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1
+ );
// 鐢熸垚鎵撳嵃鏁版嵁
let imageJsonObj = jcapi.generateLabelJson();
@@ -572,83 +826,43 @@
}
});
},
- tapQuery(item) {
+ async tapQuery(item) {
this.maskShow = false;
- // 杩炴帴鎵撳嵃鏈�
- let _this = this;
+ try {
+ await bluetooth.connect(item);
+ uni.showToast({ title: "杩炴帴鎴愬姛" });
- // 璁剧疆涓鸿繛鎺ヤ腑鐘舵��
- this.connectionStatus = "connecting";
-
- jcapi.openPrinterByDevice(
- {
- address: item.address,
- name: item.name,
- deviceType: 0, // 璁惧绫诲瀷锛�0-钃濈墮锛�1-缃戠粶
- },
- function (r) {
- if (r.code == 0) {
- _this.connectedDevice = item;
- _this.connectionStatus = "connected";
- uni.showToast({
- title: "杩炴帴鎴愬姛",
- duration: 1500,
- });
- // 寮�濮嬪鐞嗘墦鍗伴槦鍒�
- if (_this.printQueue.length > 0) {
- _this.processPrintQueue();
- }
- } else {
- _this.connectionStatus = "disconnected";
- uni.showToast({
- title: "杩炴帴澶辫触: " + (r.msg || "鏈煡閿欒"),
- icon: "none",
- duration: 2000,
- });
- }
+ // 濡傛灉鏈夋墦鍗颁换鍔★紝缁х画鎵撳嵃
+ if (this.printQueue.length) {
+ this.processPrintQueue();
}
- );
+ } catch (e) {
+ uni.showToast({
+ icon: "none",
+ title: "杩炴帴澶辫触",
+ });
+ }
},
+
//鎵撳嵃鐩稿叧
- searchDevice() {
- let _this = this;
- uni.openBluetoothAdapter({
- // 纭钃濈墮鏄惁鎵撳紑
- success(r) {
- uni.showLoading({
- title: "鎼滅储涓�...",
- });
- // 鏈巿浜堣摑鐗欑浉鍏虫潈闄愬拰鏈墦寮�鎵嬫満瀹氫綅浼氭悳绱笉鍒拌澶�
- jcapi.getBluetoothDevices(function (r) {
- console.log("device:" + JSON.stringify(r));
- // 鎼滅储鍒拌澶囧洖璋�
- uni.hideLoading();
- // 濡傛灉涔嬪墠鏈夎繛鎺ョ殑璁惧浣嗕笉鍦ㄦ悳绱㈢粨鏋滀腑锛岃鏄庤澶囧凡鏇存崲
- if (
- _this.connectedDevice &&
- !r.some((dev) => dev.address === _this.connectedDevice.address)
- ) {
- _this.connectedDevice = null;
- uni.showToast({
- icon: "none",
- title: "宸茶繛鎺ョ殑钃濈墮璁惧宸叉洿鎹紝璇烽噸鏂伴�夋嫨",
- duration: 2000,
- });
- }
- _this.listDevice = r;
- _this.maskShow = true;
- });
- },
- fail(e) {
- uni.showModal({
- title: "鎻愮ず",
- content: "鎵撳紑钃濈墮澶辫触锛岃妫�鏌ヨ摑鐗欐槸鍚﹀紑鍚�",
- showCancel: false,
- });
- console.log("寮�鍚摑鐗欒澶囧け璐�" + e);
- },
- });
+ async searchDevice() {
+ try {
+ uni.showLoading({ title: "鎼滅储涓�..." });
+ const devices = await bluetooth.searchDevices();
+ uni.hideLoading();
+
+ this.listDevice = devices;
+ this.maskShow = true;
+ } catch (e) {
+ uni.hideLoading();
+ uni.showModal({
+ title: "鎻愮ず",
+ content: "璇风‘璁よ摑鐗欏拰瀹氫綅宸插紑鍚�",
+ showCancel: false,
+ });
+ }
},
+
// 缁樺埗妯嚎
getDrawLabelLine(x, y, width, height, rotate, lineType) {
jcapi.drawLabelLine({
--
Gitblit v1.9.3