<template>
	<view class="box">
		<view class="from">
			<u-form :model="form" ref="uForm">
				<u-form-item>
					<view class="from_item">
						<text><text style="color: red;">*</text>请选择发票抬头：</text>
						<view style="display: flex;" @click="toheaderPage">
							<text>{{state.params.buyerName?state.params.buyerName:"请选择"}}</text>
							<u-icon name="arrow-right" style="margin-left: 10px;"></u-icon>
						</view>
					</view>
				</u-form-item>
				<u-form-item>
					<view class="from_item">
						<text><text style="color: red;">*</text>车辆所有人证件号后6位：</text>
						<view style="display: flex;">
							<u-input v-model="state.type" class="input" />
						</view>
					</view>
				</u-form-item>
			</u-form>
		</view>

		<button class="submit" @click="submit">提交</button>
	</view>

</template>

<script setup lang="ts">
	import {
		reactive
	} from "vue";
	import { onLoad, onShow } from "@dcloudio/uni-app";
	import { navTo } from "@/utils/utils"
	import { ETCProductInvoiceApi } from "@/utils/network/api.js";
	import { stringToJson } from "@/utils/network/encryption";
	import { request } from "@/utils/network/request.js";
	const state = reactive({
		type: '',
		params: "",
	})
	onShow(() => {
		uni.$once('list', (query) => {
			console.log("111", query)
			state.params = query.item
		})
	})
	onLoad((option) => {
		state.type = option.type
	})
	const toheaderPage = () => {
		console.log(1);
		navTo('/subpackage/orders/invoiceApply/invoice-header-list?manage=2')
	}
	const submit = () => {
		if (state.type == 1) {
			ETCProductInvoiceRequest()
		}
	}
	const ETCProductInvoiceRequest = () => {
		const options = {
			type: 2,
			data: {
				orders: state.etcCardNo, //订单号列表
				titleId: state.params['id'], //发票抬头编号
				subIdentNo: 1,  //证件号后6位
				userMobile: state.userMobile, //手机号
				sellerId: 10, //售方信息编号
			},
			method: "POST",
			showLoading: true,
		};
		request(ETCProductInvoiceApi, options).then((res) => {
			const data = stringToJson(res.bizContent);
			console.log(data, "通行");
		});
	}
</script>


<style>
	page {
		width: 100%;
		height: 100%;
	}
</style>

<style lang="scss" scoped>
	.box {
		width: 100%;
		height: 100%;
		background-color: #FFF;
		border-top: 1rpx solid #DFDFDF;
		padding: 0 30rpx;
		box-sizing: border-box;

		.from {
			background-color: #fff;
			// margin-top: 20rpx;

			::v-deep .u-form-item {
				padding: 0;
				line-height: normal;

				.u-form-item__message {
					margin-bottom: 12rpx
				}
			}

			.from_item {
				display: flex;
				flex-wrap: nowrap;
				justify-content: space-between;
				// padding: 0 30rpx;
				// border-bottom: #DCDCDC 1px solid;
				align-items: center;
				height: 80rpx;

				text {
					font-size: 30rpx;
					font-family: Noto Sans S Chinese;
					font-weight: 400;
				}

				::v-deep .input {
					text-align: right;
					flex: 1;
					background: transparent;

					input {
						text-align: right;
					}
				}
			}

			.from_item1 {
				display: flex;
				flex-wrap: nowrap;
				flex-direction: column;
				justify-content: space-between;
				padding: 30rpx;
				border-bottom: #DCDCDC 1px solid;

				input {
					text-align: right;
				}

				.textarea {
					background-color: #F1F1F1;
					width: 100%;
					border-radius: 20rpx;
					margin-top: 10rpx;
					text-indent: 1rem;
					height: 180rpx;
					padding: 20rpx;
					box-sizing: border-box;
				}
			}
		}

		.submit {
			width: 670rpx;
			height: 80rpx;
			background: linear-gradient(-90deg, #43A1E0 0%, #13E7C1 100%);
			border-radius: 40rpx;
			font-size: 32rpx;
			font-family: Noto Sans S Chinese;
			font-weight: 400;
			color: #FFFFFF;
			line-height: 80rpx;
			position: fixed;
			left: 50%;
			transform: translate(-50%);
			bottom: 100rpx;
		}
	}
</style>