<template>
	<view class="content">
		<view class="content3 flex s-row">
			<view class="title">上传银行卡卡号页</view>
			<view @click="uploadImg" class="picture picture3">
				<image class="xj-image" src="@/static/images/mine/ic_shanchuan@2x.png"></image>
				<view class="text">上传银行卡卡号页</view>
			</view>
			<!-- <u-button type="primary" @click="uploadImg(3,index)">上传银行卡号页</u-button> -->
			<!-- 			<image class="preview" :src="item.payeeAddressUrl" mode="aspectFit"
				style="width:710rpx:height:710rpx;margin: 20rpx;"> </image> -->
			<view class="flex row">
				<view class="left-text">银行卡卡号</view>
				<view class="flex">
					<u--input placeholder="输入银行卡号码" inputAlign='left' border="none" v-model="dataDetails.bankCard">
					</u--input>
				</view>
			</view>
			<view class="flex row">
				<view class="left-text">开户行</view>
				<u--input placeholder="输入开户行" inputAlign='left' border="none" v-model="dataDetails.bankDeposit">
				</u--input>
			</view>
			<view class="flex row">
				<view class="left-text khzh-styel">开户支行</view>
				<view class="flex align-center" v-if="isShowManualInput">
					<u--input class="select-bankzh" placeholder="输入开户支行" inputAlign='left' border="none"
						v-model="dataDetails.bankDepositBranch">
					</u--input>
					<view @click="manualInput" class="type">选择支行</view>
				</view>
				<view class="flex align-center" v-if="!isShowManualInput">
					<!-- 	<u--input  @click="selectZhbank" placeholder="选择开户支行" inputAlign='left' border="none" disabled>
					</u--input> -->
					<view class="select-bankzh" @click="selectZhbank">选择开户支行</view>
					<view @click="manualInput" class="type">手动输入</view>
				</view>

			</view>
			<view class="flex row noborder">
				<view class="left-text">收款人</view>
				<view class="flex">
					<u--input placeholder="输入收款人姓名" inputAlign='left' border="none" v-model="dataDetails.payeeName">
					</u--input>
				</view>
			</view>
			<u-picker :show="isShowBank" :columns="bankType[index]" :closeOnClickOverlay='true' @close='zhBankClose'
				@cancel='zhBankClose' @confirm='confirmBank'></u-picker>
			</u-picker>
		</view>

		<u-toast ref="uToast"></u-toast>
		<view class="submit-btn" @click="$u.throttle(submit, 1000)">提交</view>
		<u-action-sheet :actions="$helper.imgTypeList" :title="$helper.imgType" :show="isShowimgType"
			@select="imgTypeSelect" :closeOnClickOverlay="true" :closeOnClickAction="true" @close="isShowimgType=false">
		</u-action-sheet>
	</view>
</template>

