Browse Source

bug 修复

lilei 2 năm trước cách đây
mục cha
commit
32fffeb94d

+ 11 - 8
components/kk-printer/index.vue

@@ -205,13 +205,11 @@
 							}
 							}
 						}else{
 						}else{
 							//若没有已连接设备,弹框搜索设备
 							//若没有已连接设备,弹框搜索设备
-							if(res.devices.length == 0){
-								this.isShowSearch = true
-								this.devicesList = []
-								if(this.deviceId){
-									this.closeConnect(this.deviceId)
-								}
-							} 
+							this.isShowSearch = true
+							this.devicesList = []
+							if(this.deviceId){
+								this.closeConnect()
+							}
 						}
 						}
 					}).catch((err)=>{
 					}).catch((err)=>{
 						blesdk.catchToast(err);
 						blesdk.catchToast(err);
@@ -260,10 +258,14 @@
 							verticalAlign:'center'
 							verticalAlign:'center'
 						})
 						})
 					}else{
 					}else{
-						_this.closeConnect(deviceId)
+						_this.closeConnect()
 						plus.nativeUI.toast('设备'+ res.deviceId + '已断开连接',{
 						plus.nativeUI.toast('设备'+ res.deviceId + '已断开连接',{
 							verticalAlign:'center'
 							verticalAlign:'center'
 						})
 						})
+						const lastDevice = uni.getStorageSync('vuex_lastBuleDevice')
+						if(lastDevice){
+							this.handleConnectDevice(lastDevice)
+						}
 					}
 					}
 					_this.isConnecting = false
 					_this.isConnecting = false
 			    })
 			    })
@@ -278,6 +280,7 @@
 				console.log('链接失败',err)
 				console.log('链接失败',err)
 				this.isConnecting = false
 				this.isConnecting = false
 				blesdk.catchToast(err.res)
 				blesdk.catchToast(err.res)
+				uni.setStorageSync('vuex_lastBuleDevice','')
 			},
 			},
 			onGetServicesSuccess(res){
 			onGetServicesSuccess(res){
 				console.log('获取服务',res)
 				console.log('获取服务',res)

+ 1 - 1
components/kk-printer/utils/bluetoolth.js

@@ -314,7 +314,7 @@ export function catchToast(err) {
 		10007: '当前特征值不支持此操作',
 		10007: '当前特征值不支持此操作',
 		10008: '系统上报异常',
 		10008: '系统上报异常',
 		10009: '系统版本低于 4.3 不支持BLE',
 		10009: '系统版本低于 4.3 不支持BLE',
-		10012: '连接超时,请检查打印机是否被其它手机连接中'
+		10012: '连接超时,请重试'
 	};
 	};
 	let coode = err.errCode ? err.errCode.toString() : '';
 	let coode = err.errCode ? err.errCode.toString() : '';
 	let msg = errMsg[coode];
 	let msg = errMsg[coode];

+ 5 - 5
libs/printTools.js

@@ -77,10 +77,10 @@ export const printTempl = function(tsc,data){
 	const lightHeight = 24 // 行高3mm,1mm = 8点
 	const lightHeight = 24 // 行高3mm,1mm = 8点
 	const pageW = 60 // 页签宽度mm
 	const pageW = 60 // 页签宽度mm
 	const pageH = 40 // 页签高度mm
 	const pageH = 40 // 页签高度mm
-	const maxFontNums = Math.floor((pageW*8-left*2)/lightHeight) // 每行最多字体数
+	const maxFontNums = Math.floor((pageW*8-left*4)/lightHeight) // 每行最多字体数
 	const leftMaxFnums = Math.floor(maxFontNums*0.4)
 	const leftMaxFnums = Math.floor(maxFontNums*0.4)
-	const rightMaxFnums = maxFontNums*0.5
-	let rightLeft = (leftMaxFnums+1.5)*lightHeight
+	const rightMaxFnums = leftMaxFnums + 1
+	let rightLeft = (leftMaxFnums+2.5)*lightHeight
 	// 初始化打印机
 	// 初始化打印机
 	const command = tsc.jpPrinter.createNew()
 	const command = tsc.jpPrinter.createNew()
 	command.init()
 	command.init()
@@ -92,11 +92,11 @@ export const printTempl = function(tsc,data){
 	// 数字货架名称文字
 	// 数字货架名称文字
 	top = top+30
 	top = top+30
 	// 二维码
 	// 二维码
-	command.setQR(left*3, top, "M", 5, "A", data.barCode)
+	command.setQR(left*6, top, "M", 5, "A", data.barCode)
 	// 货位号
 	// 货位号
 	const rightTop = textFormat(command,data.shelfPlaceCode,rightMaxFnums,rightLeft,top,lightHeight,"left",4)
 	const rightTop = textFormat(command,data.shelfPlaceCode,rightMaxFnums,rightLeft,top,lightHeight,"left",4)
 	// 产品编码
 	// 产品编码
-	top = rightTop
+	top = rightTop + 1
 	top = textFormat(command,data.productCode,rightMaxFnums,rightLeft,top,lightHeight,"left",1)
 	top = textFormat(command,data.productCode,rightMaxFnums,rightLeft,top,lightHeight,"left",1)
 	// 打印分数1,每个标签重发打印2次
 	// 打印分数1,每个标签重发打印2次
 	command.setPagePrint(1,data.currentInven) 
 	command.setPagePrint(1,data.currentInven)