<template>
	<view class="content">
		<view class="list-item" v-for="(item,index) in form.data" @click="choice(item)">
			<view><text>姓名：</text><text>{{item.cusName}}</text></view>
			<view><text>开户行：</text><text>{{form.array[item.bankType+1]}}</text></view>
			<view><text>开户行支行：</text><text>{{item.branchName}}</text></view>
			<view><text>银行卡号：</text><text>{{item.bankCardId}}</text></view>
		</view>
		<view class="add" @click="add">添加退费信息</view>
	</view>
</template>

<script lang="ts" setup>
	import {
		reactive
	} 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";
	// 表单数据
	const form = reactive({
		userType: "",
		customerIdnum: "",
		mobile: "",
		data: [],
		array: ['贵阳银行股份有限公司', '中国工商银行股份有限公司', '中国建设银行股份有限公司', '中国银行股份有限公司', '中国农业银行股份有限公司', '中国交通银行股份有限公司',
			'兴业银行股份有限公司', '平安银行股份有限公司', '中国邮政储蓄银行股份有限公司', '中国光大银行股份有限公司', '贵州银行股份有限公司', '中国民生银行股份有限公司',
			'招商银行股份有限公司', '.农村信用社联合社', '农村商业银行'],
	});
	onLoad((option) => {
		form.mobile = option.mobile
		form.customerIdnum = option.customerIdnum
		form.userType = option.userType
	})
	onShow(() => {
		queryList()
	})

	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,  //身份证号
			// customerIdNum: "522121199906217049",  //身份证号
		};
		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) => {
		uni.$emit('list', {
			item: item
		})
		uni.navigateBack({
			delta: 1
		})
		// uni.redirectTo({
		// 	url: `/subpackage/after-sale/ETC-log-off/upload-card?item=${item}`
		// })
	}
</script>

<style scoped>
	.content {
		background-color: #EEF7F7;
		width: 100%;
		min-height: 100vh;
		padding: 20rpx 0;
	}

	.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;

	}
</style>