shish 1 anno fa
parent
commit
90b76444bd
3 ha cambiato i file con 0 aggiunte e 872 eliminazioni
  1. 0 584
      ghsApp/src/mixins/BLE.js
  2. 0 1
      ghsApp/src/pages.json
  3. 0 287
      ghsApp/src/pagesOrder/print.vue

+ 0 - 584
ghsApp/src/mixins/BLE.js

@@ -1,584 +0,0 @@
-/** -姜枫 2021.06.13- **/
-import { addPrintNum } from "@/api/order";
-var util = require("@/pagesOrder/js/util.js");
-import drawQrcode from "@/pagesOrder/js/weapp.qrcode.esm";
-var toArrayBuffer = require('to-array-buffer');
-
-var PrinterJobs = require("@/pagesOrder/js/printerjobs.js");
-var printerUtil = require("@/pagesOrder/js/printerutil.js");
-
-
-export default {
-	data() {
-		return {
-			BleVal:'',
-			nameBLE:'未连接',
-			devices: [],
-			currDev: null,
-			isAutoBle: false,
-			connId: "",
-			piaojuText: [''],
-		};
-	},
-	onShow() {
-		this.devices = [];
-		this.isAutoBle = false;
-		if(uni.getStorageSync('BLE')){
-			this.nameBLE = uni.getStorageSync('BLE').name;
-		}
-	},
-	methods: {
-		//断开蓝牙链接
-		destroyed(BleVal) {
-			this.BleVal = BleVal;
-			let that = this;
-			if(!uni.getStorageSync('BLE')){
-
-				that.$util.confirmModal({content:'请先连接蓝牙'},() => {
-					uni.navigateTo({url:'/pagesOrder/print'});
-				})
-
-				return;
-			}
-			uni.closeBLEConnection({deviceId: uni.getStorageSync('BLE').deviceId,complete(res) {
-					console.log(res);
-					that.autoLinkBle(BleVal);
-				}
-			});
-			// if (this.connId != "") {
-			// 	uni.closeBLEConnection({deviceId: uni.getStorageSync('BLE').deviceId,success(res) {
-			// 			this.autoLinkBle();
-			// 		}
-			// 	});
-			// }
-		},
-		//初始化蓝牙
-		searchBle() {
-			uni.showToast({
-				title: '搜索中...',
-				duration: 2000
-				});
-			var that = this;
-			that.isAutoBle = false;
-			uni.openBluetoothAdapter({
-				success(res) {
-					console.log(res,"打开 蓝牙模块");
-					//that.onDevice();//监听搜索新设备
-					//获取本机蓝牙适配器状态。
-					uni.getBluetoothAdapterState({
-						success: function(res) {
-							console.log(res);
-							if (res.available) {
-								if (res.discovering) {
-									that.stopFindBule();
-								}
-								//搜索蓝牙
-								//开始搜寻附近的蓝牙外围设备
-								console.log("开始搜寻附近的蓝牙外围设备");
-								uni.startBluetoothDevicesDiscovery({
-									success(res) {
-										console.log(res);
-										that.getBluetoothDevices()
-									}
-								});
-							} else {
-								console.log("本机蓝牙不可用");
-							}
-						}
-					});
-				}
-			});
-		},
-		getBluetoothDevices(){
-			let that = this;
-			uni.getBluetoothDevices({
-				success: re => {
-					//let devices = res.devices;
-					console.log(re,'设备列表');
-					//var re = JSON.parse(JSON.stringify(devices));
-					if(re.devices && re.devices.length > 0){
-
-						re.devices.forEach(function(item){
-							  
-						let name = item.name?item.name:'未知设备';
-						if (name != "未知设备" && name != "") {
-							let deviceId = item.deviceId;
-							switch(uni.getSystemInfoSync().platform){
-								case 'android':
-									that.devices.push({name: name,deviceId: deviceId,services: []});
-									break;
-								case 'ios':
-									for (let i=0;i<that.devices.length;i++){
-										console.log(that.devices[i].name,'----',name)
-										if (that.devices[i].name==name) {return}
-									}
-									that.devices.push({name: name,deviceId: deviceId,services: []});
-									break;
-							}
-		
-						}else{
-							console.log('name',name)
-							console.log('re.devices[0]',re.devices[0])
-						}
-
-					});
-
-					}
-
-				
-
-				}
-			});
-		},
-		// onDevice() {
-		// 	var that = this;
-		// 	//监听寻找到新设备的事件
-		// 	uni.onBluetoothDeviceFound(function(devices) {
-		// 		console.log(devices,'设备列表');
-		// 		var re = JSON.parse(JSON.stringify(devices));
-		// 		let name = re.devices[0].name?re.devices[0].name:'未知设备';
-		// 		if (name != "未知设备" && name != "") {
-		// 			let deviceId = re.devices[0].deviceId;
-		// 			switch(uni.getSystemInfoSync().platform){
-		// 				case 'android':
-		// 					that.devices.push({name: name,deviceId: deviceId,services: []});
-		// 					break;
-		// 				case 'ios':
-		// 					for (let i=0;i<that.devices.length;i++){
-		// 						console.log(that.devices[i].name,'----',name)
-		// 						if (that.devices[i].name==name) {return}
-		// 					}
-		// 					that.devices.push({name: name,deviceId: deviceId,services: []});
-		// 					break;
-		// 			}
-
-
-		// 			// that.$nextTick(()=>{
-		// 			// 	that.$util.unique(that.devices);
-		// 			// })
-
-		// 		}
-		// 	});
-		// },
-		//自动链接蓝牙-初始化蓝牙模块
-		autoLinkBle(BleVal){
-			this.BleVal = BleVal;
-			let that = this;
-			if(!uni.getStorageSync('BLE')){
-
-				that.$util.confirmModal({content:'请先连接蓝牙'},() => {
-					uni.navigateTo({url:'/pagesOrder/print'})
-				})
-
-				return;
-			}
-			uni.showLoading({title: '打印中...'});
-			that.isAutoBle = true;
-			let deviceId = uni.getStorageSync('BLE');
-			//初始化蓝牙模块
-			uni.openBluetoothAdapter({
-				success(res) {
-					console.log('初始化成功',res)
-					that.autoLinkBleFun(deviceId);
-				},fail(e){
-					console.log('初始化失败',e)
-				}
-			});
-		},
-		//自动链接蓝牙
-		autoLinkBleFun(item) {
-			console.log('自动链接 444444444444444444444444444444444444444444444444444')
-			var that = this;
-			let deviceId = item.deviceId;
-			uni.createBLEConnection({
-				deviceId: deviceId,
-				complete(res) {
-					console.log(res,'自动连接成功')
-					if (res.errMsg == "createBLEConnection:ok") {
-						uni.setStorageSync('BLE',item);
-						setTimeout(function() {
-							that.getBLEServices(deviceId);
-						}, 2000);
-					}
-				}
-			});
-		},
-		stopFindBule() {
-			console.log("停止搜寻附近的蓝牙外围设备---------------");
-			uni.stopBluetoothDevicesDiscovery({
-				success(res) {
-					console.log(res);
-				}
-			});
-		},
-		onConn(item) {
-			console.log('正在连接 333333333333333333333333333333333333333333333333333333333333333333333333')
-			uni.showLoading({title: '正在连接...'});
-			var that = this;
-			// console.log("连接蓝牙---------------" + item.deviceId);
-			let deviceId = item.deviceId;
-			uni.createBLEConnection({
-				deviceId: deviceId,
-				complete(res) {
-					if (res.errMsg == "createBLEConnection:ok") {
-						that.nameBLE = item.name;
-						// console.log("连接蓝牙-[" + item.name + "]--成功");
-						// that.$msg("连接蓝牙-[" + item.name + "]--成功");
-						that.connId = deviceId;
-						that.currDev = item;
-						setTimeout(function() {
-							that.getBLEServices(deviceId);
-						}, 2000);
-					} else {
-						console.log(res);
-					}
-					//连接成功 关闭搜索
-					that.stopFindBule();
-				}
-			});
-		},
-
-		getBLEServices(_deviceId) {
-			var that = this;
-			let deviceId = _deviceId;
-			console.log("获取蓝牙设备所有服务(service)");
-
-			console.log('获取蓝牙设备所有服务 222222222222222222222222222222222222222222222222222222222')
-
-			uni.getBLEDeviceServices({
-				// 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
-				deviceId: deviceId,
-				success(res) {
-						console.log('getBLEDeviceServices成功:',res)
-						for (var s = 0; s < res.services.length; s++) {
-							console.log(res.services[s].uuid);
-							let serviceId = res.services[s].uuid;
-							uni.getBLEDeviceCharacteristics({
-								// 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
-								deviceId: deviceId,
-								// 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
-								serviceId: serviceId,
-								success(res) {
-									var re = JSON.parse(JSON.stringify(res));
-
-									console.log("deviceId = [" + deviceId + "]  serviceId = [" + serviceId + "]")
-
-									for (var c = 0; c < re.characteristics.length; c++) {
-										if (re.characteristics[c].properties.write == true) {
-											let uuid = re.characteristics[c].uuid;
-											console.log(" deviceId = [" +deviceId +"]  serviceId = [" +serviceId +"] characteristics = [" +uuid +"]");
-											//是否是直接打印
-											if(that.isAutoBle){
-												console.log('打印订单 11111111111111111111111111111111111111111111111111111111111111')
-												that.senBleLabel()
-												uni.hideLoading()
-												that.isAutoBle = false
-											}
-											for (var index in that.devices) {
-												if (that.devices[index].deviceId == deviceId) {
-													that.devices[index].services.push({serviceId: serviceId,characteristicId: uuid});
-													that.$nextTick(()=>{
-														uni.setStorageSync('BLE',that.devices[index]);
-														that.$msg("连接蓝牙-[" + that.devices[index].name + "]--成功");
-													})
-													break;
-												}
-											}
-											console.log(JSON.stringify(that.devices));
-										}
-									}
-								}
-							});
-						}
-				},
-				fail(res) {
-					console.log('getBLEDeviceServices失败:',res)
-					uni.hideLoading()
-					uni.showLoading({title:"打印失败..."})
-					setTimeout(function(){
-						uni.hideLoading()
-					},2000)
-					// if(res.errCode && res.errCode == 10004){
-					// 	uni.showLoading({title:"重打中..."})
-					// 	that.destroyed(that.BleVal)
-					// }
-				}
-			});
-		},
-		_writeBLECharacteristicValue(data) {
-			uni.writeBLECharacteristicValue({
-			  deviceId: data.deviceId,
-			  serviceId: data.serviceId,
-			  characteristicId: data.characteristicId,
-			  value: data.buffer,
-			  success(res) {
-				console.log('writeBLECharacteristicValue success', res)
-			  },
-			  fail(res) {
-				console.log('writeBLECharacteristicValue fail', res)
-			  }
-			})
-		  },
-
-		senBleLabel() {
-			let BleVal = this.BleVal;
-			let that = this;
-			console.log(BleVal,'BleValBleVal')
-			let currDev = uni.getStorageSync('BLE');
-			let deviceId = currDev.deviceId;
-			let serviceId = currDev.services[0].serviceId;
-			let characteristicId = currDev.services[0].characteristicId;
-
-			let currentRealPrice = BleVal.debt == 1 ? '0.00' : BleVal.realPrice;
-
-			let printerJobs = new PrinterJobs();
-			printerJobs
-			  .setSize(2, 2)
-			  .print(BleVal.sendNum)
-			  .setSize(1, 1)
-			  .print(printerUtil.fillLine())
-			  .setSize(2, 2)
-			  .print(BleVal.custom.fullAddress)
-			  .print(BleVal.custom.customName)
-			  .print(BleVal.custom.customMobile)
-
-				.setSize(1, 1)
-				.print("备注:")
-				.setSize(2, 2)
-				.print(BleVal.remark)
-				.setSize(1, 1)
-				
-
-				.setAlign('lt')
-				.print(printerUtil.fillAround('花材 数量 价格'));
-				
-				if(BleVal.product.length > 0){
-					BleVal.product.forEach(function(currentItem){
-						printerJobs.print(printerUtil.inline(currentItem.name+' '+currentItem.num, currentItem.price));
-					})
-				}
-				printerJobs.print(printerUtil.fillLine());
-				//printerJobs.setAlign('rt');
-				printerJobs.setAlign('lt')
-				if(BleVal.sendCost>0){
-					printerJobs.print('运费:¥'+BleVal.sendCost);
-				}
-				
-				printerJobs.print('总金额:¥'+BleVal.prePrice);
-
-				if(BleVal.discountAmount > 0){
-					printerJobs.print('优惠:¥'+BleVal.discountAmount);
-				}
-			
-				printerJobs.print('应付金额:¥'+BleVal.realPrice);
-				printerJobs.print('实付金额:¥'+currentRealPrice);
-			
-				if(BleVal.debtAmount > 0){
-					printerJobs.print('累计欠款:¥'+BleVal.debtAmount);
-				}
-
-				printerJobs.print(printerUtil.fillLine());
-				printerJobs.print('订单日期:'+BleVal.date);
-				printerJobs.print('订单编号:'+BleVal.orderSn);
-				printerJobs.print('门店名称:纯彩花艺');
-				printerJobs.print('门店地址:'+BleVal.address);
-				
-				printerJobs.println().println();
-			
-		
-			let buffer = printerJobs.buffer();
-			
-			// 1.并行调用多次会存在写失败的可能性
-			// 2.建议每次写入不超过20字节
-			// 分包处理,延时调用
-			const maxChunk = 20;
-			const delay = 20;
-			for (let i = 0, j = 0, length = buffer.byteLength; i < length; i += maxChunk, j++) {
-			  let subPackage = buffer.slice(i, i + maxChunk <= length ? (i + maxChunk) : length);
-			  setTimeout(this._writeBLECharacteristicValue, j * delay, {deviceId:deviceId, serviceId:serviceId, characteristicId:characteristicId,buffer:subPackage});
-			}
-
-			//增加打印次数
-			addPrintNum({id:that.orderId}).then(res=>{
-				if(!that.$util.isEmpty(that.detailInfo)){
-					that.detailInfo.printNum++;
-				}
-				if(!that.$util.isEmpty(that.list.data)){
-					that.list.data.forEach(ele=>{
-						if (ele.id==that.orderId) {
-							ele.printNum++;
-						}
-					})
-				}
-			})
-
-			// let arrPrint = [];
-			// //初始化打印机
-			// arrPrint.push(util.sendDirective([0x1B, 0x40])); //16进制
-			// //正文
-			// arrPrint.push(util.sendDirective([0x1B, 0x0E]));
-			// //字体宽高加倍
-			// arrPrint.push(util.sendDirective([0x1d, 0x21, 0x11]));
-			// arrPrint.push(util.hexStringToBuff(BleVal.sendNum));
-			// //字体不放大,宽高不再加倍
-			// arrPrint.push(util.sendDirective([0x1d, 0x21, 0x00]));
-
-			// arrPrint.push(util.sendDirective([0x1B, 0x14]));
-			// arrPrint.push(util.hexStringToBuff(" |纯彩花艺\n"));
-			// arrPrint.push(util.sendDirective([0x1B, 0x14]));
-			
-			// arrPrint.push(util.hexStringToBuff("--------------------------------\n"));
-			// arrPrint.push(util.sendDirective([0x1B, 0x0E]));
-
-			// //字体宽高加倍
-			// arrPrint.push(util.sendDirective([0x1d, 0x21, 0x11]));
-
-			// arrPrint.push(util.hexStringToBuff(BleVal.custom.fullAddress+ "\n"));	
-			// arrPrint.push(util.sendDirective([0x1B, 0x0E]));
-			// arrPrint.push(util.hexStringToBuff(BleVal.custom.customName+"\n"+BleVal.custom.customMobile+ "\n"));
-
-			// //字体不放大,宽高不再加倍
-			// arrPrint.push(util.sendDirective([0x1d, 0x21, 0x00]));
-
-			// if(BleVal.remark.length > 0){
-			// 	arrPrint.push(util.sendDirective([0x1B, 0x14]));
-			// 	arrPrint.push(util.hexStringToBuff("--------------------------------\n"));
-			// 	arrPrint.push(util.hexStringToBuff("备注:\n"));
-			// 	arrPrint.push(util.sendDirective([0x1B, 0x0E]));
-			// 	//字体宽高加倍
-			// 	arrPrint.push(util.sendDirective([0x1d, 0x21, 0x11]));
-			// 	arrPrint.push(util.hexStringToBuff(BleVal.remark+"\n"));
-			// 	//字体不放大,宽高不再加倍
-			// 	arrPrint.push(util.sendDirective([0x1d, 0x21, 0x00]));
-			// }
-
-			// arrPrint.push(util.sendDirective([0x1B, 0x14]));
-			// arrPrint.push(util.hexStringToBuff("--------------------------------\n"));
-			// arrPrint.push(util.hexStringToBuff(util.printThreeData('花材', '数量', '价格')));
-			// if(BleVal.product.length > 0){
-			// 	BleVal.product.forEach(function(currentItem){
-			// 		arrPrint.push(util.hexStringToBuff(util.printThreeData(currentItem.name, currentItem.num, currentItem.price)))
-			// 	})
-			// }
-			// arrPrint.push(util.hexStringToBuff("--------------------------------\n"));
-			// arrPrint.push(util.hexStringToBuff(util.printTwoData("运费:", BleVal.sendCost)));
-			// arrPrint.push(util.hexStringToBuff(util.printTwoData("总金额:", BleVal.prePrice)));
-			// arrPrint.push(util.hexStringToBuff(util.printTwoData("优惠:", BleVal.discountAmount)));
-			// arrPrint.push(util.hexStringToBuff(util.printTwoData("应付金额:", BleVal.realPrice)));
-			// arrPrint.push(util.hexStringToBuff(util.printTwoData("实付金额:", BleVal.debt == 1 ? '0.00' : BleVal.realPrice)));
-			// if(BleVal.debtAmount > 0){
-			// 	//加粗
-			// 	//arrPrint.push(util.sendDirective([0x1b, 0x45, 0x01]));
-			// 	arrPrint.push(util.hexStringToBuff(util.printTwoData("累计欠款:", BleVal.debtAmount)));
-			// 	//取消加粗	
-			// 	//arrPrint.push(util.sendDirective([0x1b, 0x45, 0x00]));
-			// }
-			// arrPrint.push(util.hexStringToBuff(util.printTwoData("订单日期:", BleVal.date)));
-			// arrPrint.push(util.hexStringToBuff(util.printTwoData("订单编号:", BleVal.orderSn)));
-			// arrPrint.push(util.sendDirective([0x1B, 0x61, 0x00]));
-			// arrPrint.push(util.hexStringToBuff("门店地址:"+BleVal.address+"\n"));
-			// arrPrint.push(util.hexStringToBuff("\n\n\n\n"));
-
-			// const ctx = uni.createCanvasContext('canvas');
-			// ctx.clearRect(0, 0, 130, 130);
-			// let tthis = this;
-			// drawQrcode({
-			// 	canvasId: 'canvas',
-			// 	text: 'https://shop.huahb.cn/#/main/index',
-			// 	width: 130,
-			// 	height: 130,
-			// 	callback(e) {
-			// 		console.log(111111123)
-			// 		setTimeout(() => {
-			// 			// 获取图片数据
-			// 			uni.canvasGetImageData({
-			// 				canvasId: 'canvas',
-			// 				x: 0,
-			// 				y: 0,
-			// 				width: 130,
-			// 				height: 130,
-			// 				success(res) {
-			// 					let arr = tthis.convert4to1(res.data);
-			// 					let data = tthis.convert8to1(arr);
-			// 					const cmds = [].concat([27, 97, 1], [29, 118, 48, 0, 20, 0, 160, 0], data, [27, 74, 3], [27, 64]);
-			// 					const buffer = toArrayBuffer(Buffer.from(cmds, 'gb2312'));
-			// 					console.log(123456789)
-			// 					arrPrint.push(util.sendDirective([0x1B, 0x40]));
-			// 					for (let i = 0; i < buffer.byteLength; i = i + 20) {
-			// 						arrPrint.push(buffer.slice(i, i + 20));
-			// 					}
-			// 					arrPrint.push(util.hexStringToBuff("\n"));
-			// 					arrPrint.push(util.sendDirective([0x1B, 0x61, 0x01])); //居中
-			// 					arrPrint.push(util.hexStringToBuff("扫码采购花材\n"));
-			// 					arrPrint.push(util.hexStringToBuff("\n"));
-			// 					arrPrint.push(util.hexStringToBuff("\n"));
-			// 				}
-			// 			})
-			// 		}, 3000);
-			// 	}
-			// });
-			// this.printInfo({deviceId:deviceId, serviceId:serviceId, characteristicId:characteristicId}, arrPrint);
-
-		},
-
-			//4合1
-	convert4to1(res) {
-		let arr = [];
-		for (let i = 0; i < res.length; i++) {
-			if (i % 4 == 0) {
-				let rule = 0.29900 * res[i] + 0.58700 * res[i + 1] + 0.11400 * res[i + 2];
-				if (rule > 200) {
-					res[i] = 0;
-				} else {
-					res[i] = 1;
-				}
-				arr.push(res[i]);
-			}
-		}
-		return arr;
-	},
-
-	//8合1
-	convert8to1(arr) {
-		let data = [];
-		for (let k = 0; k < arr.length; k += 8) {
-			let temp = arr[k] * 128 + arr[k + 1] * 64 + arr[k + 2] * 32 + arr[k + 3] * 16 + arr[k + 4] * 8 + arr[k + 5] * 4 +
-				arr[k + 6] * 2 + arr[k + 7] * 1
-			data.push(temp);
-		}
-		return data;
-	},
-
-		printInfo(device, arr, callback) {
-			let tthis = this;
-			if (arr.length > 0) {
-				tthis.sendStr(device, arr[0], function(success) {
-					arr.shift();
-					tthis.printInfo(device, arr, callback);
-				}, function(error) {
-					console.log(error);
-				});
-			} else {
-				callback ? callback() : '';
-			}
-		},
-		//发送数据
-		sendStr(device, bufferstr, success, fail) {
-			let tthis = this;
-			uni.writeBLECharacteristicValue({
-				deviceId: device.deviceId,
-				serviceId: device.serviceId,
-				characteristicId: device.characteristicId,
-				value: bufferstr,
-				success: function(res) {
-					success(res);
-					console.log('sendStr', bufferstr)
-				},
-				failed: function(res) {
-					fail(res)
-					console.log("数据发送失败:" + JSON.stringify(res))
-				}
-			})
-		},
-	}
-}

