<template>
	<view class="selectCar-box">
		<view v-if="state.list.length > 0" class="item" v-for="(item, i) in state.list" :key="i">
			<view class="details-item">
				<view> 卡号： </view>
				<text>{{ item.cardId }}</text>
			</view>
			<view class="details-item">
				<view> 签号： </view>
				<text>{{ item.obuId }}</text>
			</view>
			<view class="details-item">
				<view> 激活时间： </view>
				<text>{{ item.insertTime }}</text>
			</view>

		</view>
		<view v-else class="flex"> 暂无OBU重新激活记录 </view>
	</view>
</template>

<script lang="ts" setup>
	import { reactive, ref } from "vue";
	import { navTo } from "@/utils/utils";
	import { onLoad, onShow } from "@dcloudio/uni-app";
	import { reactivateQuery } from "@/utils/network/api.js";
	import { requestNew } from "@/utils/network/request.js";
	import { msg } from "@/utils/utils";
	import { getItem, StorageKeys, setItem } from "@/utils/storage";
	import { stringToJson } from "@/utils/network/encryption";

	const state = reactive({
		list: [],
		cardId: "",
		obuId: ""
	});
	onLoad((options) => {
		console.log("iooooo", options)
		state.cardId = options.cardId
		state.obuId = options.obuId
		activationRecordQuery().then((item : any) => {
			state.list = item.data
			console.log(item);
		});
	});
	// 查询重新激活记录
	const activationRecordQuery = () => {
		const options = {
			type: 2,
			data: {
				cardId: state.cardId,
				obuId: state.obuId,
			},
			method: "POST",
			showLoading: true,
		};

		return new Promise(async (resolve, reject) => {
			const res = await requestNew(reactivateQuery, options);
			const data = res;
			resolve(data);
		}).catch((error) => {
			reject(error);
		});
	}
</script>

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

	.selectCar-box {
		height: 100%;
		padding: 30rpx;

		.item {
			padding: 20rpx;
			background: #ffffff;
			box-shadow: 0rpx 2rpx 6rpx 0rpx rgba(223, 223, 223, 0.8);
			border-radius: 20rpx;
			margin-bottom: 30rpx;
		}
	}

	.details-item {
		display: flex;
		font-size: 26rpx;
		font-family: Noto Sans S Chinese;
		font-weight: 400;
		color: #999999;
		margin-bottom: 30rpx;

		text {
			font-size: 26rpx;
			font-family: Noto Sans S Chinese;
			font-weight: 400;
			color: #333333;
		}
	}
</style>