<script>
	import upload from '@/components/upload.vue';
	import permision from "@/js_sdk/wa-permission/permission.js"
	import uploadImage from '@/components/ossutil/uploadFile.js';
	var _this;
	export default {
		components: {},
		data() {
			return {
				isShowimgType: false,
				dataDetails: {},
				imagesrc: '',
				bankType: [],
				submitstatus:false,
				isShowBank: false,
				isShowManualInput: false,
				index: ''
			};
		},
		onLoad() {
			this.get_camera_permission()
			_this = this;
		},
		methods: {
			async get_camera_permission() {
				var photol=await permision.requestAndroidPermission("android.permission.CAMERA")
				if(photol == false){
					uni.showModal({
						title: '提示',
						content: '您已经关闭相机权限,去设置',
						success: function (res) {
							if (res.confirm) {
								permision.gotoAppPermissionSetting()
									            // plus.runtime.openURL("app-settings:");
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});	
				}
			},
			manualInput() {
				if (this.isShowManualInput) {
					if (uni.$u.test.isEmpty(this.bankType[this.index])) {
						this.$refs.uToast.show({
							type: 'error',
							message: "请先上传银行卡！",
						})
						return true
					}
					this.isShowBank = true

				} else {
					this.isShowBank = false
				}
				this.isShowManualInput = !this.isShowManualInput
			},
			//设置图片
			setImage(e) {
				console.log(e);
				//显示在页面
				//this.imagesrc = e.path;
				if (e.dotype == 'idphoto') {
					_this.zjzClipper(e.path);
				} else if (e.dotype == 'watermark') {
					_this.watermark(e.path);
				} else {
					_this.savePhoto(e.path);
				}
			},
			//保存图片到相册，方便核查
			savePhoto(path) {
				this.imagesrc = path;
				uploadImage(path, 'appData/',
					result => {
						// 上传成功
						console.log('图片地址', result)
					}
				)
				//保存到相册
				// uni.saveImageToPhotosAlbum({
				// 	filePath: path,
				// 	success: () => {
				// 		uni.showToast({
				// 			title: '已保存至相册',
				// 			duration: 2000
				// 		});
				// 	}
				// });
			},
			uploadImg() {

				this.isShowimgType = true
			},
			photograph() {
				console.log('拍照')
				let that = this;
				uni.chooseImage({
					count: 1,
					success: function(res) {
						console.log(JSON.stringify(res.tempFilePaths));
						uploadImage(res.tempFilePaths[0], 'appData/',
							result => {
								// 上传成功
								console.log('图片地址', result)
							}
						)
					}
				});

			},
			imgTypeSelect(val) {
				console.log(val)
				if (val.name == '相册') {
					uni.chooseImage({
						count: 1,
						sourceType: this.$helper.chooseImage.sourceType,
						success: function(res) {
							console.log(JSON.stringify(res.tempFilePaths));
							uploadImage(res.tempFilePaths[0], 'appData/',
								result => {
									// 上传成功
									console.log('图片地址', result)

								}
							)
						}
					});

				} else {

				}

			},
			//身份证正面
			getImgUrl1(src) {
				// console.log(src)
				// console.log('------------res-----------')
				// let that = this;
				// that.id[0] = src
				// that.id1 = src
				// that.certificates = false
				// that.personImgs.personImg = that.id[0]
				// that.$api.doRequest('get', '/driverViewInfo/personShibie', that
				// 	.personImgs).then(res => {
				// 	if (res.data.data.recPerson != null) {
				// 		if (res.data.data.recPerson != "") {
				// 			that.$set(that.DriverViewInfo, 'driverName', res
				// 				.data.data.recPerson)
				// 		}
				// 	}
				// 	if (res.data.data.recPersonNo != null) {
				// 		if (res.data.data.recPersonNo != "") {
				// 			that.$set(that.DriverViewInfo, 'numberCard', res
				// 				.data.data.recPersonNo)
				// 		}
				// 	}
				// }).catch(res => {
				// 	uni.showToast({
				// 		title: res.data.message,
				// 		icon: 'none',
				// 		duration: 2000
				// 	})
				// })
			},
			submit() {
				console.log(' tijia')
			},
		},
	};
</script>

<style scoped lang="scss">
	.row4-img {
		width: 32rpx;
		height: 32rpx;
	}

	.content {
		padding: 20rpx;
		height: calc(100vh - 23vh);
	}

	.content3 {
		background: white;
		padding: 20rpx;
		box-sizing: border-box;

		.left-text {
			// background: red;
			width: 290rpx;
			color: #333333;
			display: flex;
			align-items: center;
		}

		.row {
			border-bottom: 1px solid #EEEEEE;
			padding-bottom: 28rpx;
			margin-top: 26rpx;

			.ch-style {}
		}

		.row-ch {
			padding-right: 180rpx;
			box-sizing: border-box;
		}
	}

	.title {
		color: #999999;
		margin: 20rpx 0;
	}

	.picture {
		margin-top: 20rpx;
		background: #F5F6FA;
		border-radius: 10rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		color: #6A7282;
	}

	.picture {
		width: 100%;
		height: 440rpx;

		.text {
			margin-top: 20rpx;
		}
	}

	.xj-image {
		width: 100rpx;
		height: 100rpx;
	}

	.picture3 {
		background: url(../../../static/images/mine/yhkzm.png);
		background-size: 100% 100%;
	}

	.select-bankzh {
		width: 230rpx;
		// height: 48rpx;
	}

	.type {
		background: #2772FB;
		border-radius: 10rpx;
		color: white;
		box-sizing: border-box;
		padding: 4rpx 10rpx;
		font-size: 26rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		height: 68rpx;
	}

	.submit-btn {
		position: fixed;
		bottom: 40rpx;
		width: 90%;
		background: #2772FB;
		color: white;
		text-align: center;
		margin-left: 5%;
		padding: 30rpx 0;
		border-radius: 50rpx;
	}
</style>
