<template>
	<view class="addBankCard p30">
		<view style="height: 30rpx"></view>
		<view>
			<view class="addBankCard_input_tit">请输入{{ enterprise.role == 1 ? '姓名' : '企业名称' }}：</view>
			<view class="addBankCard_input">
				<up-input :border="false" placeholder="请输入" v-model="enterprise.realname"></up-input>
			</view>

			<!-- 			<view v-if="enterprise.type == 2">
				<view class="addBankCard_input_tit">请输入纳税人识别号：</view>
				<view class="addBankCard_input">
					<up-input :border="false" placeholder="请输入" v-model="enterprise.taxNo"></up-input>
				</view>
			</view> -->
			<view v-if="enterprise.role == 1">
				<view class="addBankCard_input_tit">请输入手机号：</view>
				<view class="addBankCard_input">
					<up-input :border="false" placeholder="请输入" v-model="enterprise.mobile"></up-input>
				</view>
			</view>
			<view v-if="enterprise.role == 1">
				<view class="addBankCard_input_tit">请输入身份证号：</view>
				<view class="addBankCard_input">
					<up-input :border="false" placeholder="请输入" v-model="enterprise.idcard"></up-input>
				</view>
			</view>
			<!-- 
			<view class="addBankCard_input_tit">请输入开户行名称：</view>
			<view class="addBankCard_input">
				<up-input :border="false" placeholder="请输入" v-model="enterprise.bankName"></up-input>
			</view> -->
			<view class="addBankCard_input_tit" v-if="enterprise.role == 2">请输入开户行：</view>
			<view class="addBankCard_input" v-if="enterprise.role == 2">
				<up-input :border="false" placeholder="请输入" v-model="enterprise.subname"></up-input>
			</view>
			<view class="addBankCard_input_tit">请输入银行卡卡号：</view>
			<view class="addBankCard_input">
				<up-input :border="false" placeholder="请输入" v-model="enterprise.num"></up-input>
			</view>
		</view>
		<view style="margin: 30rpx 0">
			<view style="font-size: 28rpx; color: coral">请仔细核对信息，填写错误会导致提现失败。</view>
		</view>

		<view style="display: flex; justify-content: center">
			<view class="addBankCard_btn" @click="addBank">确定</view>
		</view>
	</view>
</template>

<script setup>
import { reactive, ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import { addUsersAccountInfo, smsCode } from '@/api/api.js';
let tips = ref('');
let uCode = ref(null);
let codeChange2 = (text) => {
	tips.value = text;
};

let enterprise = reactive({
	role: 1
});

onLoad((options) => {
	enterprise.role = options.role;
});

let getCode2 = () => {
	if (!enterprise.phone) return uni.showToast({ title: '请输入手机号', icon: 'none' });
	if (uCode.value.canGetCode) {
		// 模拟向后端请求验证码
		uni.showLoading({
			title: '正在获取验证码'
		});
		smsCode({
			phone: enterprise.phone
		}).then((res) => {
			uni.hideLoading();
			uni.$u.toast('验证码已发送');
			uCode.value.start();
		});
	} else {
		uni.$u.toast('倒计时结束后再发送');
	}
};

let addBank = async () => {
	// if (enterprise.type == 2) {
	// 	enterprise.taxNo = '';
	// 	enterprise.bankName = '';
	// } else {
	// 	enterprise.bankName = '';
	// }

	let _res = await addUsersAccountInfo(enterprise);
	uni.showToast({ title: '添加成功', icon: 'none' });
	setTimeout(() => {
		uni.navigateBack();
	}, 1500);
};
</script>

<style scoped lang="scss">
.addBankCard {
	// @include flex();
	&_input {
		width: 690rpx;
		height: 70rpx;
		background: #ffffff;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		@include flex;
		margin-bottom: 30rpx;
		padding: 0 30rpx;

		&_tit {
			width: 100%;
			font-weight: bold;
			font-size: 26rpx;
			color: #232323;
			margin-bottom: 20rpx;
		}
	}

	&_btn {
		width: 488rpx;
		height: 86rpx;
		background: #4874e5;
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		@include flex($space: center);
		font-weight: bold;
		font-size: 28rpx;
		color: #ffffff;
	}
}
</style>
