<template>
	<view>
		<cu-custom bgColor="bg-gradual-blueness" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">检查照片</block>
		</cu-custom>
		<scroll-view scroll-y>
			<view class="de-card-list de-list">
				<view class="de-item-sp">
					<view class="de-sub-title">
						<text class="text-grey">检查照片</text>
					</view>
					<view class="de-sub-content">
						<scroll-view scroll-x class="bg-white nav" scroll-with-animation>
							<view class="cu-item" v-for="(item,index) in files" v-bind:key="index">
								<view class="imgs">
									<image :src="baseImgPath+item.FILEPATH" :data-index="index" @click="ViewShowImage" mode=""></image>
								</view>
							</view>
						</scroll-view>
					</view>
				</view>
			</view>

			<view class="cu-tabbar-height"></view>
		</scroll-view>
	</view>
</template>

<script>
	import {
		basePath,baseImgPath
	} from '@/common/tool.js';
	export default {
		data() {
			return {
				noClick: true,
				date: '',
				imgList: [],
				id: '',
				pd: [],
				hs: [],
				files: [],
				basePath:basePath,
				baseImgPath:baseImgPath,
				ISQUALIFIED:'1'
			}
		},
		onLoad(e) {
			this.id = e.id;
			// let now = new Date();
			// this.date = formatDate(now, 'yyyy-MM-dd');
			this.getData();
		},
		// filters: {
		// 	formatDate(time) {
		// 		time = time * 1
		// 		let date = new Date(time)
		// 		return formatDate(date, 'yyyy-MM-dd hh:mm')
		// 	}
		// },
		methods: {
			getData() {
				var _this = this;
				uni.showLoading({
					title: '请稍候'
				})
				uni.request({
					url: basePath + '/app/imgfiles/listImgs',
					method: 'POST',
					dataType: 'json',
					header: {
						'Content-type': 'application/x-www-form-urlencoded'
					},
					data: {
						FOREIGN_KEY: _this.id,
						TYPE:14
					},
					success: (res) => {
						if ("success" == res.data.result) {
							uni.hideLoading();
							_this.files=res.data.imgs;
						} else if ("exception" == data.result) {
							uni.showToast({
								title: '错误',
								duration: 2000
							});
						}
					}
				});
			},
			//图片上传
			ChooseImage() {
				var _this = this;
				uni.chooseImage({
					count: 4, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
					sourceType: ['camera', 'album'], //从相册选择
					success: (res) => {
						if (this.imgList.length != 0) {
							this.imgList = this.imgList.concat(res.tempFilePaths)
						} else {
							this.imgList = res.tempFilePaths
						}
					}
				});
			},
			ViewImage(e) {
				uni.previewImage({
					urls: this.imgList,
					current: e.currentTarget.dataset.url
				});
			},
			DelImg(e) {
				uni.showModal({
					title: '双控平台',
					content: '确定要删除这张图片吗?',
					cancelColor: "#000000",
					cancelText: '取消',
					confirmText: '确定',
					success: res => {
						if (res.confirm) {
							this.imgList.splice(e.currentTarget.dataset.index, 1)
						}
					}
				})
			},
			
			ViewShowImage(e) {
				let files = [];
				for (var i = 0; i < this.files.length; i++) {
					files.push(baseImgPath+this.files[i].FILEPATH)
				}
				uni.previewImage({
					urls: files,
					current: e.currentTarget.dataset.index
				});
			},
			ViewShowImages(imgs,index) {
				let files = [];
				for (var i = 0; i < imgs.length; i++) {
					files.push(baseImgPath+imgs[i].FILEPATH)
				}
				uni.previewImage({
					urls: files,
					current: index
				});
			},
			goToOpen(e) {
				var url=e;
				plus.runtime.openURL(url, function(res) {
					console.log(res);
				});
		 

				// uni.navigateTo({
				// 	url: '/pages/application/safety-production-account/organization-personnel/web-view?link=' + url
				// });
			},
		}
	}
</script>

<style>
	.bb {
		border-top: 1upx solid #f1f1f1;
		border-bottom: 1upx solid #f1f1f1;
	}

	.cu-bar .action:first-child {
		font-size: 26upx
	}

	.cu-form-title {
		padding: 20upx 0;
	}

	.cu-form-textarea {
		background-color: #ffffff;
		padding: 1upx 30upx 20upx;
		min-height: 100upx;
	}

	.cu-form-textarea textarea {
		height: 4.6em;
		width: 100%;
		line-height: 1.2em;
		flex: 1;
		font-size: 28upx;
		padding: 0;
	}

	.cu-form-group {
		padding: 0upx 25upx;
	}

	.cu-form-group picker .picker {
		line-height: 76upx;
	}

	.cu-form-group .title {
		font-size: 28upx;
		line-height: 76upx;
		color: #888;
	}

	.cu-form-group uni-picker::after {
		top: -11upx;
	}

	.selected {
		display: flex;
		align-items: center;
	}

	.selected .radio {
		transform: scale(0.5);
		margin-right: 10upx;
	}

	.cu-btn {
		border-radius: 0;
		width: 100%;
		height: 84upx;
		font-weight: bold;
	}

	.group {
		display: flex;
		align-items: center;
	}
</style>