|  |  |  |  | <template> | 
					
						
							|  |  |  |  | 	<view class="Big"> | 
					
						
							|  |  |  |  | 		<view id="page"> | 
					
						
							|  |  |  |  | 			<!-- 导航栏 --> | 
					
						
							|  |  |  |  | 			<view v-if="showPop"> | 
					
						
							|  |  |  |  | 				<view > | 
					
						
							|  |  |  |  | 					<text class="font-sm text-secondary px-3 py-2">ilsApi地址IP+端口</text> | 
					
						
							|  |  |  |  | 					<input type="text" class="font-md border bg-white px-3" placeholder="请填写ilsApi地址IP+端口" style="height: 100rpx;" v-model="ilsApi"/> | 
					
						
							|  |  |  |  | 				</view> | 
					
						
							|  |  |  |  | 				<view > | 
					
						
							|  |  |  |  | 					<text class="font-sm text-secondary px-3 py-2">打印机地址IP</text> | 
					
						
							|  |  |  |  | 					<input type="text" class="font-md border bg-white px-3" placeholder="请填写打印机地址IP" style="height: 100rpx;" v-model="printIp"/> | 
					
						
							|  |  |  |  | 				</view> | 
					
						
							|  |  |  |  | 				<view > | 
					
						
							|  |  |  |  | 					<text class="font-sm text-secondary px-3 py-2">打印机名称</text> | 
					
						
							|  |  |  |  | 					<input type="text" class="font-md border bg-white px-3" placeholder="请填写打印机名称" style="height: 100rpx;" v-model="printName"/> | 
					
						
							|  |  |  |  | 				</view> | 
					
						
							|  |  |  |  | 				<view > | 
					
						
							|  |  |  |  | 				        <button class="systemSty" @tap="cancelAdd">取消</button> | 
					
						
							|  |  |  |  | 				        <button class="systemSty" @tap="confirmAdd">确定</button> | 
					
						
							|  |  |  |  | 				</view> | 
					
						
							|  |  |  |  | 			</view>		 | 
					
						
							|  |  |  |  | 			当前单号: | 
					
						
							|  |  |  |  | 			<text class="nameSty">{{codes}}</text> | 
					
						
							|  |  |  |  | 			<button v-if="!showPop" @click="pdaSystemInit()" class="systemSty">PDA设置</button> | 
					
						
							|  |  |  |  | 			<button v-if="codes" @click="doPrinter(codes)" class="nameSty">再次打印</button> | 
					
						
							|  |  |  |  | 		</view> | 
					
						
							|  |  |  |  | 		<scan-code></scan-code> | 
					
						
							|  |  |  |  | 		</view> | 
					
						
							|  |  |  |  | </template> | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | <script> | 
					
						
							|  |  |  |  | 	import scanCode from "@/components/scan-code/scan-code.vue"; | 
					
						
							|  |  |  |  | 	// import { getCLodop } from '@/common/print/CLodopfuncs.js';
 | 
					
						
							|  |  |  |  | 	// import { getPrinterList } from '@/common/print/CLodopfuncs.js';
 | 
					
						
							|  |  |  |  | 	const printPdf = uni.requireNativePlugin('YanYu-PrintPDF'); | 
					
						
							|  |  |  |  | 	 | 
					
						
							|  |  |  |  | 	export default { | 
					
						
							|  |  |  |  | 		data() { | 
					
						
							|  |  |  |  | 			return { | 
					
						
							|  |  |  |  | 				codes: undefined, | 
					
						
							|  |  |  |  | 				showPop: false, | 
					
						
							|  |  |  |  | 				selectClassEnd:[], | 
					
						
							|  |  |  |  | 				httpRoot: 'http://', | 
					
						
							|  |  |  |  | 				ilsApi: '192.168.1.56:9090', | 
					
						
							|  |  |  |  | 				printIp: '192.168.1.56', | 
					
						
							|  |  |  |  | 				serviceApi: ':8080/ilsApp/print', | 
					
						
							|  |  |  |  | 				printName: 'Xprinter', | 
					
						
							|  |  |  |  | 				onLoad(option) { | 
					
						
							|  |  |  |  | 					this.$broadcastScan.init(this.getScancode); | 
					
						
							|  |  |  |  | 				}, | 
					
						
							|  |  |  |  | 				onUnload() { | 
					
						
							|  |  |  |  | 					this.$broadcastScan.stop(); | 
					
						
							|  |  |  |  | 				}, | 
					
						
							|  |  |  |  | 				onHide() { | 
					
						
							|  |  |  |  | 					this.$broadcastScan.stop(); | 
					
						
							|  |  |  |  | 				}, | 
					
						
							|  |  |  |  | 				onShow() { | 
					
						
							|  |  |  |  | 					this.$broadcastScan.start(); | 
					
						
							|  |  |  |  | 				} | 
					
						
							|  |  |  |  | 			} | 
					
						
							|  |  |  |  | 		}, | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		methods: { | 
					
						
							|  |  |  |  | 			pdaSystemInit: function(){ | 
					
						
							|  |  |  |  | 				this.showPop = true; | 
					
						
							|  |  |  |  | 			}, | 
					
						
							|  |  |  |  | 			selectClass(event){ | 
					
						
							|  |  |  |  | 			      | 
					
						
							|  |  |  |  | 			     }, | 
					
						
							|  |  |  |  | 			confirmAdd() { | 
					
						
							|  |  |  |  | 				//确认
 | 
					
						
							|  |  |  |  | 				this.showPop = false; | 
					
						
							|  |  |  |  | 				console.log("ilsApi:", this.ilsApi); | 
					
						
							|  |  |  |  | 				console.log("printIp:", this.printIp); | 
					
						
							|  |  |  |  | 			}, | 
					
						
							|  |  |  |  | 			cancelAdd() {   | 
					
						
							|  |  |  |  | 				//取消
 | 
					
						
							|  |  |  |  | 				this.ilsApi = ''; | 
					
						
							|  |  |  |  | 				this.printIp = ''; | 
					
						
							|  |  |  |  | 				this.showPop = false;		   | 
					
						
							|  |  |  |  | 			}, | 
					
						
							|  |  |  |  | 			// 打印
 | 
					
						
							|  |  |  |  | 			doPrinter: function(orderCoder) { | 
					
						
							|  |  |  |  | 				this.showPop = false; | 
					
						
							|  |  |  |  |                 console.log("doPrinter orderCoder: " + orderCoder); | 
					
						
							|  |  |  |  | 				console.log("ilsApi:", this.ilsApi); | 
					
						
							|  |  |  |  | 				console.log("printIp:", this.printIp); | 
					
						
							|  |  |  |  | 				uni.request({ | 
					
						
							|  |  |  |  | 				    url: this.httpRoot + this.printIp + this.serviceApi,	 | 
					
						
							|  |  |  |  | 					method: 'POST', | 
					
						
							|  |  |  |  | 					data: { | 
					
						
							|  |  |  |  | 							ilsApi: this.ilsApi, | 
					
						
							|  |  |  |  | 							printIp: this.printIp, | 
					
						
							|  |  |  |  | 							orderId: orderCoder, | 
					
						
							|  |  |  |  | 							printName: this.printName | 
					
						
							|  |  |  |  | 						}, | 
					
						
							|  |  |  |  | 				    success: (res) => { | 
					
						
							|  |  |  |  | 				        console.log( res); | 
					
						
							|  |  |  |  | 						if(res.data.code==200){ | 
					
						
							|  |  |  |  | 							uni.showToast({ | 
					
						
							|  |  |  |  | 								title: '面单下发成功.正在打印,请稍候...', | 
					
						
							|  |  |  |  | 								icon: 'none', | 
					
						
							|  |  |  |  | 								duration: 3000 | 
					
						
							|  |  |  |  | 							}); | 
					
						
							|  |  |  |  | 						}else{ | 
					
						
							|  |  |  |  | 							uni.showToast({ | 
					
						
							|  |  |  |  | 							    title: res.data.message, | 
					
						
							|  |  |  |  | 							    icon: 'none', | 
					
						
							|  |  |  |  | 							    duration: 3000 | 
					
						
							|  |  |  |  | 							}) | 
					
						
							|  |  |  |  | 						} | 
					
						
							|  |  |  |  | 				    }, | 
					
						
							|  |  |  |  | 					fail: (error) => { | 
					
						
							|  |  |  |  | 						uni.showToast({ | 
					
						
							|  |  |  |  | 						    title: '接口访问异常,打印失败', | 
					
						
							|  |  |  |  | 						    icon: 'none', | 
					
						
							|  |  |  |  | 						    duration: 3000 | 
					
						
							|  |  |  |  | 						}) | 
					
						
							|  |  |  |  | 					}, | 
					
						
							|  |  |  |  | 				}); | 
					
						
							|  |  |  |  | 			}, | 
					
						
							|  |  |  |  | 			onShow: function() { | 
					
						
							|  |  |  |  | 				var _this = this; | 
					
						
							|  |  |  |  | 				uni.$off('scancodedate'); // 每次进来先 移除全局自定义事件监听器
 | 
					
						
							|  |  |  |  | 				uni.$on('scancodedate', function(data) { | 
					
						
							|  |  |  |  | 					console.log('你想要的code:', data.code); | 
					
						
							|  |  |  |  | 					_this.codes = data.code; | 
					
						
							|  |  |  |  | 					_this.showPop = false; | 
					
						
							|  |  |  |  | 					let orderCoder = data.code; | 
					
						
							|  |  |  |  | 					console.log("onShow orderCoder: " + orderCoder); | 
					
						
							|  |  |  |  | 					console.log("ilsApi:", _this.ilsApi); | 
					
						
							|  |  |  |  | 					console.log("printIp:", _this.printIp); | 
					
						
							|  |  |  |  | 					console.log("serviceApi:", _this.httpRoot + _this.printIp + _this.serviceApi); | 
					
						
							|  |  |  |  | 					if(orderCoder.length>18){ | 
					
						
							|  |  |  |  | 						//orderCoder = "SF1642682535344";
 | 
					
						
							|  |  |  |  | 						uni.request({ | 
					
						
							|  |  |  |  | 							url: _this.httpRoot + _this.printIp + _this.serviceApi, | 
					
						
							|  |  |  |  | 							method: 'POST', | 
					
						
							|  |  |  |  | 							data: { | 
					
						
							|  |  |  |  | 									ilsApi: _this.ilsApi, | 
					
						
							|  |  |  |  | 									printIp: _this.printIp, | 
					
						
							|  |  |  |  | 									orderId: orderCoder, | 
					
						
							|  |  |  |  | 									printName: _this.printName | 
					
						
							|  |  |  |  | 								}, | 
					
						
							|  |  |  |  | 							success: (res) => { | 
					
						
							|  |  |  |  | 								console.log( res); | 
					
						
							|  |  |  |  | 								if(res.data.code==200){ | 
					
						
							|  |  |  |  | 									uni.showToast({ | 
					
						
							|  |  |  |  | 										title: '下发成功.正在打印,请稍候...', | 
					
						
							|  |  |  |  | 										icon: 'none', | 
					
						
							|  |  |  |  | 										duration: 3000 | 
					
						
							|  |  |  |  | 									}); | 
					
						
							|  |  |  |  | 								}else{ | 
					
						
							|  |  |  |  | 									uni.showToast({ | 
					
						
							|  |  |  |  | 										title: res.data.message, | 
					
						
							|  |  |  |  | 										icon: 'none', | 
					
						
							|  |  |  |  | 										duration: 3000 | 
					
						
							|  |  |  |  | 									}) | 
					
						
							|  |  |  |  | 								} | 
					
						
							|  |  |  |  | 							}, | 
					
						
							|  |  |  |  | 							fail: (error) => { | 
					
						
							|  |  |  |  | 								console.log("error: ", error); | 
					
						
							|  |  |  |  | 								uni.showToast({ | 
					
						
							|  |  |  |  | 									title: '接口访问异常,打印失败', | 
					
						
							|  |  |  |  | 									icon: 'none', | 
					
						
							|  |  |  |  | 									duration: 3000 | 
					
						
							|  |  |  |  | 								}) | 
					
						
							|  |  |  |  | 							}, | 
					
						
							|  |  |  |  | 						}); | 
					
						
							|  |  |  |  | 					}else{ | 
					
						
							|  |  |  |  | 						uni.showToast({ | 
					
						
							|  |  |  |  | 								title: '非法单号', | 
					
						
							|  |  |  |  | 								icon: 'none', | 
					
						
							|  |  |  |  | 								duration: 3000 | 
					
						
							|  |  |  |  | 						}) | 
					
						
							|  |  |  |  | 					} | 
					
						
							|  |  |  |  | 				}) | 
					
						
							|  |  |  |  | 			}, | 
					
						
							|  |  |  |  | 			getScancode(code) { | 
					
						
							|  |  |  |  | 				// 有些PDA会自带换行符,trim函数处理下
 | 
					
						
							|  |  |  |  | 				code = code.trim() | 
					
						
							|  |  |  |  | 				//code就是扫描获取的值
 | 
					
						
							|  |  |  |  | 				console.log(code) | 
					
						
							|  |  |  |  | 			}, | 
					
						
							|  |  |  |  | 			printPdf() { | 
					
						
							|  |  |  |  | 				// 有些PDA会自带换行符,trim函数处理下
 | 
					
						
							|  |  |  |  | 				printPdf.managerPrint("D:\LeStoreDownload\EXP-LHJ1239002405-3676E4041337.pdf"); | 
					
						
							|  |  |  |  | 			} | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | </script> | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | <style> | 
					
						
							|  |  |  |  | .Big{ | 
					
						
							|  |  |  |  | 	width: 220px; | 
					
						
							|  |  |  |  | 	margin: 200px 100px; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | .nameSty{ | 
					
						
							|  |  |  |  | 	height: 30px; | 
					
						
							|  |  |  |  | 	width: 220px !important; | 
					
						
							|  |  |  |  | 	line-height: 30px; | 
					
						
							|  |  |  |  | 	font-size: 18px; | 
					
						
							|  |  |  |  | 	font-weight: bold; | 
					
						
							|  |  |  |  | 	color: #828282 !important; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | /deep/.u-size-default,/deep/.uni-input-input{ | 
					
						
							|  |  |  |  | 	font-size: 18px; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | </style> |