<template>
	<view class="page" :style="themeColor">
		<view class="flex benben-position-layout flex flex-wrap align-center printerSettings_flex_0"
			:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex flex-wrap align-center justify-between flex-sub printerSettings_fd0_0'>
				<view class='flex flex-wrap align-center' @tap.stop="handleJumpDiy" data-type="back" data-url="1">
					<text class='fu-iconfont2  printerSettings_fd0_0_c0_c0' @tap.stop="handleJumpDiy" data-type="back"
						data-url="1">&#xE794;</text>
				</view>
				<view class='flex flex-wrap align-stretch justify-center flex-sub'>
					<text class='printerSettings_fd0_0_c1_c0'>打印机设置</text>
				</view>
				<view class='flex flex-wrap align-center printerSettings_fd0_0_c2'>
				</view>
			</view>

		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
		<!---暂无数据flex布局开始-->
		<view class="flex flex-direction flex-wrap align-center benben-flex-layout printerSettings_flex_1"
			v-if="isData=='1'">
			<view class='flex flex-wrap align-center printerSettings_fd1_0'>
				<image class='printerSettings_fd1_0_c0' mode="aspectFit" :src='STATIC_URL+"1.png"'></image>
			</view>
			<text class='printerSettings_fd1_1'>暂无打印机</text>
		</view>

		<!---暂无数据flex布局结束-->
		<!---flex布局flex布局开始-->
		<view class="flex benben-flex-layout flex-wrap align-center printerSettings_flex_2" v-if="isData=='2'">
			<view class='flex flex-direction flex-wrap align-stretch flex-sub printerSettings_fd2_0'>
				<view class='flex flex-wrap align-center justify-between'>
					<view class='flex flex-wrap align-center'>
						<view class='flex flex-wrap align-center printerSettings_fd2_0_c0_c0_c0'>
							<text class='printerSettings_fd2_0_c0_c0_c0_c0'>打印机编号</text>
						</view>
						<view class='flex flex-wrap align-center printerSettings_fd2_0_c0_c0_c1'>
							<text class='printerSettings_fd2_0_c0_c0_c1_c0'>{{sninput}}</text>
						</view>
					</view>
					<view class='flex flex-wrap align-center' @tap.stop="popupShow1684113691133=true">
						<button class='self-center printerSettings_fd2_0_c0_c1_c0'>解绑</button>
					</view>
				</view>
				<view class='flex flex-wrap align-center printerSettings_fd2_0_c1'>
				</view>
				<view class='flex flex-wrap align-center justify-between'>
					<view class='flex flex-wrap align-center'>
						<view class='flex flex-wrap align-center printerSettings_fd2_0_c2_c0_c0'>
							<text class='printerSettings_fd2_0_c2_c0_c0_c0'>打印机识别码</text>
						</view>
						<view class='flex flex-wrap align-center printerSettings_fd2_0_c2_c0_c1'>
							<text class='printerSettings_fd2_0_c2_c0_c1_c0'>{{keyinput}}</text>
						</view>
					</view>
				</view>
				<view class='flex flex-wrap align-center justify-between printerSettings_fd2_0_c3'>
					<view class='flex flex-wrap align-center'>
						<view class='flex flex-wrap align-center printerSettings_fd2_0_c3_c0_c0'>
							<text class='printerSettings_fd2_0_c3_c0_c0_c0'>打印机名称</text>
						</view>
						<view class='flex flex-wrap align-center printerSettings_fd2_0_c3_c0_c1'>
							<text class='printerSettings_fd2_0_c3_c0_c1_c0'>{{printername}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>

		<!---flex布局flex布局结束-->
		<view
			class="flex flex-direction flex-wrap align-center justify-center benben-position-layout flex printerSettings_flex_3"
			v-if="isData=='1'">
			<button class='printerSettings_fd3_0' @tap.stop="popupShow1684113737166=true">添加打印机</button>

		</view>
		<view :style="{height: '88rpx'}" v-if="isData=='1'"></view>
		<benben-popup v-model="popupShow1684113691133" :mask="true" mode='center'>
			<!---解绑弹窗flex布局开始-->
			<view class="flex flex-direction flex-wrap align-center printerSettings_flex_4">
				<text class='printerSettings_fd4_0'>提示</text>
				<text class='printerSettings_fd4_1'>是否解除绑定吗？</text>
				<view class='flex flex-wrap align-center printerSettings_fd4_2'>
				</view>
				<view class='flex flex-wrap align-center'>
					<view class='flex flex-wrap align-center printerSettings_fd4_3_c0'
						@tap.stop="popupShow1684113691133=false">
						<text class='printerSettings_fd4_3_c0_c0'>取消</text>
					</view>
					<view class='flex flex-wrap align-center printerSettings_fd4_3_c1' @tap="delTap">
						<text class='printerSettings_fd4_3_c1_c0'>确定</text>
					</view>
				</view>
			</view>

			<!---解绑弹窗flex布局结束-->

		</benben-popup>
		<benben-popup v-model="popupShow1684113737166" :mask="true" mode='center'>
			<!---添加打印机flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout printerSettings_flex_5">
				<view class='flex flex-direction flex-wrap align-stretch flex-sub printerSettings_fd5_0'>
					<view class='flex flex-wrap align-center justify-between'>
						<view class='flex flex-wrap align-center printerSettings_fd5_0_c0_c0'>
						</view>
						<view class='flex flex-wrap align-center printerSettings_fd5_0_c0_c1'>
							<text class='printerSettings_fd5_0_c0_c1_c0'>添加打印机</text>
						</view>
						<view class='flex flex-wrap align-center' @tap.stop="popupShow1684113737166=false">
							<image class='printerSettings_fd5_0_c0_c2_c0' :src='STATIC_URL+"2.png"'
								@tap.stop="popupShow1684113737166=false"></image>
						</view>
					</view>
					<view class='flex flex-direction flex-wrap align-stretch printerSettings_fd5_0_c1'>
						<text class='printerSettings_fd5_0_c1_c0'>打印机编号</text>
						<view class='flex flex-direction flex-wrap align-stretch'>
							<input class='printerSettings_fd5_0_c1_c1_c0' type="text" placeholder="请输入SN码"
								confirm-type="done" :maxlength="-1"
								placeholder-style="color:rgba(142, 142, 147, 1);font-size:28rpx" v-model="sninput" />
						</view>
					</view>
					<view class='flex flex-direction flex-wrap align-stretch printerSettings_fd5_0_c2'>
						<text class='printerSettings_fd5_0_c2_c0'>打印机识别码</text>
						<view class='flex flex-direction flex-wrap align-stretch'>
							<input class='printerSettings_fd5_0_c2_c1_c0' type="text" placeholder="请输入KEY码"
								confirm-type="done" :maxlength="-1"
								placeholder-style="color:rgba(142, 142, 147, 1);font-size:28rpx" v-model="keyinput" />
						</view>
					</view>
					<view class='flex flex-direction flex-wrap align-stretch'>
						<text class='printerSettings_fd5_0_c3_c0'>打印机名称</text>
						<view class='flex flex-direction flex-wrap align-stretch'>
							<input class='printerSettings_fd5_0_c3_c1_c0' type="text" placeholder="请输入打印机名称，如厨房"
								confirm-type="done" :maxlength="-1"
								placeholder-style="color:rgba(142, 142, 147, 1);font-size:28rpx"
								v-model="printername" />
						</view>
					</view>
					<view class='flex flex-wrap align-center justify-center printerSettings_fd5_0_c4'>
						<button class='printerSettings_fd5_0_c4_c0' @tap="sureTap">立即绑定</button>
					</view>
				</view>
			</view>

			<!---添加打印机flex布局结束-->

		</benben-popup>


	</view>
</template>
<script>
	import { validate } from '@/common/utils/index'
	export default {
		components: {},


		data() {
			return {
				"popupShow1684113737166": false,
				"popupShow1684113691133": false,
				"sninput": "",
				"keyinput": "",
				"printername": "",
				"isData": "1",
				aid:"",
				is_check:false
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			
		},
		onShow() {
			this.post6486853cd3104()
		},
		methods: {
			post6486853cd3104(){
				this.$api.post(global.apiUrls.post6486853cd3104).then(res=>{
					if(res.data.code==1){
						if(res.data.data.length>0){
							this.sninput = res.data.data[0].sn
							this.keyinput = res.data.data[0].key
							this.printername = res.data.data[0].name
							this.aid = res.data.data[0].aid
							this.isData = 2
						}else{
							this.isData = 1
						}
						
					}
				})
			},
			sureTap(){
				if(this.is_check) return
				if (!validate(this.sninput, 'require')) {
				  this.$message.info('请输入SN码');
				  return false;
				}
				if (!validate(this.keyinput, 'require')) {
				  this.$message.info('请输入KEY码');
				  return false;
				}
				if (!validate(this.printername, 'require')) {
				  this.$message.info('请输入打印机名称，如厨房');
				  return false;
				}
				this.is_check = true
				this.$api.post(global.apiUrls.post648684c90ec38,{
					name:this.printername,
					key:this.keyinput,
					sn:this.sninput
				}).then(res=>{
					this.$message.info(res.data.msg)
					if(res.data.code==1){
						this.popupShow1684113737166 = false
						this.post6486853cd3104()
						this.is_check = false
					}else{
						this.is_check = false
					}
				})
			},
			delTap(){
				this.$api.post(global.apiUrls.post6486856ed0d81,{
					aid:this.aid,
				}).then(res=>{
					this.$message.info(res.data.msg)
					if(res.data.code==1){
						this.popupShow1684113691133 = false
						this.post6486853cd3104()
					}
				})
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: rgba(248, 248, 248, 1);
		background-size: 100% auto !important;
	}

	.printerSettings_flex_0 {
		border-bottom: 1px solid #eee;
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.printerSettings_fd0_0_c2 {
		width: 32rpx;
		height: 32rpx;
	}

	.printerSettings_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333333;
		line-height: 36rpx;
	}

	.printerSettings_fd0_0_c0_c0 {
		font-size: 34rpx;
		font-weight: 500;
		color: #333;
		line-height: 88rpx;
	}

	.printerSettings_fd0_0 {
		margin: 0rpx 32rpx 0rpx 32rpx;
	}

	.printerSettings_flex_1 {
		padding: 189rpx 0rpx 32rpx 0rpx;
	}

	.printerSettings_fd1_1 {
		color: #999999;
		font-size: 28rpx;
		font-weight: 400;
		line-height: 28rpx;
	}

	.printerSettings_fd1_0_c0 {
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		width: 490rpx;
		height: 372rpx;
	}

	.printerSettings_fd1_0 {
		position: relative;
		margin: 0rpx 0rpx 56rpx 0rpx;
	}

	.printerSettings_flex_2 {
		padding: 0rpx 24rpx 0rpx 24rpx;
	}

	.printerSettings_fd2_0_c3_c0_c1_c0 {
		color: #333333;
		font-size: 28rpx;
		font-weight: 400;
		line-height: 48rpx;
	}

	.printerSettings_fd2_0_c3_c0_c1 {
		margin: 0rpx 0rpx 0rpx 24rpx;
	}

	.printerSettings_fd2_0_c3_c0_c0_c0 {
		color: #8E8E93;
		font-size: 28rpx;
		font-weight: 400;
		line-height: 48rpx;
	}

	.printerSettings_fd2_0_c3_c0_c0 {
		width: 177rpx;
	}

	.printerSettings_fd2_0_c3 {
		margin: 24rpx 0rpx 0rpx 0rpx;
	}

	.printerSettings_fd2_0_c2_c0_c1_c0 {
		color: #333333;
		font-size: 28rpx;
		font-weight: 400;
		line-height: 48rpx;
	}

	.printerSettings_fd2_0_c2_c0_c1 {
		margin: 0rpx 0rpx 0rpx 24rpx;
	}

	.printerSettings_fd2_0_c2_c0_c0_c0 {
		color: #8E8E93;
		font-size: 28rpx;
		font-weight: 400;
		line-height: 48rpx;
	}

	.printerSettings_fd2_0_c2_c0_c0 {
		width: 177rpx;
	}

	.printerSettings_fd2_0_c1 {
		background: rgba(238, 238, 238, 1);
		height: 1rpx;
		background-size: 100% auto !important;
		margin: 26rpx 0rpx 24rpx 0rpx;
	}

	.printerSettings_fd2_0_c0_c1_c0 {
		background: rgba(254, 59, 48, 1);
		border-radius: 25rpx 25rpx 25rpx 25rpx;
		font-size: 24rpx;
		color: #fff;
		width: 88rpx;
		height: 44rpx;
		line-height: 44rpx;
	}

	.printerSettings_fd2_0_c0_c0_c1_c0 {
		color: #333333;
		font-size: 28rpx;
		font-weight: 400;
		line-height: 48rpx;
	}

	.printerSettings_fd2_0_c0_c0_c1 {
		margin: 0rpx 0rpx 0rpx 24rpx;
	}

	.printerSettings_fd2_0_c0_c0_c0_c0 {
		color: #8E8E93;
		font-size: 28rpx;
		font-weight: 400;
		line-height: 48rpx;
	}

	.printerSettings_fd2_0_c0_c0_c0 {
		width: 177rpx;
	}

	.printerSettings_fd2_0 {
		background: rgba(255, 255, 255, 1);
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		background-size: 100% auto !important;
		margin: 25rpx 0rpx 0rpx 0rpx;
		padding: 22rpx 24rpx 24rpx 24rpx;
	}

	.printerSettings_flex_3 {
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		bottom: calc(48rpx + var(--window-bottom));
	}

	.printerSettings_fd3_0 {
		background: rgba(255, 147, 0, 1);
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		font-size: 32rpx;
		color: #fff;
		width: 686rpx;
		height: 88rpx;
		line-height: 88rpx;
		font-weight: 400;
	}

	.printerSettings_flex_4 {
		background: #fff;
		margin: 0rpx 104rpx 0rpx 104rpx;
		background-size: #eee;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		padding: 40rpx 0rpx 0rpx 0rpx;
	}

	.printerSettings_fd4_3_c1_c0 {
		font-size: 34rpx;
		font-weight: 500;
		color: rgba(255, 147, 0, 1);
	}

	.printerSettings_fd4_3_c1 {
		padding: 23rpx 100rpx 23rpx 100rpx;
		border-radius: 0rpx 0rpx 16rpx 0rpx;
	}

	.printerSettings_fd4_3_c0_c0 {
		font-size: 34rpx;
		font-weight: 400;
		color: rgba(153, 153, 153, 1);
	}

	.printerSettings_fd4_3_c0 {
		border-right: 1px solid #eee;
		padding: 23rpx 100rpx 23rpx 95rpx;
		border-radius: 0rpx 0rpx 0rpx 16rpx;
	}

	.printerSettings_fd4_2 {
		background: rgba(238, 238, 238, 1);
		width: 540rpx;
		height: 1rpx;
		background-size: #eee;
	}

	.printerSettings_fd4_1 {
		padding: 40rpx 0rpx 40rpx 0rpx;
		font-size: 32rpx;
		font-weight: 400;
		color: #333333;
		line-height: 52rpx;
	}

	.printerSettings_fd4_0 {
		font-weight: 500;
		font-size: 32rpx;
		color: #333333;
		line-height: 32rpx;
	}

	.printerSettings_flex_5 {
		padding: 0rpx 80rpx 0rpx 80rpx;
	}

	.printerSettings_fd5_0_c4_c0 {
		background: rgba(255, 147, 0, 1);
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		font-size: 32rpx;
		color: rgba(255, 255, 255, 1);
		width: 300rpx;
		height: 88rpx;
		line-height: 88rpx;
		font-weight: 500;
	}

	.printerSettings_fd5_0_c4 {
		margin: 32rpx 0rpx 35rpx 0rpx;
	}

	.printerSettings_fd5_0_c3_c1_c0 {
		background: #F8F8F8;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		height: 88rpx;
		padding: 0rpx 24rpx 0rpx 24rpx;
	}

	.printerSettings_fd5_0_c3_c0 {
		font-size: 28rpx;
		font-weight: 500;
		color: #333333;
		margin: 0rpx 0rpx 16rpx 0rpx;
		line-height: 48rpx;
	}

	.printerSettings_fd5_0_c2_c1_c0 {
		background: rgba(248, 248, 248, 1);
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		height: 88rpx;
		padding: 0rpx 24rpx 0rpx 24rpx;
	}

	.printerSettings_fd5_0_c2_c0 {
		font-size: 28rpx;
		font-weight: 500;
		color: #333333;
		margin: 0rpx 0rpx 16rpx 0rpx;
		line-height: 48rpx;
	}

	.printerSettings_fd5_0_c2 {
		margin: 0rpx 0rpx 32rpx 0rpx;
	}

	.printerSettings_fd5_0_c1_c1_c0 {
		background: rgba(248, 248, 248, 1);
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		height: 88rpx;
		padding: 0rpx 24rpx 0rpx 24rpx;
	}

	.printerSettings_fd5_0_c1_c0 {
		font-size: 28rpx;
		font-weight: 500;
		color: #333333;
		margin: 0rpx 0rpx 16rpx 0rpx;
		line-height: 48rpx;
	}

	.printerSettings_fd5_0_c1 {
		margin: 0rpx 0rpx 32rpx 0rpx;
	}

	.printerSettings_fd5_0_c0_c2_c0 {
		width: 40rpx;
		height: 40rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.printerSettings_fd5_0_c0_c1_c0 {
		font-size: 32rpx;
		font-weight: 700;
		color: rgba(51, 51, 51, 1);
	}

	.printerSettings_fd5_0_c0_c1 {
		line-height: 109rpx;
	}

	.printerSettings_fd5_0_c0_c0 {
		width: 24rpx;
	}

	.printerSettings_fd5_0 {
		background: #fff;
		background-size: 100% auto !important;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		padding: 0rpx 32rpx 0rpx 32rpx;
		width: 590rpx;
	}
</style>
