<template>
	<view class="page" :style="{'height':h+'px','padding-top':mt+'px'}">
		<c-nav-bar title="核销" backUrl="/pagesHouse/home/index" @goBack="goBack" :showHome="false"></c-nav-bar>
		<view class="card" @tap="scanCode">
			<view>
				<text>扫码核销</text>

			</view>
		</view>
		<view class="card" @tap="showVerifyPopup">
			<view>
				<text>核销码核销</text>
			</view>
		</view>
		<Tabbares :tabbarid="1" :value="1"></Tabbares>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				//userInfo: null,
				merchantId: '',
				types: [],
				list: [],
				showVerifyModal: false,
				verifyCode: '',
				h: 0,
				mt: 0
			}
		},
		created() {

		},
		onLoad(option) {
		this.initHeight();
		// 测试弹窗是否能正常显示
		// setTimeout(() => {
		// 	this.showVerifyModal = true
		// }, 1000)
	},
		methods: {
			goBack() {
				uni.navigateBack()
			},
			scanCode(){
				uni.scanCode({
					onlyFromCamera: true,
					success: (res) => {
						//
						console.log(res)
						uni.navigateTo({
							url: "/pagesHouse/Verification/detailsewm?list=" + res.result
						})
											
					},
					error: (res) => {
						uni.reLaunch({
							url:'/pagesHouse/home/index'
						})
					}
				})
			},
			showVerifyPopup() {
				uni.showModal({
					title: '核销码核销',
					content: '',
					editable: true,
					placeholderText: '请输入核销码',
					success: (res) => {
						if (res.confirm) {
							const inputValue = res.content.trim()
							if (inputValue) {
								this.verifyCode = inputValue
								this.submitVerify()
							} else {
								uni.showToast({
									title: '请输入核销码',
									icon: 'none'
								})
							}
						}
					}
				})
			},
			closeModal() {
				this.showVerifyModal = false
				this.verifyCode = ''
			},
			submitVerify() {
				if (!this.verifyCode.trim()) {
					uni.showToast({
						title: '请输入核销码',
						icon: 'none'
					})
					return
				}
				uni.navigateTo({
					url: "/pagesHouse/Verification/detailsewm?list=" + this.verifyCode
				})
			},
			initHeight() {
				uni.getSystemInfo({
					success: (res) => {
						this.h = res.windowHeight
						this.mt = res.statusBarHeight + 44
					}
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.page {
		background: #F3F4F4;
		padding-bottom: 20rpx;
		box-sizing: border-box;
		overflow-y: auto;

		.card {
			width: calc(100% - 60rpx);
			height: 180rpx;
			background: #FFFFFF;
			border-radius: 10rpx 10rpx 10rpx 10rpx;
			margin: 20rpx 30rpx 0;
			padding: 0 30rpx 0 60rpx;
			box-sizing: border-box;
			background: url(https://fsy.shengsi.gov.cn/file/20240109/1ee084be17f74dde94617dcb7f7c8af3.png) no-repeat;
			background-size: 100% 100%;
			display: flex;
			align-items: center;
			justify-content: space-between;

			&>view {
				&:first-child {
					display: flex;
					flex-direction: column;

					text {
						font-size: 38rpx;
						font-family: PingFang SC, PingFang SC;
						font-weight: 800;
						color: #1E3A62;

					}
				}


			}
		}
	}
</style>