<template>
	<view>
		<!-- 商户信息 -->
		<view class="width100 height100p" style="background-color: #eb6a53;" v-if="auditDetail.status == 5">
			<view class="font18 fcorfff paddtop35 fotct">
				渠道审核中
			</view>
		</view>
		<view class="titlename width100 font18 fontwig6 fcor333">结算信息</view>
		<view class="width100 backcorfff">
			<view class="notes">
				<view class="fcor666 width25">公司名称</view>
				<view class="font14 fcor333 text2 width75 fotrt">{{auditDetail.merName}}</view>
			</view>
			<view class="notes">
				<view class="fcor666 width25">结算类型</view>
				<view class="font14 fcor333 text2 width75 fotrt" v-if="auditDetail.settleType == 1">对公结算</view>
				<view class="font14 fcor333 text2 width75 fotrt" v-if="auditDetail.settleType == 2">对私法人结算</view>
				<view class="font14 fcor333 text2 width75 fotrt" v-if="auditDetail.settleType == 3">对私非法人结算</view>
			</view>
			<view class="notes">
				<view class="fcor666 width25" v-if="auditDetail.settleType == 1">开户持有人</view>
				<view class="fcor666 width25" v-if="auditDetail.settleType != 1">银行卡持有人</view>
				<view class="font14 fcor333 text2 width75 fotrt">{{auditDetail.bankCardHolder}}</view>
			</view>
			<view class="notes" v-if="auditDetail.settleType == 1">
				<view class="fcor666 width25" v-if="auditDetail.settleType == 1">开户账号</view>
				<view class="fcor666 width25" v-if="auditDetail.settleType != 1">银行卡号</view>
				<view class="font14 fcor333 text2 width75 fotrt">{{auditDetail.bankCardNo}}</view>
			</view>
			<view class="notes">
				<view class="fcor666 width25">开户行地址</view>
				<view class="font14 fcor333 text2 width75 fotrt">
					{{auditDetail.openningBankProvinceName}}-{{auditDetail.openningBankAreaName}}-{{auditDetail.openningBankCityName}}
				</view>
			</view>
			<view class="notes">
				<view class="fcor666 width25">所属支行</view>
				<view class="font14 fcor333 text2 width75 fotrt">{{auditDetail.openningBankName}}</view>
			</view>
			<view class="notes">
				<view class="fcor666 width25">所属银行</view>
				<view class="font14 fcor333 text2 width75 fotrt">{{auditDetail.bankName}}</view>
			</view>
			<view v-if="auditDetail.settleType == 3">
				<view class="notes">
					<view class="fcor666 width25">非法人姓名</view>
					<view class="font14 fcor333 text2 width75 fotrt">{{auditDetail.settleIdCardName}}</view>
				</view>
				<view class="notes">
					<view class="fcor666 width25">身份证号码</view>
					<view class="font14 fcor333 text2 width75 fotrt">{{auditDetail.settleIdCardNo}}</view>
				</view>
				<!-- <view class="notes">
					<view class="fcor666 width25">身份证号码</view>
					<view class="font14 fcor333 text2 width75 fotrt">{{auditDetail.settleIdCardNo}}</view>
				</view> -->
				<view class="notes">
					<view class="fcor666 width25">身份证地址</view>
					<view class="font14 fcor333 text2 width75 fotrt">{{auditDetail.settleIdCardAddress}}</view>
				</view>
				<view class="notes">
					<view class="fcor666 width25">身份证有效期</view>
					<view class="font14 fcor333 text2 width75 fotrt">
						{{auditDetail.settleIdCardPeriodStart}}至{{auditDetail.settleIdCardPeriodEnd}}
					</view>
				</view>
			</view>
		</view>
		<view class="titlename width100 font18 fontwig6 fcor333" v-if="auditDetail.settleType == 3">非法人授权书</view>
		<image class="width90 " mode="widthFix" :src="uncorporsettelimg" v-if="auditDetail.settleType == 3"></image>
		<view class="titlename width100 font18 fontwig6 fcor333" v-if="auditDetail.settleType == 3">非法人身份证图片</view>
		<image class="width90 " mode="widthFix" :src="idcardposimg" v-if="auditDetail.settleType == 3"></image>
		<image class="width90 " mode="widthFix" :src="idcardsideimg" v-if="auditDetail.settleType == 3"></image>
		<view class="titlename width100 font18 fontwig6 fcor333" v-if="auditDetail.settleType == 1">开户许可证图片</view>
		<image class="width90 " mode="widthFix" :src="accopenperimg" v-if="auditDetail.settleType == 1"></image>
		<view class="titlename width100 font18 fontwig6 fcor333" v-if="auditDetail.settleType == 2">结算银行卡图片</view>
		<image class="width90 " mode="widthFix" :src="settleimg" v-if="auditDetail.settleType != 1"></image>
		<view class="titlename width100 font18 fontwig6 fcor333"
			v-if="auditDetail.status == 2 || auditDetail.status == 4 || auditDetail.status == 6">驳回信息</view>
		<textarea class="width100 backcorfff" v-model="rejectReason" v-if="auditDetail.status == 2"
			style="padding: 15px;" placeholder="请填写审核驳回内容"></textarea>
		<textarea class="width100 backcorfff" :value="auditDetail.rejectReason" disabled="true"
			v-if="auditDetail.status == 4 || auditDetail.status == 6" style="padding: 15px;"></textarea>
		<view class="alijusstart" v-if="auditDetail.status == 2">
			<button class="btns mart40 backcor008" @click="approve()">通过</button>
			<button class="btns mart40 backcorlr" @click="reject()">驳回</button>
		</view>
		<view class="height70"></view>
	</view>
