<template>
	<view class="content">
		<view class="content3 flex s-row">
			<view class="flex flex-space-between width100">
				上传银行卡正面
			</view>

			<u-button type="primary" @click="uploadImg(3)">上传银行卡号页</u-button>
			<view class="flex flex-space-between width100">
				<view>银行卡卡号</view>
				<view class="flex">
					<u--input placeholder="输入银行卡号码" inputAlign='right' border="none" v-model="dataDetails.name">
					</u--input>
					<u--image src="../../static/images/xiangji-2.png" width="40px" height="40px" @click='photograph'>
					</u--image>
				</view>
			</view>
			<view class="flex flex-space-between width100">
				<view>开户行</view>
				<view class="flex">
					<u--input placeholder="输入开户行" inputAlign='right' border="none" v-model="dataDetails.name">
					</u--input>
				</view>
			</view>
			<view class="flex flex-space-between width100">
				<view>开户支行</view>
				<view class="flex">
					<u--input placeholder="选择开户支行" inputAlign='right' border="none" v-model="dataDetails.name">
					</u--input>
					<view>手动输入</view>
				</view>
			</view>
			<view class="flex flex-space-between width100">
				<view>收款人</view>
				<view class="flex">
					<u--input placeholder="输入收款人姓名" inputAlign='right' border="none" v-model="dataDetails.name">
					</u--input>
				</view>
			</view>
		</view>
		<view class="" @click="submit">提交</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 uploadImage from '@/components/ossutil/uploadFile.js';
	var _this;
	export default {
		components: {},
		data() {
			return {
				uploadType: '',
				isShowimgType: false,
				dataDetails: {
					name: '阿萨啊',
					carNumberList: [{
						kahao: '',
						addressUrl: ''
					}],
					bankList: [{
						yhk: '',
						kh: '',
						khh: '',
						khzh: '',
						skr: ''
					}],
				},
				imagesrc: ''
			};
		},
		onLoad() {
			_this = this;
		},
		methods: {
			//设置图片
			setImage(e) {
				debugger
				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) {
				debugger
				this.imagesrc = path;
				uploadImage(path, 'appData/',
					result => {
						// 上传成功
						console.log('图片地址', result)
					}
				)
				//保存到相册
				// uni.saveImageToPhotosAlbum({
				// 	filePath: path,
				// 	success: () => {
				// 		uni.showToast({
				// 			title: '已保存至相册',
				// 			duration: 2000
				// 		});
				// 	}
				// });
			},
			uploadImg(type) {

				this.uploadType = type
				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)
				console.log(this.uploadType)
				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)
									switch (this.uploadType) {
										case 0:
											console.log('人车合影')
											break
										case 1:
											console.log('身份正面')
											break
										case 2:
											console.log('身份反面')
											break
										case 3:
											console.log('银行卡')
											break
										case 4:
									}
								}
							)
						}
					});

				} else {
					switch (this.uploadType) {
						case 0:
							console.log('人车合影')
							break
						case 1:
							uni.$u.route('/pages/mine/camera/idcard/idcard?dotype=face');
							console.log('身份正面')
							break
						case 2:
							console.log('身份反面')
							break
						case 3:
							console.log('银行卡')
							break
						case 4:
					}
				}

			},
			//身份证正面
			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;
	}
</style>
