<template>
	<view>
		<view class="form form-b">
			<view class="li cards">
				<label class="label">银行卡</label>
				<view class="linsence">
					<image :src="bankUrl ? bankUrl : picUrlss + 'card.png'"></image>
					<view>储蓄银行卡正面照</view>
				</view>
			</view>
			<view class="li dflex">
				<label class="label">户名</label>
				<view class="item flex"><input disabled="true" v-model="rName" placeholder="请输入户主名称" placeholder-class="placeholder" class="ipt" /></view>
			</view>
			<view class="li ddflex">
				<label class="label">开户银行</label>
				<view class="item fflex">
					<view v-if="bankName" class="ipt">{{ bankName }}</view>
				</view>
			</view>
			<view class="li ddflex">
				<label class="label">银行卡号</label>
				<view class="item fflex"><input disabled="true" v-model="bankNo" placeholder-class="placeholder" class="ipt" /></view>
			</view>

			<view class="li flexs dflex">
				<label class="label">预留手机</label>
				<view class="item flex"><input disabled="true" type="number" v-model="bankAcctPhone" maxlength="11" placeholder-class="placeholder" class="ipt" /></view>
			</view>
		</view>
		
		<!-- <view class="next" @click="submit()">更换银行卡</view> -->
	</view>
</template>

<script>
const app = getApp();
// const util = require('../../../utils/util.js');
const req = require('../../../utils/request.js');
const hfParams = require('../../../utils/hfParams.js');
var QQMapWX = require('../../../utils/qqmap.js');
export default {
	data() {
		return {
			fileInfo: {
				legalPersonidPositivePic: '', //正面
				egalPersonidOppositePic: '' //反面
			},
			//身份信息
			rName: '',
			rCode: '',
			rValidDate: '',

			location: '',
			addIds: '',
			address: '', //区域
			addressDetails: '',
			bankList: [],

			bankUrl: '', //银行卡图片
			bankPosition: -1, //下标
			bankName: '', //银行名字
			bankAcctName: '', //户名
			bankNo: '', //卡号
			bankAcctPhone: '',

			settlementInfo: ''
		};
	},
	onLoad(opt) {
		this.bankList = hfParams.bank();
		this.getSettlementInfo();
	},
	methods: {
		getSettlementInfo() {
			req.getRequest('/api/v3/settlement/info', '', data => {
				this.settlementInfo = data;
				if (this.settlementInfo) {
					this.addIds = this.settlementInfo.provCode + ',' + this.settlementInfo.areaCode;
					this.address = this.settlementInfo.address;
					this.rName = this.settlementInfo.cardName;
					this.bankName = this.getBankName(this.settlementInfo.bankCode);
					this.bankAcctName = this.settlementInfo.cardName;
					this.bankUrl = this.settlementInfo.bankUrl;
					this.bankNo = this.settlementInfo.cardNo.replace(' ', '');
					this.fileInfo = JSON.parse(this.settlementInfo.fileJson);
					this.rCode = this.settlementInfo.legalCertId;
					this.rValidDate = this.settlementInfo.legalCertIdExpires;
					this.bankAcctPhone = this.settlementInfo.legalMp;
				}
			});
		},
		
		getBankName(code) {
			for (var i = 0; i < this.bankList.length; i++) {
				var bankObj = this.bankList[i];
				if (bankObj.code == code) {
					this.bankPosition = i;
					return bankObj.name;
				}
			}
		},

		initCheckBank(name) {
			for (var i = 0; i < this.bankList.length; i++) {
				var bankObj = this.bankList[i];
				if (bankObj.name == name) {
					this.bankPosition = i;
					this.bankName = name;
				}
			}
		},

		submit() {
			uni.navigateTo({
				url: '/promote/withdrawal/bindCard/bindCard?isEnd=true'
			});
		}
	}
};
</script>

<style>
@import './bindCardCheck.css';
</style>