+ 0 - 1
ghsApp/src/pages.json

@@ -105,7 +105,6 @@
 				{"path": "ship","style": {"navigationBarTitleText": "发货"}},
 				{"path": "ship","style": {"navigationBarTitleText": "发货"}},
 				{"path": "shipInfo","style": {"navigationBarTitleText": "发货"}},
 				{"path": "shipInfo","style": {"navigationBarTitleText": "发货"}},
 				{"path": "select","style": {"navigationBarTitleText": "重选花材"}},
 				{"path": "select","style": {"navigationBarTitleText": "重选花材"}},
-				{"path": "print","style": {"navigationBarTitleText": "连接蓝牙"}},
 				{"path": "allot","style": {"navigationBarTitleText": "分配工作"}},
 				{"path": "allot","style": {"navigationBarTitleText": "分配工作"}},
 				{"path": "refundSuccess","style": {"navigationBarTitleText": "结果"}},
 				{"path": "refundSuccess","style": {"navigationBarTitleText": "结果"}},
 				{"path": "refundList","style": {"navigationBarTitleText": "售后记录", "enablePullDownRefresh": true}},
 				{"path": "refundList","style": {"navigationBarTitleText": "售后记录", "enablePullDownRefresh": true}},

+ 0 - 287
ghsApp/src/pagesOrder/print.vue

