<template>
	<view class="oderPage">
		<u-form :model="form"  :error-type="errorType">
			<view class="from">

				<u-form-item prop="applyType">
					<view class="from_item">
						<text style="color: #004576;"><text class="red">*</text>申请类型：</text>
						<view style="display: flex;">
							<picker @change="bindPickerChange" :value="index" :range="columnsOld">
								<view class="uni-input">{{index>=0?columnsOld[index]:"请选择"}}</view>
							</picker>
							<u-icon name="arrow-right" style="margin-left: 10px;display: flex;"
								@click="showPicker"></u-icon>
						</view>
					</view>
				</u-form-item>
			</view>
		</u-form>
		<view class="content">
			<view class="title"><text class="red">*</text>设备更换需将原设备寄回</view>
			<view class="title1"><image :src="`${$imgUrl}common/apply-goods.png`"></image><text>寄回信息</text></view>
			<view class="content-box">
				<view class="phone">
					<text>收件人：</text>
					<text>ETC售后</text>
				</view>
				<view class="phone">
					<text>联系电话：</text>
					<text>18798751224</text>
				</view>
				<view>此电话仅用于ETC售后收取快递，如需咨询业务请致电4008008787</view>
			</view>
			<view class="title1"><image :src="`${$imgUrl}common/tips.png`"></image><text>寄回地址</text></view>
			<view class="content-box">补换订单审核时效：设备签收后的2个自然日完成审核，审核通过后请关注订单物流单号；</view>
		</view>
		<button class="submit" @click="submit">下一步</button>
	</view>

</template>

<script setup lang="ts">
	import {
		navTo
	} from "@/utils/utils.ts"
	import {
		ref,
		reactive
	} from "vue";
	import {
		onReady
	} from "@dcloudio/uni-app";
	import {
		onLoad
	} from "@dcloudio/uni-app";
	// 表单数据
	const form = reactive({
		orderId: '',
		applyType: '',

	})
	//接受通过该id查询订单详情
	const oldId = ref('')

	const applyType = ref('')
	//选择器数据 
	const index = ref('-1');
	const columnsOld = ["换货-换卡签"]
	const columns = [
		{
			label: '换货-换卡签',
			// 其他属性值
			id: 'ALL'
		},
	]
	const bindPickerChange = (e) => {
		console.log('picker发送选择改变，携带值为', e.detail.value)
		index.value = e.detail.value
		form.applyType = columns[e.detail.value].id
		applyType.value = columns[e.detail.value].label
	}
	// 验证规则
	const rules = {

	}
	// 验证提示类型(toast要版本为1.3.5才支持)
	const errorType = ['message', 'border-bottom', 'toast']

	// 设置验证规则
	const myForm = ref(null)
	onReady(() => {
		// myForm.value.setRules(rules)
	})

	let show = ref(false)

	// 打开地区先择器
	const showPicker = function () {
		show.value = true
	}


	// 提交
	const submit = () => {
		if (form.applyType) {
			console.log('验证通过', form);
			navTo(`/subpackage/orders/apply-ex-goods?orderId=${form.orderId}&applyType=${form.applyType}`) //测试用
		} else {
			uni.showToast({
				title: "请选择申请类型",
				icon: "none"
			})
		}
	}

	onLoad((option) => {
		form.orderId = option.orderId
		oldId.value = option.id
		console.log(form,option.id);
	});
</script>


<style>
	page {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
	}
</style>
<style lang="scss" scoped>
	.oderPage {
		flex: 1;
		width: 100%;

		.from {
			background-color: #fff;

			::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;
				align-items: center;
				height: 80rpx;

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

					input {
						text-align: right;
					}
				}
			}
		}
	}

	.submit {
		background:linear-gradient(to right,#01243A,#004576);
		width: 670rpx;
		height: 80rpx;
		color: #fff;
		border-radius: 100rpx;
		margin: 26px auto;
		font-size: 32rpx;
	}

	.red {
		color: red;
		margin-right: 10rpx;
	}
    .content{
		font-weight: 400;
		font-size: 28rpx;
		color: #6C6C6C;
		background-color: white;
		width: 100%;
		margin-top: 20rpx;
		padding: 30rpx;
		box-sizing: border-box;
		image{
			width: 8rpx;
			height: 26rpx;
			margin-right: 10rpx;
		}
		.title{
			font-weight: 400;
			font-size: 30rpx;
			color: #111111;
		}
		.title1{
			font-weight: 400;
			font-size: 28rpx;
			color: #111111;
			margin: 20rpx 0 30rpx 0;
		}
		.content-box{
			background: #F1F1F1;
			padding: 20rpx;
			.phone{
				margin-bottom: 6rpx;
				text:first-child{
					margin-right: 6rpx;
				}
			}
		}
	}
</style>