From f26f29d84e0a68831a6af14dab3eec5500496d2e Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期三, 28 五月 2025 16:48:52 +0800
Subject: [PATCH] 初始化项目

---
 pages/product/labelPrint/labelPrint.vue |  711 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 711 insertions(+), 0 deletions(-)

diff --git a/pages/product/labelPrint/labelPrint.vue b/pages/product/labelPrint/labelPrint.vue
new file mode 100644
index 0000000..7c16b34
--- /dev/null
+++ b/pages/product/labelPrint/labelPrint.vue
@@ -0,0 +1,711 @@
+<template>
+	<view class="app">
+		<view class="main">			
+			<view class="cu-card list">
+			<block v-for="(item,index) in listss" v-bind:key="index">
+				<view class="cu-item du-item shadow u-rela"  style="overflow:hidden;">		
+					<!-- <view class="content">
+						<text class="text-grey margin-left-sm text-df">鍘熸枡缂栧彿</text>
+						<text
+							class="text-black margin-left text-df">{{item.materialCode}}</text>
+					</view>	 -->
+					<view class="content">
+						<text class="text-grey margin-left-sm text-df">鍘熸枡浠g爜</text>
+						<text
+							class="text-black margin-left text-df">{{item.sn}}</text>
+					</view>	
+					<view class="content">
+						<text class="text-grey margin-left-sm text-df">鍘熸枡鍚嶇О</text>
+						<text
+							class="text-black margin-left text-df">{{item.type}}</text>
+					</view>		
+					<view class="content">
+						<text class="text-grey margin-left-sm text-df">鍘熸枡鎵瑰彿</text>
+						<text   class="text-black margin-left text-df">{{item.code}}</text>
+					</view>
+					<view class="content">
+						<text class="text-grey margin-left-sm text-df">鐩镐綅</text>
+						<text class="text-black margin-left text-df">{{item.img}}</text>
+					</view>
+					<view class="content">
+						<text class="text-grey margin-left-sm text-df"></text>
+						
+						<text   class="text-black margin-left text-df" style="flex:0.5">
+							<button class="_btn"  @click="weighPrintHandle(item)"  >绉伴噺鎵撳嵃</button>
+						</text>
+					</view>
+
+				</view>
+				
+			</block>
+			</view>
+			<view v-if="maskShow" class="uni-mask" @touchmove.stop.prevent="moveHandle" @click="maskclose">
+				<scroll-view class="uni-scroll_box" scroll-y @touchmove.stop.prevent="moveHandle" @click.stop="moveHandle">
+					<view
+						class="uni-list-box"
+						v-for="(item, index) in list"
+						:key="index"
+						@click="tapQuery(item)"
+					>
+						<view>
+							<view class="uni-list_name">鍚嶇О锛歿{ item.name }}</view>
+							<view class="uni-list_item">UUID:{{ item.address }}</view>
+						</view>
+					</view>
+				</scroll-view>
+			</view>
+			<uni-fab :pattern="pattern" horizontal="right" vertical="bottom" :popMenu="false" @fabClick="searchDevice" :doc="doc">
+			</uni-fab>
+							
+		</view>
+	</view>
+</template>
+<script>
+	const jcapi = uni.requireNativePlugin("JCSDK-JCApiModule");
+	// 浜岀淮鐮佺被鍨�
+	const QrCodeType = {
+		QrCode: 31,
+		PDF417: 32,
+		DataMatrix: 33,
+		AZTEC: 34
+	}
+	
+	// 绾挎潯绫诲瀷
+	const LineType = {
+		Solid: 1, // 瀹炵嚎
+		Dotted: 2, // 铏氱嚎锛堥粯璁よ櫄瀹�1:1鐩搁棿锛�
+	}
+	
+	// 鎹㈣鏂瑰紡
+	const LineModeType = {
+		Justified: 1, // 瀹介珮鍥哄畾锛屽唴瀹硅嚜閫傚簲锛堝瓧鍙�/瀛楅棿璺�/琛岄棿璺濇寜姣斾緥缂╂斁锛�
+		AutoHeight: 2, // 瀹藉害鍥哄畾锛岄珮搴﹁嚜閫傚簲
+		Fixed: 4, // 瀹介珮鍥哄畾锛岃秴鍑洪儴鍒嗚鍓�
+		Adapt: 6, // 瀹介珮鍥哄畾锛屽唴瀹硅秴杩囨椂棰勮瀹介珮鑷姩缂╁皬
+	}
+	
+	export default {
+		onLoad() {
+			let _this = this;
+			// 鍒濆鍖朣DK
+			jcapi.initSDK()
+			// 鐩戝惉椤电爜鍥炶皟
+			jcapi.didReadPrintCountInfo(function(r) {
+				console.log(r)
+			})
+			
+			// 鐩戝惉閿欒鍥炶皟
+			jcapi.didReadPrintErrorInfo(function(r) {
+				console.log(r)
+				if(r.code == 23) {
+					// 鎵撳嵃鏈烘柇寮�杩炴帴
+					_this.connectedDevice = null
+				}
+				uni.showToast({
+					icon: 'none',
+					title: JSON.stringify(r),
+					duration: 2 * 1000
+				})
+			})
+		},
+		onShow() {
+		},
+		onNavigationBarButtonTap(e) {
+			uni.scanCode({
+				success: res => {
+					try {
+						const result = JSON.parse(res.result)
+					
+					} catch (e) {}
+				}
+			});
+		},
+		data() {	
+			
+			return {
+				//鎵撳嵃鏁版嵁
+				listss:[
+					{
+						sn:"2024GY-010070",
+						type:"骞插彉楂樺帇绾垮湀",
+						orderNo:"2024061200010",
+						img:"CS03",
+						typeTwo:"CS03",
+						ptodect:"鍒樺鏍�,鎴村厓娴�,钁h繋璧�",
+						date:"2024-06-10"
+					}
+				],
+				//鎵撳嵃鐩稿叧
+				doc:"钃濈墮",
+				pattern: {
+					color: '#7A7E83',
+					backgroundColor: '#fff',
+					selectedColor: '#007AFF',
+					buttonColor: '#007AFF',
+					iconColor: '#fff'
+				},
+				maskShow: false,
+				list:[],//钃濈墮璁惧鏁版嵁
+				printDensity: 5,
+				labelType: 1,
+				printMode: 2,//printModeData: [{name : '鐑晱', value: 1}, {name: '鐑浆鍗�', value: 2}],
+			}
+		},
+		computed:{
+		},
+		methods: {
+			moveHandle() {},
+			maskclose() {
+				this.maskShow = false;
+			},
+			searchDevice(){
+				let _this = this
+				uni.openBluetoothAdapter({ // 纭钃濈墮鏄惁鎵撳紑
+					success(r) {
+						uni.showLoading({
+							title: "鎼滅储涓�..."
+						})
+						// 鏈巿浜堣摑鐗欑浉鍏虫潈闄愬拰鏈墦寮�鎵嬫満瀹氫綅浼氭悳绱笉鍒拌澶�
+						jcapi.getBluetoothDevices(function(r){
+							console.log("device:" + JSON.stringify(r))
+							// 鎼滅储鍒拌澶囧洖璋�
+							uni.hideLoading()
+							_this.list = r;
+							_this.maskShow = true	
+						})
+					},
+					fail(e) {
+						uni.showModal({
+							confirmText: "鎵撳紑钃濈墮澶辫触"
+						})
+						console.log("寮�鍚摑鐗欒澶囧け璐�" + e)
+					}
+				})
+			},
+			tapQuery(item) {
+				this.maskShow = false
+				// 杩炴帴鎵撳嵃鏈�
+				let _this = this;
+				jcapi.openPrinterByDevice({
+					address: item.address,
+					name: item.name,
+					deviceType: item.deviceType // 璁惧绫诲瀷锛�0-钃濈墮锛�1-缃戠粶
+				}, function(r) {
+					uni.showToast({
+						title: (r.code == 0) ? "杩炴帴鎴愬姛" : "杩炴帴澶辫触",
+						duration: 2 * 1000
+					})
+					if(r.code == 0) {
+						_this.connectedDevice = item
+					}
+				})
+			},
+			weighPrintHandle(item)
+			{
+				this.printQrCode()
+			},
+			//鎵撳嵃浜岀淮鐮�
+			printQrCode() {
+				// 鍒濆鍖栫敾鏉�
+				jcapi.initDrawingBoard({
+					width: 50,
+					height: 100,
+					rotate: 0
+				});
+				// // 缁樺埗浜岀淮鐮�
+				var jsonString = JSON.stringify(this.listss[0]);
+				jcapi.drawLabelQrCode({
+					x: 17,
+					y: 74,
+					width: 20,
+					height: 20,
+					value: jsonString,
+					rotate: 0,
+					codeType: QrCodeType.QrCode,
+				});
+				//缁樺埗妯嚎
+				jcapi.drawLabelLine({
+					x: 4,
+					y: 1,
+					width: 46,
+					height: 0.5,
+					rotate: 0,
+					lineType: LineType.Solid // 瀹炵嚎1
+				});
+				
+				jcapi.drawLabelLine({
+					x:4,
+					y: 11,
+					width: 46,
+					height: 0.5,
+					rotate: 0,
+					lineType: LineType.Solid // 瀹炵嚎2
+				});
+				
+				jcapi.drawLabelLine({
+					x: 4,
+					y: 21,
+					width: 46,
+					height: 0.5,
+					rotate: 0,
+					lineType: LineType.Solid // 瀹炵嚎3
+				});
+				
+				jcapi.drawLabelLine({
+					x: 4,
+					y: 31,
+					width: 46,
+					height: 0.5,
+					rotate: 0,
+					lineType: LineType.Solid // 瀹炵嚎4
+				});
+				
+				jcapi.drawLabelLine({
+					x: 4,
+					y: 41,
+					width: 46,
+					height: 0.5,
+					rotate: 0,
+					lineType: LineType.Solid // 瀹炵嚎5
+				});
+				
+				jcapi.drawLabelLine({
+					x: 4,
+					y: 51,
+					width: 46,
+					height:0.5,
+					rotate: 0,
+					lineType: LineType.Solid // 瀹炵嚎6
+				});
+				
+				jcapi.drawLabelLine({
+					x:4,
+					y: 61,
+					width: 46,
+					height: 0.5,
+					rotate: 0,
+					lineType: LineType.Solid // 瀹炵嚎7
+				});
+				
+				jcapi.drawLabelLine({
+					x: 4,
+					y: 71,
+					width: 46,
+					height: 0.5,
+					rotate: 0,
+					lineType: LineType.Solid // 瀹炵嚎8
+				});
+				
+				jcapi.drawLabelLine({
+					x: 4,
+					y: 98,
+					width: 46,
+					height: 0.5,
+					rotate: 0,
+					lineType: LineType.Solid // 瀹炵嚎9
+				});
+				
+					//缁樺埗绔栫嚎
+					jcapi.drawLabelLine({
+						x: 4,
+						y: 1,
+						width: 0.5,
+						height: 97,
+						rotate: 0,
+						lineType: LineType.Solid // 瀹炵嚎
+					});
+					
+					
+					jcapi.drawLabelLine({
+						x: 20,
+						y: 1,
+						width: 0.5,
+						height: 70,
+						rotate: 0,
+						lineType: LineType.Solid // 瀹炵嚎9
+					});
+					
+					
+					jcapi.drawLabelLine({
+						x: 48.5,
+						y: 1,
+						width: 0.5,
+						height: 97,
+						rotate: 0,
+						lineType: LineType.Solid // 瀹炵嚎9
+					});
+					
+				// 	//缁樺埗鏂囧瓧
+					jcapi.drawLabelText({
+						x:1,
+						y:4,
+						width:20,
+						height: 12,
+						value: "缂� 鍙�:",
+						fontSize: 3.6,
+						rotate: 0,
+						lineMode: LineModeType.AutoHeight,
+						lineSpace: 0,
+						letterSpace: 0,
+						textAlignHorizontal: 1,
+						textAlignVertical: 1,
+					})
+					
+					jcapi.drawLabelText({
+						x:5,
+						y:14,
+						width:12,
+						height: 20,
+						value: "绫� 鍨�:",
+						fontSize:3.6,
+						rotate: 0,
+						lineMode: LineModeType.AutoHeight,
+						lineSpace: 0,
+						letterSpace: 0,
+						textAlignHorizontal: 1,
+						textAlignVertical: 1,
+					})
+					
+					jcapi.drawLabelText({
+						x:5,
+						y:24,
+						width:12,
+						height: 22,
+						value: "宸ュ崟鍙�:",
+						fontSize: 3.6,
+						rotate: 0,
+						lineMode: LineModeType.AutoHeight,
+						lineSpace: 0,
+						letterSpace: 0,
+						textAlignHorizontal: 1,
+						textAlignVertical: 1,
+					})
+					
+					jcapi.drawLabelText({
+						x:5,
+						y:34,
+						width:12,
+						height: 20,
+						value: "鍥� 鍙�:",
+						fontSize: 3.6,
+						rotate: 0,
+						lineMode: LineModeType.AutoHeight,
+						lineSpace: 0,
+						letterSpace: 0,
+						textAlignHorizontal: 1,
+						textAlignVertical: 1,
+					})
+					
+					jcapi.drawLabelText({
+						x:5,
+						y:44,
+						width:24,
+						height: 20,
+						value: "瑙勬牸鍨嬪彿:",
+						fontSize: 3.4,
+						rotate: 0,
+						lineMode: LineModeType.AutoHeight,
+						lineSpace: 0,
+						letterSpace: 0,
+						textAlignHorizontal: 0,
+						textAlignVertical: 1,
+					})
+					
+					jcapi.drawLabelText({
+						x:5,
+						y:54,
+						width:12,
+						height: 22,
+						value: "鐢熶骇浜�:",
+						fontSize: 3.6,
+						rotate: 0,
+						lineMode: LineModeType.AutoHeight,
+						lineSpace: 0,
+						letterSpace: 0,
+						textAlignHorizontal: 1,
+						textAlignVertical: 1,
+					})
+					
+					jcapi.drawLabelText({
+						x:5,
+						y:64,
+						width:24,
+						height: 20,
+						value: "鐢熶骇鏃ユ湡:",
+						fontSize: 3.4,
+						rotate: 0,
+						lineMode: LineModeType.AutoHeight,
+						lineSpace: 0,
+						letterSpace: 0,
+						textAlignHorizontal: 0,
+						textAlignVertical: 1,
+					})
+					
+					jcapi.drawLabelText({
+						x:22,
+						y:4,
+						width:40,
+						height: 12,
+						value: this.listss[0].sn,
+						fontSize: 3,
+						rotate: 0,
+						lineMode: LineModeType.AutoHeight,
+						lineSpace: 0,
+						letterSpace: 0,
+						textAlignHorizontal: 0,
+						textAlignVertical: 0,
+					})
+					
+					jcapi.drawLabelText({
+						x:22,
+						y:14,
+						width:40,
+						height: 12,
+						value: this.listss[0].type,
+						fontSize: 3,
+						rotate: 0,
+						lineMode: LineModeType.AutoHeight,
+						lineSpace: 0,
+						letterSpace: 0,
+						textAlignHorizontal: 0,
+						textAlignVertical: 0,
+					})
+					
+					jcapi.drawLabelText({
+						x:22,
+						y:24,
+						width:40,
+						height: 12,
+						value: this.listss[0].orderNo,
+						fontSize: 3,
+						rotate: 0,
+						lineMode: LineModeType.AutoHeight,
+						lineSpace: 0,
+						letterSpace: 0,
+						textAlignHorizontal: 0,
+						textAlignVertical: 0,
+					})
+					
+					jcapi.drawLabelText({
+						x:22,
+						y:34,
+						width:40,
+						height: 12,
+						value: this.listss[0].img,
+						fontSize: 3,
+						rotate: 0,
+						lineMode: LineModeType.AutoHeight,
+						lineSpace: 0,
+						letterSpace: 0,
+						textAlignHorizontal: 0,
+						textAlignVertical: 0,
+					})
+					
+					jcapi.drawLabelText({
+						x:22,
+						y:44,
+						width:40,
+						height: 12,
+						value: this.listss[0].typeTwo,
+						fontSize: 3,
+						rotate: 0,
+						lineMode: LineModeType.AutoHeight,
+						lineSpace: 0,
+						letterSpace: 0,
+						textAlignHorizontal: 0,
+						textAlignVertical: 0,
+					})
+					
+					jcapi.drawLabelText({
+						x:22,
+						y:53,
+						width:28,
+						height: 12,
+						value: this.listss[0].ptodect,
+						fontSize: 3,
+						rotate: 0,
+						lineMode: LineModeType.AutoHeight,
+						lineSpace: 0,
+						letterSpace: 0,
+						textAlignHorizontal: 0,
+						textAlignVertical: 0,
+					})
+					
+					jcapi.drawLabelText({
+						x:22,
+						y:64,
+						width:40,
+						height: 12,
+						value: this.listss[0].date,
+						fontSize: 3,
+						rotate: 0,
+						lineMode: LineModeType.AutoHeight,
+						lineSpace: 0,
+						letterSpace: 0,
+						textAlignHorizontal: 0,
+						textAlignVertical: 0,
+					})
+				
+				
+				// 鐢熸垚鎵撳嵃鏁版嵁
+				let imageJsonObj = jcapi.generateLabelJson()
+				// 璁剧疆鎵撳嵃浠诲姟
+				jcapi.startJob({
+					totalCount: 1,
+					density: this.printDensity,
+					labelType: this.labelType,
+					printMode: this.printMode,
+				},function(r){
+					if(r.code == 0) {
+						// 鎵撳嵃鏁版嵁
+						jcapi.printData(imageJsonObj, {
+							"printQuantity": 1,
+						}, function(r) {
+							if (r.code == 0) {
+								console.log("鎵撳嵃鎴愬姛")
+							} else {
+								console.log("鎵撳嵃澶辫触")
+							}
+						})
+					} else {
+						console.log("璁剧疆鎵撳嵃浠诲姟澶辫触")
+					}
+				})
+			}, 
+		}
+	}
+</script>
+
+<style scoped>
+	
+	
+	>>>.cu-custom .cu-bar
+	{
+		background: #3281FF !important;
+		height: 44px;
+		height: calc(44px + constant(safe-area-inset-top));
+		height: calc(44px + env(safe-area-inset-top));
+		padding: 7px 3px;
+		padding-top: calc(7px + constant(safe-area-inset-top));
+		padding-top: calc(7px + env(safe-area-inset-top));
+	}
+	
+	.content
+	{	display: flex;
+		flex-direction: row;
+		padding: 0 10rpx;}
+			
+	.content .text-grey
+	{
+		flex:0.8
+	}
+
+	.content .text-black
+	{
+		flex:2;
+		text-align: right;
+	}
+
+	.filter-content {
+		overflow-y: auto;
+		/* #ifdef H5 */
+		height: calc(100vh - 95px);
+		/* #endif */
+		/* #ifdef MP-WEIXIN */
+		height: calc(100vh - 125px);
+		/* #endif */
+		/* #ifdef APP-VUE */
+		height: calc(100vh - 145px);
+		/* #endif */
+		/* #ifdef APP-PLUS */
+		height: calc(100vh - 55px);
+		/* #endif */
+	}
+
+	uni-checkbox::before {
+		content: ''
+	}
+
+	.list>.cu-item .info {
+		border-top: 1px solid #f7f7f7;
+		padding-top: 10px;
+		margin-left: 10px;
+		margin-right: 5px;
+		padding-bottom: 10px;
+	}
+
+	.list>.cu-item .title {
+		margin-top: 15px;
+		margin-left: 10px;
+		margin-right: 10px;
+		margin-bottom: 10px;
+	}
+
+	.cu-card>.du-item {
+		display: block;
+		background-color: #FFFFFF;
+		overflow: hidden;
+		border-radius: 10upx;
+		margin: 20upx 24upx;
+	}
+
+	.cu-card>.du-item:first-child{margin-top: 10px;}
+	
+/* 	.main
+	{
+		color:#000;
+		padding:0 2%;
+	} */
+	
+	.bottom-btn
+	{
+		overflow:hidden;
+		margin:20px 0;
+		padding:0 2%;
+	}
+	
+	._btn
+	{
+		background:#3A80F4;
+		color:#FFF;
+		margin-bottom:20px;
+	}
+	
+	.uni-mask {
+		position: fixed;
+		top: 0;
+		left: 0;
+		bottom: 0;
+		display: flex;
+		align-items: center;
+		width: 100%;
+		background: rgba(0, 0, 0, 0.6);
+		padding: 0 30rpx;
+		box-sizing: border-box;
+	}
+	
+	
+	.uni-scroll_box {
+		height: 70%;
+		background: #fff;
+		border-radius: 20rpx;
+	}
+	.uni-list-box {
+		margin: 0 20rpx;
+		padding: 15rpx 0;
+		border-bottom: 1px #f5f5f5 solid;
+		box-sizing: border-box;
+	}
+	.uni-list:last-child {
+		border: none;
+	}
+	.uni-list_name {
+		font-size: 30rpx;
+		color: #333;
+	}
+	.uni-list_item {
+		font-size: 24rpx;
+		color: #555;
+		line-height: 1.5;
+	}
+</style>

--
Gitblit v1.9.3