<template>
	<view class="content">
		<u-radio-group v-model="radiovalue1" iconPlacement="row">
			<u-radio :customStyle="{marginBottom: '8px'}" v-for="(item, index) in radiolist1" :key="index"
				:label="item.name" :name="item.name" @change="radioChange">
			</u-radio>
		</u-radio-group>

		<view class="level1-title">证件信息</view>
		<view class="content1">
			<view class="flex flex-space-between">
				<view class="left">
					<view>驾驶证主页</view>
					<u-button type="primary">上传驾驶证主页</u-button>
				</view>
				<view class="left">
					<view>驾驶证副页</view>
					<u-button type="primary">上传驾驶证副页</u-button>
				</view>
			</view>
			<view class="flex flex-space-between">
				<view>驾驶证有效期</view>
				<view>选择驾驶证有效期</view>
			</view>
		</view>

		<u-divider text="分割线"></u-divider>
		<view class="content2">
			<view class="flex flex-space-between">
				<view class="left">
					<view>行驶证主页</view>
					<u-button type="primary">上传行驶证主页</u-button>
				</view>
				<view class="left">
					<view>行驶证副页</view>
					<u-button type="primary">上传行驶证副页</u-button>
				</view>
			</view>
			<view class="flex flex-space-between">
				<view>行驶证有效期</view>
				<view>选择行驶证有效期</view>
			</view>
		</view>
		<u-divider text="分割线"></u-divider>
		<view class="content3">
			<view class="flex flex-space-between">
				<view class="left">
					<view>挂车行驶证主页</view>
					<u-button type="primary">上传挂车行驶证主页</u-button>
				</view>
				<view class="left">
					<view>挂车行驶证副页</view>
					<u-button type="primary">上传挂车行驶证副页</u-button>
				</view>
			</view>
			<view class="flex flex-space-between">
				<view>挂车行驶证有效期</view>
				<view>选择挂车行驶证有效期</view>
			</view>
			<u-divider text="分割线"></u-divider>
		</view>
		<view class="content4">
			<view class="flex s-row">
				<view class="">从业资格证</view>
				<u-button type="primary">上传从业资格证</u-button>
			</view>
			<view class="flex flex-space-between">
				<view>从业资格证有效期</view>
				<view>选择从业资格证有效期</view>
			</view>
		</view>
		<u-divider text="分割线"></u-divider>
		<view class="content5">
			<view class="flex s-row">
				<view class="">运营证</view>
				<u-button type="primary">上传运营证</u-button>
			</view>
			<view class="flex flex-space-between">
				<view>运营证有效期</view>
				<view>选择运营证有效期</view>
			</view>
		</view>
		<u-divider text="分割线"></u-divider>
		<view class="content6">
			<view class="flex s-row">
				<view class="">挂车运营证</view>
				<u-button type="primary">上传挂车运营证</u-button>
			</view>
			<view class="flex flex-space-between">
				<view>挂车运营证有效期</view>
				<view>选择挂车运营证有效期</view>
			</view>
		</view>
		<u-button type="primary" @click="submit">提交</u-button>
		<u-toast ref="uToast"></u-toast>

	</view>
</template>

<script>
	import uploadImage from '@/components/ossutil/uploadFile.js';
	var _this;
	export default {
		components: {},
		data() {
			return {
				radiolist1: [{
						name: '挂车司机',
						disabled: false
					},
					{
						name: '非挂车司机',
						disabled: false
					}
				],
				// u-radio-group的v-model绑定的值如果设置为某个radio的name，就会被默认选中
				radiovalue1: '挂车司机',
			};
		},
		onLoad(options) {
			_this = this;
			console.log(options)
		},
		methods: {
			submit() {
				// 校验
				console.log('提交')
			},
			radioChange(n) {
				console.log('radioChange', n);
			},
			//设置图片
			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(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:
					}
				}

			},
			// 上传人车合影
			unloadGroupPhoto() {
				this.isShowimgType = true
				// uni.chooseImage({
				//     count: 1, 
				//     success: function (res) {
				//         console.log(JSON.stringify(res.tempFilePaths));
				// 		uploadImage(res.tempFilePaths[0], 'appData/',
				// 			result => {
				// 				// 上传成功
				// 				console.log('图片地址', result)
				// 			}
				// 		)
				//     }
				// });
			},
			//身份证正面
			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
				// 	})
				// })
			},

			// getImgUrl(res) {
			// 	// this.detailData.addressUrl = res
			// 	console.log(res)
			// 	console.log('------------res-----------')
			// },
			// onError(error) {
			// 	console.log('------------error-----------')
			// 	console.log(error)
			// },
			// onRemove(index) {},
			// filterFileType(index, lists) {
			// 	if (lists[index].fileType != 'jpg' && lists[index].fileType != 'png' && lists[index].fileType != 'gif') {
			// 		lists.splice(index, 1);
			// 		// 当前文件不支持
			// 		uni.showModal({
			// 			title: '暂不支持当前图片类型',
			// 			showCancel: false
			// 		});
			// 	} else {
			// 		this.isAdd = false;
			// 	}
			// },
			// onProgress(e) {
			// 	console.log(e)
			// },

		},
	};
</script>

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