@@ -1,287 +0,0 @@
-<style lang="scss" scoped>
-			.center{
-				font-size: 32upx;
-				padding: 30upx;
-				.connected-title{
-					text{color: #2079ff;}
-				}
-				.seek-btn{
-					margin: 30upx 0;
-					width: 60%;
-					height: 80upx;
-					color: #FFFFFF;
-					background: #169bd5;
-					border-radius: 20upx;
-				}
-				.ble-list{
-					width: 65%;
-					height: 80upx;
-					text{color: #2079ff;}
-				}
-			}
-</style>
-
-<template>
-	<view class="center">
-		<view class="flex connected-title">已连接蓝牙:<text>{{nameBLE}}</text></view>
-		<view class="flex-center seek-btn" @click="searchBle">搜索蓝牙打印机</view>
-		<!--<button @click="searchBle">搜索蓝牙打印机</button>-->
-		<!--<view style="margin-top: 30upx;" :key="index" v-for="(item, index) in devices">-->
-		<view class="flex-space ble-list" :key="index" v-for="(item, index) in devices" @click="onConn(item)">
-				{{item.name}} <text>连接</text>
-		</view>
-		<!--<button style="margin-top: 100upx;" @click="senBleLabel()">标签打印</button>-->
-		<!--<textarea @blur="bindTextAreaBlur" auto-height placeholder-style="color:#F76260" placeholder="请输入票据信息" v-model="piaojuText"/>-->
-		<!--<button style="margin-top: 100upx;" @click="billPrint()">票据打印</button>-->
-	</view>
-</template>
-
-<script>
-	import BLE from "@/mixins/BLE";
-// var tsc = require("./js/gprint/tsc.js");
-// var esc = require("./js/gprint/esc.js");
-export default {
-	mixins: [BLE],
-	data() {
-		return {
-			// devices: [],
-			// currDev: null,
-			// connId: "",
-			// piaojuText: "",
-			// deviceId:'6CE888E4-6BF4-2D2A-60AE-07480F6A39A6',
-		};
-	},
-	onLoad: function() {},
-
-	// methods: {
-	// 	destroyed: function() {
-	// 		console.log("destroyed----------");
-	// 		if (this.connId != "") {
-	// 			uni.closeBLEConnection({
-	// 				deviceId: this.connId,
-	// 				success(res) {
-	// 					console.log(res);
-	// 				}
-	// 			});
-	// 		}
-	// 	},
-	// 	searchBle() {
-	// 		var that = this;
-	// 		uni.openBluetoothAdapter({
-	// 			success(res) {
-	// 				console.log(res,"打开 蓝牙模块");
-	// 				that.onDevice();//监听搜索新设备
-	// 				//获取本机蓝牙适配器状态。
-	// 				uni.getBluetoothAdapterState({
-	// 					success: function(res) {
-	// 						console.log(res);
-	// 						if (res.available) {
-	// 							if (res.discovering) {
-	// 								that.stopFindBule();
-	// 							}
-	// 							//搜索蓝牙
-	// 							//开始搜寻附近的蓝牙外围设备
-	// 							console.log("开始搜寻附近的蓝牙外围设备");
-	// 							uni.startBluetoothDevicesDiscovery({
-	// 								success(res) {
-	// 									console.log(res);
-	// 								}
-	// 							});
-	// 						} else {
-	// 							console.log("本机蓝牙不可用");
-	// 						}
-	// 					}
-	// 				});
-	// 			}
-	// 		});
-	// 	},
-	// 	onDevice() {
-	// 		var that = this;
-	// 		//监听寻找到新设备的事件
-	// 		uni.onBluetoothDeviceFound(function(devices) {
-	// 			console.log(devices,'设备列表');
-	// 			var re = JSON.parse(JSON.stringify(devices));
-	// 			let name = re.devices[0].name?re.devices[0].name:'未知设备';
-	// 			let deviceId = re.devices[0].deviceId;
-	// 			that.devices.push({name: name,deviceId: deviceId,services: []});
-	// 			// that.zidonglianjie();
-	// 			// if (name != "未知设备" && name != "") {
-	// 			// 	let deviceId = re.devices[0].deviceId;
-	// 			// 	that.devices.push({name: name,deviceId: deviceId,services: []});
-	// 			// }
-	// 		});
-	// 	},
-	// 	zidonglianjie(){
-	// 		this.devices.forEach((ele)=>{
-	// 			if(ele.deviceId==this.deviceId){
-	// 				this.onConn(ele);
-	// 			}
-	// 		})
-	// 	},
-	// 	stopFindBule() {
-	// 		console.log("停止搜寻附近的蓝牙外围设备---------------");
-	// 		uni.stopBluetoothDevicesDiscovery({
-	// 			success(res) {
-	// 				console.log(res);
-	// 			}
-	// 		});
-	// 	},
-	// 	onConn(item) {
-	// 		var that = this;
-	// 		console.log("连接蓝牙---------------" + item.deviceId);
-	// 		let deviceId = item.deviceId;
-	// 		uni.createBLEConnection({
-	// 			deviceId: deviceId,
-	// 			complete(res) {
-	// 				if (res.errMsg == "createBLEConnection:ok") {
-	// 					uni.setStorageSync('BLE',item);
-	// 					console.log("连接蓝牙-[" + item.name + "]--成功");
-	// 					that.$msg("连接蓝牙-[" + item.name + "]--成功");
-	// 					that.connId = deviceId;
-	// 					that.currDev = item;
-	// 					setTimeout(function() {
-	// 						that.getBLEServices(deviceId);
-	// 					}, 2000);
-	// 				} else {
-	// 					console.log(res);
-	// 				}
-	// 				//连接成功 关闭搜索
-	// 				that.stopFindBule();
-	// 			}
-	// 		});
-	// 	},
-	//
-	// 	getBLEServices(_deviceId) {
-	// 		var that = this;
-	// 		let deviceId = _deviceId;
-	// 		console.log("获取蓝牙设备所有服务(service)");
-	//
-	// 		uni.getBLEDeviceServices({
-	// 			// 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
-	// 			deviceId: deviceId,
-	// 			complete(res) {
-	// 				console.log(res);
-	// 				let serviceId = "";
-	//
-	// 				for (var s = 0; s < res.services.length; s++) {
-	// 					console.log(res.services[s].uuid);
-	// 					let serviceId = res.services[s].uuid;
-	// 					uni.getBLEDeviceCharacteristics({
-	// 						// 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
-	// 						deviceId: deviceId,
-	// 						// 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
-	// 						serviceId: serviceId,
-	// 						success(res) {
-	// 							var re = JSON.parse(JSON.stringify(res));
-	//
-	// 							console.log(
-	// 								"deviceId = [" + deviceId + "]  serviceId = [" + serviceId + "]"
-	// 							);
-	// 							for (var c = 0; c < re.characteristics.length; c++) {
-	// 								if (re.characteristics[c].properties.write == true) {
-	// 									let uuid = re.characteristics[c].uuid;
-	// 									console.log(
-	// 										" deviceId = [" +
-	// 											deviceId +
-	// 											"]  serviceId = [" +
-	// 											serviceId +
-	// 											"] characteristics=[" +
-	// 											uuid
-	// 									);
-	//
-	// 									for (var index in that.devices) {
-	// 										if (that.devices[index].deviceId == deviceId) {
-	// 											that.devices[index].services.push({
-	// 												serviceId: serviceId,
-	// 												characteristicId: uuid
-	// 											});
-	// 											break;
-	// 										}
-	// 									}
-	// 									console.log(JSON.stringify(that.devices));
-	// 								}
-	// 							}
-	// 						}
-	// 					});
-	// 				}
-	// 			},
-	// 			fail(res) {
-	// 				console.log(res);
-	// 			}
-	// 		});
-	// 	},
-	// 	senBlData(deviceId, serviceId, characteristicId, uint8Array) {
-	// 		console.log("************deviceId = [" +deviceId +"]  serviceId = [" +serviceId +"] characteristics=[" +characteristicId +"]");
-	// 		var uint8Buf = Array.from(uint8Array);
-	// 		function split_array(datas, size) {
-	// 			var result = {};
-	// 			var j = 0;
-	// 			for (var i = 0; i < datas.length; i += size) {
-	// 				result[j] = datas.slice(i, i + size);
-	// 				j++;
-	// 			}
-	// 			console.log(result);
-	// 			return result;
-	// 		}
-	// 		var sendloop = split_array(uint8Buf, 20);
-	// 		// console.log(sendloop.length)
-	// 		function realWriteData(sendloop, i) {
-	// 			var data = sendloop[i];
-	// 			if (typeof data == "undefined") {
-	// 				return;
-	// 			}
-	// 			console.log("第【" + i + "】次写数据" + data);
-	// 			var buffer = new ArrayBuffer(data.length);
-	// 			var dataView = new DataView(buffer);
-	// 			for (var j = 0; j < data.length; j++) {
-	// 				dataView.setUint8(j, data[j]);
-	// 			}
-	// 			uni.writeBLECharacteristicValue({
-	// 				deviceId,
-	// 				serviceId,
-	// 				characteristicId,
-	// 				value: buffer,
-	// 				success(res) {
-	// 					realWriteData(sendloop, i + 1);
-	// 				}
-	// 			});
-	// 		}
-	// 		var i = 0;
-	// 		realWriteData(sendloop, i);
-	// 	},
-	// 	senBleLabel() {
-	// 		//标签模式
-	// 		let deviceId = this.currDev.deviceId;
-	// 		let serviceId = this.currDev.services[0].serviceId;
-	// 		let characteristicId = this.currDev.services[0].characteristicId;
-	// 		var command = tsc.jpPrinter.createNew();
-	// 		command.setSize(40, 60);
-	// 		command.setGap(2);
-	// 		command.setCls();
-	// 		// command.setText(50, 10, "TSS24.BF2", 1, 1, "打印测试")
-	// 		// command.setQR(50, 50, "L", 5, "A", "977767937@qq.com")
-	// 		// command.setQR(a, b, c, d,    e,       f ")
-	// 		command.setText(30, 0, 2, 0, "arial", "测试");
-	// 		command.setText("福建省厦门市集美管控黄庄三里9号绿意花街");
-	// 		// command.setText("阿斯顿",'','13333333333');
-	// 		// command.setText(10, 90, "TSS24.BF2", 1, 1, "收花人电话:5521667788");
-	// 		// command.setText(10, 130, "TSS24.BF2", 1, 1, "收花时间:2020-6-10 上午");
-	// 		// command.setText(10,170,"TSS24.BF2",1,1,"收花地址:11111厦门市集美区凤林前山路147号110室");
-	// 		command.setPagePrint();
-	// 		this.senBlData(deviceId, serviceId, characteristicId, command.getData());
-	// 	},
-	// 	billPrint() {
-	// 		//票据模式
-	// 		let deviceId = this.currDev.deviceId;
-	// 		let serviceId = this.currDev.services[0].serviceId;
-	// 		let characteristicId = this.currDev.services[0].characteristicId;
-	// 		var command = esc.jpPrinter.createNew();
-	// 		command.init();
-	// 		command.setText(this.piaojuText);
-	// 		command.setPrintAndFeedRow(1);
-	// 		this.senBlData(deviceId, serviceId, characteristicId, command.getData());
-	// 	}
-	// }
-};
-</script>
-