<template>
	<view class="contentAll">
		<view class="card" v-for="(item,index) in form.data">
			<view>
				<view class="icon-active" v-if="i==value" @click="choice(item)">
					<u-icon name="checkbox-mark" color="#fff" size="28"></u-icon>
				</view>
				<view class="icon-no-active" v-else @click="choice(item)">
				</view>
			</view>
			<view class="content">
				<view class="title">姓名：{{item.cusName}}</view>
				<view class="title">开户行：{{bankData[item.bankType+1]}}</view>
				<view class="title">开户行支行：{{item.branchName}}</view>
				<view class="title">银行卡号：{{item.bankCardId}}</view>
			</view>
			<view class="edit" @click="toEdit(item)">
				<image :src="`${$imgUrl}applyCard/edit.png`" mode=""></image>
				<view>
					编辑
				</view>
			</view>

		</view>


		<view class="add" @click="add">添加退费信息</view>
	</view>
</template>

<script lang="ts" setup>
	import {
		reactive, ref
	} from "vue";
	import {
		onLoad, onShow
	} from "@dcloudio/uni-app";
	import {
		navTo,
	} from "@/utils/utils";
	import { cancelList } from "@/utils/network/api.js";
	import { stringToJson } from "@/utils/network/encryption";
	import { request } from "@/utils/network/request.js";
	import { bankData } from "@/datas/bank.js";
	// 表单数据
	const form = reactive({
		userType: "",
		customerIdnum: "",
		mobile: "",
		data: [],
	});
	onLoad((option) => {
		form.mobile = option.mobile
		form.customerIdnum = option.customerIdnum
		form.userType = option.userType
	})
	const value = ref('-1')
	onShow(() => {
		queryList()
	})
	const toEdit = (item) => {
		const params = encodeURIComponent(JSON.stringify(item))
		navTo(`/subpackage/after-sale/ETC-log-off/refund-information-edit?mobile=${form.mobile}&&customerIdnum=${form.customerIdnum}&&userType=${form.userType}&&params=${params}`);
	}
	const add = () => {
		navTo(`/subpackage/after-sale/ETC-log-off/refund-information-add?mobile=${form.mobile}&&customerIdnum=${form.customerIdnum}&&userType=${form.userType}`);
	}
	const queryList = () => {

		var data = {
			customerIdNum: form.customerIdnum,  //身份证号
		};
		const options = {
			type: 2,
			data: data,
			method: "POST",
			showLoading: true,
		};
		console.log("options", options)
		request(cancelList, options).then((res) => {
			const data = stringToJson(res.bizContent);
			form.data = data.data
			console.log("data", data)

		});
	}
	const choice = (item) => {
		console.log("item", item)
		uni.$emit('list', {
			item: item
		})
		uni.navigateBack({
			delta: 1
		})
	}
</script>

<style scoped lang="scss">
	.contentAll {
		background-color: #EEF7F7;
		width: 100%;
		min-height: 100vh;
		padding: 20rpx 20rpx;
		box-sizing: border-box;
	}

	.add {
		width: 100%;
		height: 80rpx;
		background-color: white;
		text-align: center;
		line-height: 80rpx;
		position: fixed;
		bottom: 0;
		left: 0;
		font-size: 32rpx;
	}

	.list-item {
		width: 95%;
		border-radius: 10rpx;
		margin: 0 auto;
		font-size: 28rpx;
		border: 1rpx solid #ccc;
		padding: 12rpx;
		box-sizing: border-box;
		background-color: white;
		margin-bottom: 28rpx;

	}



	.card {
		background: #FFFFFF;
		box-shadow: 0rpx 2rpx 6rpx 0rpx rgba(223, 223, 223, 0.8);
		border-radius: 20rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 30rpx;
		margin-bottom: 30rpx;

		.content {
			width: 70%;

			.title {
				font-size: 30rpx;
				font-family: Noto Sans S Chinese;
				font-weight: 400;
				color: #333333;
				margin-bottom: 15rpx;
			}

			text {
				font-size: 26rpx;
				font-family: Noto Sans S Chinese;
				font-weight: 400;
				color: #666666;
			}
		}

		.icon-active {
			width: 43rpx;
			height: 43rpx;
			background: #00B38B;
			border-radius: 50%;
			display: flex;
			justify-content: center;
			align-items: center;
		}

		.icon-no-active {
			width: 44rpx;
			height: 44rpx;
			background: #FFFFFF;
			border: 1px solid #00B38B;
			border-radius: 50%;
		}

		.edit {
			display: flex;
			justify-content: center;
			align-items: center;
			flex-direction: column;


			image {
				width: 40rpx;
				height: 40rpx;
			}

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