<template>
	<view class="content">
		<view class="data_css">
			<view class="wrap">
				<view class="c-row">
					<view class="title">客户姓名</view>
					<view class="con-list">
						{{dataInfo.customerName}}
					</view>
				</view>
				<view class="c-row" v-show="dataInfo.customerPhone">
					<view class="title">手机号</view>
					<view class="con-list">
						{{dataInfo.customerPhone}}
					</view>
				</view>
				<view class="c-row" v-show="dataInfo.compAddress">
					<view class="title">联系地址</view>
					<view class="con-list">
						{{dataInfo.compAddress}}
					</view>
				</view>
				<view class="c-row">
					<view class="title">身份证号</view>
					<view class="con-list">
						{{dataInfo.customerNumberCard}}
					</view>
				</view>
			</view>
			<view class="wrap">
				<view class="tips">身份证照片</view>
				<view class="img" v-if="dataInfo.cardAddressUrl.length > 0">
					<u-swiper :list="dataInfo.cardAddressUrl" @change="e => currentNum = e.current" radius="10"
						indicatorMode="dot" height="360" img-mode="true" :autoplay="true" @click="openDocument1">
					</u-swiper>
				</view>
			</view>
			<view class="wrap">
				<view class="c-row ">
					<view class="title">银行卡号</view>
					<view class="con-list">
						{{dataInfo.bankCard}}
					</view>
				</view>
				<view class="c-row ">
					<view class="title">开户行</view>
					<view class="con-list">
						{{dataInfo.bankDeposit}}
					</view>
				</view>
				<view class="c-row ">
					<view class="title">开户支行</view>
					<view class="con-list">
						{{dataInfo.bankDepositBranch}}
					</view>
				</view>
			</view>
			<view class="wrap">
				<view class="tips">银行卡照片</view>
				<view class="img" v-if="dataInfo.payeeAddressUrl.length > 0">
					<u-swiper :list="dataInfo.payeeAddressUrl" @change="e => currentNum = e.current" radius="10"
						indicatorMode="dot" height="360" img-mode="true" :autoplay="true" @click="openDocument2">
					</u-swiper>
				</view>
			</view>
			<view class="wrap">
				<view class="c-row ">
					<view class="title">供应商</view>
					<view class="con-list">
						{{dataInfo.supplier?dataInfo.supplier:"暂无"}}
					</view>
				</view>
				<view class="c-row ">
					<view class="title">供应商电话</view>
					<view class="con-list">
						{{dataInfo.supplierPhone?dataInfo.supplierPhone:"暂无"}}
					</view>
				</view>
			</view>
		</view>
		<view class="btn">
			<view class="btn_left">
				<view class="noway" @click="submit(1)">
					驳回
				</view>
			</view>
			<view class="btn_right">
				<view class="sure" @click="submit(2)">
					通过
				</view>
			</view>
		</view>
		<u-modal v-model="auditShow" confirm-color='#22C572' confirm-text='确定' title='提示' :showCancelButton='false'
			:content="content" @confirm="next" @cancel="cancel"></u-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				dataInfo: {},
				auditShow: false,
				title: "提示",
				content: "",
				tips: "",
				currentNum: "",
				list3: [
					'https://cdn.uviewui.com/uview/swiper/swiper3.png',
					'https://cdn.uviewui.com/uview/swiper/swiper2.png',
					'https://cdn.uviewui.com/uview/swiper/swiper1.png',
				],
			}
		},
		onShow() {

		},
		onLoad(options) {
			if (options.data) {
				this.dataInfo = JSON.parse(options.data)
				if (this.dataInfo.cardAddressUrl) {
					this.dataInfo.cardAddressUrl = this.dataInfo.cardAddressUrl.split(",")
				}
				if (this.dataInfo.payeeAddressUrl) {
					this.dataInfo.payeeAddressUrl = this.dataInfo.payeeAddressUrl.split(",")
				}
			}
		},
		methods: {
			cancel() {
				this.auditShow = false
			},
			next() {
				if (this.tips == 1) {
					this.reject()
				} else if (this.tips == 2) {
					this.adopt()
				}
			},
			openDocument1(e) {
				let imgUrl = this.dataInfo.cardAddressUrl[e]
				uni.downloadFile({
					url: imgUrl,
					success: function(res) {
						var filePath = res.tempFilePath;
						uni.openDocument({
							filePath: filePath,
							showMenu: true,
							success: function(res) {
								console.log('打开文档成功');
							}
						});
					}
				});
			},
			openDocument2(e) {
				let imgUrl = this.dataInfo.payeeAddressUrl[e]
				uni.downloadFile({
					url: imgUrl,
					success: function(res) {
						var filePath = res.tempFilePath;
						uni.openDocument({
							filePath: filePath,
							showMenu: true,
							success: function(res) {
								console.log('打开文档成功');
							}
						});
					}
				});
			},
			submit(num) {
				if (num == 1) {
					this.tips = 1
					this.content = "确定驳回客户信息？"
				} else {
					this.tips = 2
					this.content = "确定通过客户信息？"
				}
				this.auditShow = true
			},
			reject() {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				this.$api.doRequest('post', '/identityAuthenticationInfo/api/examine', {
					id: this.dataInfo.id,
					flag: 2,
					examiner: uni.getStorageSync('userInfo').userName
				}).then(res1 => {
					uni.hideLoading()
					this.$api.msg('驳回成功！')
					setTimeout(function() {
						uni.navigateBack({
							delta: 1
						});
					}, 2000);
				})
			},
			adopt() {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				this.$api.doRequest('post', '/identityAuthenticationInfo/api/examine', {
					id: this.dataInfo.id,
					flag: 1,
					examiner: uni.getStorageSync('userInfo').userName
				}).then(res1 => {
					uni.hideLoading()
					this.$api.msg('通过成功！')

					setTimeout(function() {
						uni.navigateBack({
							delta: 1
						});
					}, 2000);
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.data_css {
		margin-bottom: 220rpx;
	}

	.wrap {
		padding-bottom: 10px;
		font-size: 14px;
		background: #fff;
		margin: 10px;
		border-radius: 10px;
		padding: 30rpx 30rpx;

		input {
			font-size: 14px;
		}

		.title {
			font-size: 28rpx;
		}

		.tips {
			font-size: 34rpx;
			font-weight: 600;
			border-bottom: 1px solid #EEEEEE;
			padding-bottom: 30rpx;
		}

		.c-row {
			display: -webkit-box;
			display: -webkit-flex;
			display: flex;
			-webkit-box-align: center;
			-webkit-align-items: center;
			align-items: center;
			padding: 40rpx 0;
			position: relative;
			border-bottom: 1px solid #EEEEEE;
		}

		.con-list {
			-webkit-box-flex: 1;
			-webkit-flex: 1;
			flex: 1;
			display: -webkit-box;
			display: -webkit-flex;
			display: flex;
			-webkit-box-orient: vertical;
			-webkit-box-direction: normal;
			-webkit-flex-direction: column;
			flex-direction: column;
			color: #AFB3BF;
			line-height: 40rpx;
			text-align: right;
			padding-right: 20rpx;
		}
	}

	.btn {
		width: 100%;
		height: 200rpx;
		background-color: #ffffff;
		position: fixed;
		bottom: 0px;
		display: flex;
		padding-top: 40rpx;

		.btn_left,
		.btn_right {
			width: 50%;
			text-align: center;
			// line-height: 160rpx;
			margin: 0 auto;
		}

		.noway,
		.sure {
			width: 80%;
			height: 90rpx;
			line-height: 90rpx;
			margin: 0 auto;
			border-radius: 45rpx;
			font-size: 32rpx;
		}

		.sure {
			background-color: #5C76DF;
			color: #ffffff;
		}

		.noway {
			background-color: #F7F8FA;
			color: #AFB3BF;
		}
	}

	.img {
		width: 100%;
		margin: 20rpx auto;
		text-align: center;

		// .img_css {
		// 	width: 96%;
		// 	height: 440rpx;
		// }
	}
</style>
