<template>
	<!-- 	<view class="container">
		<view class="check-content">
			<view class="posi">
				<u-checkbox-group>
					<u-checkbox v-model="checked" shape="circle">
					</u-checkbox>
				</u-checkbox-group>

				<view class="content">
					我已阅读并同意 <text class="item-line" @click="handleDialog('etc')">《ETC用户协议》</text>和<text class="item-line"
						@click="handleDialog('risk')">《风险提示告知书》</text>
				</view>
			</view>

		</view>
		<view class='btn-buttom'>
			<button class="btn btn-text as-gravity-center nav-bg as-weight" @click='handleNext'>下一步
			</button>
		</view>
		<u-modal v-model="isShow" width='700rpx' mask-close-able :show-title='false' :show-confirm-button='false'>
			<view class="slot-content">
				<ETCUserAgreement v-if='type=="etc"'/>
				<Risk v-else/>
			</view>
		</u-modal>
	</view> -->
</template>
<script setup lang='ts'>
	import {
		ref
	} from 'vue'
	import {
		unifyTemplate
	} from '@/hooks/unifyTemplate'
	import {
		onLoad
	} from '@dcloudio/uni-app';
	import {
		request
	} from '@/utils/network/request'
	import ETCUserAgreement from '@/components/ETCUserAgreement.vue'
	import Risk from '@/components/Risk.vue'
	const {
		initData, //初始化数据
		qdOrderVal //qdOrder中数据 ref
	} = unifyTemplate() //初始化数据
	//获取页面配置
	onLoad((opin) => {
		initData(opin, 3).then(data => {
			// contractTesting(data.qdOrder.qdOrderNo, data.config.jumpPage)
			// contractQuery(data.qdOrder.qdOrderNo, data.config.jumpPage,data)
			uni.navigateTo({
				url: '/' + data.config.jumpPage,
				animationType: 'pop-in',
				animationDuration: 500
			})
		})
	})
	const checked = ref(false)
	// 合同查询
	function contractQuery(qdOrderNo, jumpPage,orderData) {
		const data = {
			orderId: qdOrderVal.value.qtOrderNo //订单id
		}
		request('7e039f28efcb4ff6ae7e3a2111339b87', {
			data,
		}).then((res) => {
			if (res.statusCode === 0) {
				const data = JSON.parse(res.bizContent)
				if (data.signmentState !== 1 || data.contractState !== 1) {
					// 合同处理
					handleContract(orderData)
				} else {
					uni.navigateTo({
						url: '/' + jumpPage,
						animationType: 'pop-in',
						animationDuration: 500
					})
					// 都为1说明可以进行签约检测
					// contractTesting(qdOrderNo, jumpPage)
				}
			}
		})
	}
	const isShow = ref(false)
	const type = ref('')

	function handleDialog(types) {
		isShow.value = true
		if (types == 'etc') {
			type.value = 'etc'
		} else {
			type.value = 'risk'
		}
	}

	function handleNext() {
		console.log(checked.value);

	}
	// 合同处理
	function handleContract(orderData) {
		console.log(qdOrderVal.value);
		let ifCode: any
		if (orderData.order.userType === 'PERSONAL_USER') {
			// 个人合同
			ifCode = 'ec36c36b501341b19407990265a36313'
		} else {
			ifCode = 'b808a5b65cec4fe4b4a873874f9541e8'
		}
		const data = {
			orderId: qdOrderVal.value.qtOrderNo //订单id
		}
		request(ifCode, {
			data,
		}).then((res) => {
			if (res.statusCode === 0) {
				const data = JSON.parse(res.bizContent)
				window.open(data.shortUrl, '_self')
			}
		})
	}
</script>
<!-- 签约管理 -->
<style lang='scss' scoped>
	.sig-manage {
		height: 100vh;
		width: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.container {
		height: 100%;
		width: 100%;
		display: flex;
		flex-direction: column;
	}

	:deep(.u-checkbox__label) {
		margin: 0;
		margin-right: 5rpx;
	}

	.check-content {
		flex: 1 1 auto;
		position: relative;

		.posi {
			position: absolute;
			padding: 20rpx;
			bottom: 30rpx;
			left: 0;
			width: 100%;
		}
	}

	.content {
		display: inline;
		word-wrap: break-word;

	}

	.item-line {
		color: $u-type-primary;
		cursor: pointer;
	}

	.btn {
		height: 80rpx;
		opacity: 1;
		border-radius: 100rpx;
		margin: 20rpx;
	}

	.btn-text {
		color: #FFFFFF;
		font-size: 28rpx;
	}

	.nav-bg {
		/* background: linear-gradient(to right, #13E7C1, #43A1E0); */
		border: 1px solid #FFFFFF;
		background: #1AAC1B;
	}

	.btn-buttom {
		flex: 0 0 auto;
	}

	.slot-content {
		height: 82vh;
		overflow-y: auto;
	}
</style>