|  |  | <template>
 | 
						
						
						
							|  |  | 	<view class="Big">
 | 
						
						
						
							|  |  | 		<view id="page">
 | 
						
						
						
							|  |  | 			<!-- 导航栏 -->
 | 
						
						
						
							|  |  | 			<view v-if="showPop">
 | 
						
						
						
							|  |  | 				<view >
 | 
						
						
						
							|  |  | 					<text class="font-sm text-secondary px-3 py-2">ilsApi地址</text>
 | 
						
						
						
							|  |  | 					<input type="text" class="font-md border bg-white px-3" placeholder="请填写ilsApi地址" 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="请填写ilsApi地址" style="height: 100rpx;" v-model="printIp"/>
 | 
						
						
						
							|  |  | 				</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';
 | 
						
						
						
							|  |  | 	const printPdf = uni.requireNativePlugin('YanYu-PrintPDF');
 | 
						
						
						
							|  |  | 	
 | 
						
						
						
							|  |  | 	export default {
 | 
						
						
						
							|  |  | 		data() {
 | 
						
						
						
							|  |  | 			return {
 | 
						
						
						
							|  |  | 				codes: undefined,
 | 
						
						
						
							|  |  | 				showPop: false,
 | 
						
						
						
							|  |  | 				httpRoot: 'http://',
 | 
						
						
						
							|  |  | 				ilsApi: '192.168.1.56:9090',
 | 
						
						
						
							|  |  | 				printIp: '192.168.1.26',
 | 
						
						
						
							|  |  | 				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;	
 | 
						
						
						
							|  |  | 			},
 | 
						
						
						
							|  |  | 			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);
 | 
						
						
						
							|  |  | 				// LODOP.PRINT_INIT(null, "192.168.1.26");
 | 
						
						
						
							|  |  | 				// LODOP.SET_PRINTER_INDEX(-1);
 | 
						
						
						
							|  |  | 				// LODOP.PRINT_INITA(0, 0, "100mm", "150mm", "100X150");
 | 
						
						
						
							|  |  | 				// LODOP.SET_PRINT_PAGESIZE(1, "100mm", "150mm", "");
 | 
						
						
						
							|  |  | 				// LODOP.SET_PRINT_MODE("POS_BASEON_PAPER", true);
 | 
						
						
						
							|  |  | 				// //LODOP.ADD_PRINT_HTM(10, 20, "100mm", "150mm", "<img src="+this.imageData+" style=\"width: 100mm; height: 100mm;\"/>");
 | 
						
						
						
							|  |  | 				// LODOP.ADD_PRINT_PDF(0, 0, "100mm", "150mm", this.imgePdfData);
 | 
						
						
						
							|  |  | 				// LODOP.PRINT();
 | 
						
						
						
							|  |  | 			
 | 
						
						
						
							|  |  | 				uni.request({
 | 
						
						
						
							|  |  | 				    url: this.httpRoot + this.ilsApi + '/jeecg-boot/front/getOrderPayStateAndPdfBase64?OrderId=' + orderCoder,
 | 
						
						
						
							|  |  | 					method: 'GET',
 | 
						
						
						
							|  |  | 				    success: (res) => {
 | 
						
						
						
							|  |  | 				        console.log( res.data.result);
 | 
						
						
						
							|  |  | 						if(res.data.code==200){
 | 
						
						
						
							|  |  | 							let LODOP = getCLodop();
 | 
						
						
						
							|  |  | 							LODOP.PRINT_INIT(null, this.printIp);
 | 
						
						
						
							|  |  | 							LODOP.SET_PRINTER_INDEX(-1);
 | 
						
						
						
							|  |  | 							LODOP.PRINT_INITA(2, 0, "100mm", "150mm", "100X150");
 | 
						
						
						
							|  |  | 							LODOP.SET_PRINT_PAGESIZE(1, "100mm", "150mm", "");
 | 
						
						
						
							|  |  | 							LODOP.SET_PRINT_MODE("POS_BASEON_PAPER", true);
 | 
						
						
						
							|  |  | 							// LODOP.ADD_PRINT_HTM(2, 0, "100mm", "150mm", "<img src="+ this.imgBase64Root + res.data.message+" style=\"width: 100mm; height: 100mm;\"/>");
 | 
						
						
						
							|  |  | 							LODOP.ADD_PRINT_PDF(0, 0, "100mm", "150mm", res.data.result);
 | 
						
						
						
							|  |  | 							LODOP.PRINT();
 | 
						
						
						
							|  |  | 							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);
 | 
						
						
						
							|  |  | 					//orderCoder = "SF1642682535344";
 | 
						
						
						
							|  |  | 					uni.request({
 | 
						
						
						
							|  |  | 					    url: _this.httpRoot + _this.ilsApi + '/jeecg-boot/front/getOrderPayStateAndPdfBase64?OrderId=' + orderCoder,
 | 
						
						
						
							|  |  | 						method: 'GET',
 | 
						
						
						
							|  |  | 					    success: (res) => {
 | 
						
						
						
							|  |  | 					        console.log( res.data.result);
 | 
						
						
						
							|  |  | 							if(res.data.code==200){
 | 
						
						
						
							|  |  | 								let LODOP = getCLodop();
 | 
						
						
						
							|  |  | 								LODOP.PRINT_INIT(null, _this.printIp);
 | 
						
						
						
							|  |  | 								LODOP.SET_PRINTER_INDEX(-1);
 | 
						
						
						
							|  |  | 								LODOP.PRINT_INITA(2, 0, "100mm", "150mm", "100X150");
 | 
						
						
						
							|  |  | 								LODOP.SET_PRINT_PAGESIZE(1, "100mm", "150mm", "");
 | 
						
						
						
							|  |  | 								LODOP.SET_PRINT_MODE("POS_BASEON_PAPER", true);
 | 
						
						
						
							|  |  | 								// LODOP.ADD_PRINT_HTM(2, 0, "100mm", "150mm", "<img src="+ this.imgBase64Root + res.data.message+" style=\"width: 100mm; height: 100mm;\"/>");
 | 
						
						
						
							|  |  | 								LODOP.ADD_PRINT_PDF(0, 0, "100mm", "150mm", res.data.result);
 | 
						
						
						
							|  |  | 								LODOP.PRINT();
 | 
						
						
						
							|  |  | 								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
 | 
						
						
						
							|  |  | 							})
 | 
						
						
						
							|  |  | 						},
 | 
						
						
						
							|  |  | 					});
 | 
						
						
						
							|  |  | 				})
 | 
						
						
						
							|  |  | 			},
 | 
						
						
						
							|  |  | 			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>
 |