</template>

<script>
	import {
		reject,
		approve,
		getAuditDetail,
		getImgSignedUrl
	} from '../../../Utils/Api.js';
	export default {
		data() {
			return {
				auditNo: '', //审批编号
				auditDetail: '', //详情资料
				rejectReason: '', //驳回内容
				accopenperimg: '', //开户许可证图片
				settleimg: '', //结算银行卡
				uncorporsettelimg:'', //结算非法人信息
				idcardposimg: '', //身份证正面
				idcardsideimg: '' //身份证反面
			}
		},
		onLoad(options) {
			this.auditNo = options.id;
			this.getAuditDetail();
		},
		methods: {
			//查询详情
			getAuditDetail() {
				uni.showLoading({
					title: '加载中'
				})
				let datas = {
					applyNo: this.auditNo
				}
				getAuditDetail(datas).then(res => {
					uni.hideLoading();
					if (res.return_code == '000000') {
						this.auditDetail = res.return_data.auditObject;
						this.getImgSignedUrl(5, res.return_data.auditObject.openningBankLicenseUrl);
						if (res.return_data.auditObject.bankCardImg) {
							this.getImgSignedUrl(4, res.return_data.auditObject.bankCardImg);
						}
						if (res.return_data.auditObject.commissionImg) {
							this.getImgSignedUrl(10, res.return_data.auditObject.commissionImg);
						}
						if (res.return_data.auditObject.settleType == 3) {
							this.getImgSignedUrl(2, res.return_data.auditObject.settleIdCardPortraitImg);
							this.getImgSignedUrl(3, res.return_data.auditObject
								.settleIdCardNationalEmblemImg);
						}

					}
				})
			},
			//查看临时图片路径
			getImgSignedUrl(item, item1) {
				let datas = {
					"fileUrl": item1
				}
				getImgSignedUrl(datas).then(res => {
					if (res.return_code == '000000') {
						if (item == 5) {
							this.accopenperimg = res.return_data;
						}
						if (item == 4) {
							this.settleimg = res.return_data;
						}
						if (item == 2) {
							this.idcardposimg = res.return_data;
						}
						if (item == 3) {
							this.idcardsideimg = res.return_data;
						}
						if (item == 10) {
							this.uncorporsettelimg = res.return_data;
						}
					}
				})
			},
			//通过审核
			approve() {
				uni.showModal({
					title: '通过审核',
					content: '是否通过当前审核',
					success: (res) => {
						if (res.confirm) {
							uni.showLoading({
								title: '提交中'
							})
							let datas = {
								auditNo: this.auditNo
							}
							approve(datas).then(res => {
								uni.hideLoading();
								if (res.return_code == '000000') {
									uni.showToast({
										title: '提交成功',
										icon: "none",
										duration: 2000
									});
									uni.navigateBack();
								} else {
									uni.showToast({
										title: res.return_msg,
										icon: "none",
										duration: 2000
									});
								}
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			//驳回审核
			reject() {
				if (!this.rejectReason) {
					uni.showToast({
						title: '请填写驳回资料',
						icon: "none",
						duration: 2000
					});
					return;
				}
				uni.showModal({
					title: '驳回审核',
					content: '是否驳回当前审核',
					success: (res) => {
						if (res.confirm) {
							uni.showLoading({
								title: '提交中'
							})
							let datas = {
								auditNo: this.auditNo,
								"rejectReason": this.rejectReason
							}
							reject(datas).then(res => {
								uni.hideLoading();
								if (res.return_code == '000000') {
									uni.showToast({
										title: '提交成功',
										icon: "none",
										duration: 2000
									});
									uni.navigateBack();
								} else {
									uni.showToast({
										title: res.return_msg,
										icon: "none",
										duration: 2000
									});
								}
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f6f6f6;
	}

	.titlename {
		align-items: center;
		padding: 30rpx 0 30rpx 20rpx;
		background-color: #ffffff;
		border-bottom: 1px solid #f6f6f6;
	}

	.notes {
		width: calc(100% - 40rpx);
		display: flex;
		align-items: center;
		padding: 30rpx 0 30rpx 20rpx;
		border-bottom: 1px solid #f6f6f6;
	}

	.btns {
		width: 40%;
		height: 50px;
		line-height: 50px;
		color: #FFFFFF;
		font-weight: bold;
	}
</style>