<template>
	<!-- <nav-bar title="储值卡圈存-退款-选择车辆"></nav-bar> -->
    <view class="selectCar-box">
    	<view v-if="state.list&&state.list.length>0" @click="choose(i,item)" class="item" v-for="(item,i) in state.list" :key="i">
    		<view class="iten-left">
    			<image :src="`${$imgUrl}che.png`" mode="aspectFill"></image>
    			<text>{{item.vehiclePlate}}</text>
    		</view>
    		<view class="choose-item">
    			<view class="active" v-if="flag==i">
    			</view>
    		</view>
    	</view>
    	<view v-else>
    		<empty title='暂无找到相关车辆信息' />
    	</view>
    </view>
</template>

<script setup lang="ts">
	import empty from "@/components/empty/empty.vue";
	import {
		reactive,
		ref
	} from "vue"
	import {
		navTo,msg
	} from "@/utils/utils"
	import {
		onLoad,
	} from "@dcloudio/uni-app";
	import {
		 orderList
	} from "@/utils/network/api.js";
	import {
		request
	} from "@/utils/network/request.js";
	import {
		getItem,
		StorageKeys,
	} from "@/utils/storage";
	import {
		stringToJson
	} from "@/utils/network/encryption";
	const state = reactive({
		list: [] ,//车辆list
	});
	const flag = ref('0') //默认选择0

	onLoad(() => {
		quanCheckActionTrue().then((item: any) => {
			state.list = item.data
		})
	});
    
	const quanCheckActionTrue = () => {
		let source = ""
		// #ifdef MP-ALIPAY
			source ="ALI"
		// #endif
		// #ifdef MP-WEIXIN
			source ="WECHAT"
		// #endif
		var data = {
			opId: getItem(StorageKeys.OpenId),
			source: source, //渠道为小程序
			tabIndex: '0', //0全部
			orderStep: '11', //11 为已完成”
		};
		const options = {
			type: 2,
			data: data,
			method: "POST",
			showLoading: true,
		};

		return new Promise(async (resolve, reject) => {
			const res = await request(orderList, options);
			const data = stringToJson(res.bizContent);
			console.log("data",data)
			resolve(data);
		}).catch((error) => {
			reject(error);
		});
	}

	const choose = (i, item) => {
		flag.value = i
		console.log("item",item)
		navTo(`/subpackage/orders/refund-deposit-card?cardId=${item.cardId}`)
	}
</script>


<style>
	page {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		background-color: #F3F3F3;
	}
</style>
<style lang="scss" scoped>
	.flex {
		display: flex;
		justify-content: center;
	}

	.selectCar-box {
		// width: 100%;
		height: 100%;
		padding: 30rpx;
        background-color: #EEF7F7;
		.item {
			padding: 20rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			height: 130rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 2rpx 6rpx 0rpx rgba(223, 223, 223, 0.8);
			border-radius: 20rpx;
			margin-bottom: 30rpx;

			.iten-left {
				display: flex;
				align-items: center;

				image {
					width: 150rpx;
					height: 90rpx;

				}

				text {
					margin-left: 20rpx;
					font-size: 32rpx;
					font-family: Noto Sans S Chinese;
					font-weight: 400;
					color: #333333;
				}
			}

			.choose-item {
				width: 44rpx;
				height: 44rpx;
				background: #FFFFFF;
				border: 2rpx solid #00B38B;
				border-radius: 50%;
				margin-right: 20rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				box-sizing: content-box;
			}

			.active {
				width: 34rpx;
				height: 34rpx;
				background: #00B38B;
				border-radius: 50%;
			}
		}
	}
	.submit {
		height: 80rpx;
		background: linear-gradient(-90deg, #43A1E0 0%, #13E7C1 100%);
		box-shadow: 0rpx 4rpx 11rpx 1rpx rgba(223, 223, 223, 0.5);
		border-radius: 40rpx;
		font-size: 32rpx;
		font-family: Microsoft YaHei;
		font-weight: 400;
		color: #FFFFFF;
		line-height: 80rpx;
		position: fixed;
		bottom: 70rpx;
		width: 670rpx;
		left: 50%;
		transform: translate(-50%);
		text-align: center;
	}
</style>
