<template>
	<view class="">
		<view class="navbar">
			<view class="back">
				<text class="iconfont icon-fanhui " @click="backLast()"></text>
			</view>
			<text>文件详情</text>
		</view>
	
	<view class="upload-home">


		<view class="imgList">
			<view class="img-title">文件预览</view>
			<view class="img-box">
				<view class="htz-image-upload-list">
					<view class="htz-image-upload-Item" v-for="(item,index) in fileDetail.resource" :key="index" @click="enlargeImg(item)">
						<image class="img" :src="item" ></image>
						<!-- <view class="htz-image-upload-Item-del" v-if="remove" @click="imgDel(index)">×</view> -->
					</view>

				</view>
				<!--   -->
			</view>
			<view class="frame" v-show="isShow" @click="isShow=false">
				<view class="border" >
					<image :src="bigImg" mode="aspectFit" :lazy-load="true"></image>
				</view>
				
			</view>
			<!-- <view class="remark">
				拍摄时确保文件照片<text style="color: red;">边缘完整，字体完整，亮度均匀。</text>
			</view> -->
		</view>
		<view class="table">
			<view class="title">文件信息</view>
			<view class="text-box">
				<text class="input-key">文件名称：</text><text class="input-val">{{fileDetail.name}}</text>
			</view>
			<view class="text-box">
				<text class="input-key">上传时间：</text><text class="input-val">{{fileDetail.updated_at}}</text>
			</view>
		</view>

		<!-- <view class="tips" v-if="tips">
			<view class="title">注意事项：</view>
			<view class="content">{{tips}}点击下载模板</view>
		</view> -->
		<view class="submit" @click="deleteSubmit()">
			删除
		</view>
	</view>

</view>
</template>

<script>
	var app = getApp()
	import navBar from '../../components/navBar/navbar.vue';
	export default {
		components:{
			navBar
		},
		data() {
			return {
				fileDetail: {
					updated_at: "",
					status_text: "",
					user: {
						name: ''
					},
					name: ""
				},
				isShow: false,
				bigImg: "",
				id: ""
			}
		},
		
		onLoad(options) {
			uni.showLoading()
			let id = options.id
			this.id = options.id
			app.request('/archives/' + id, '', 'get').then(res => {
				this.fileDetail = res.data.data
				uni.hideLoading()
				console.log(res.data.data, '------------------列表详情')
			})
		},
		methods: {
			backLast:function(){
				console.log(this.url)
				uni.reLaunch({
					url:'./fileList'
				})
			},
			enlargeImg: function(e) {
				this.bigImg = e
				
				this.isShow = true
			},
			//删除数据
			deleteSubmit: function(id) {
				var that = this
				uni.showModal({
					title: '提示',
					content: '该操作将删除此项文件',
					success: function(res) {
						if (res.confirm) {
							uni.showLoading()
							app.request('/archives/' + that.id, '', 'delete').then(res => {
								console.log(res, "删除")
								uni.hideLoading()
								if (res.statusCode == 200) {
									uni.showToast({
										title: '删除成功',
										icon: 'none'
									})
									setTimeout(function(){
										uni.navigateBack()
									},500)
								}else{
									uni.showToast({
										title: '删除失败，请重试',
										icon: 'none'
									})
								}
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});

			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #EFF1F6;
	}
.navbar {
		font-size: 32upx;
		height: 100upx;
		line-height: 100upx;
		color: #888888;
		position: relative;
		position: fixed;
		top: 0;
		z-index: 9999999;
		width: 100%;
		 background-color: #FFFFFF;
		text-align: center;
		border-bottom: solid 2upx #EFF1F6;
	
		.back {
			height: 100upx;
			width: 100upx;
			text-align: center;
			// background-color: #007AFF;
			position: absolute;
			float: left;
			left: 0upx;
			font-size: 32upx;
		}
	}
	uni-page-body {
		height: 100%;
	}

	.htz-image-upload-list {
		display: flex;
		flex-wrap: wrap;
		justify-content: start;
	}

	.htz-image-upload-Item {
		// width: 200rpx;
		height: 200rpx;
		margin: 13rpx;
		border-radius: 10rpx;
		line-height: 200rpx;
		flex: 0 0 30%;
		position: relative;
	}

	.htz-image-upload-Item:first-child {
		margin-left: 5upx !important;
	}

	.htz-image-upload-Item:nth-child(4n) {
		margin-left: 5upx !important;
	}

	.htz-image-upload-Item:nth-child(3n) {
		margin-right: 5upx !important;
	}

	.htz-image-upload-Item image {
		width: 100%;
		height: 100%;
		border-radius: 10rpx;
		border: 1px solid #FF0000;
	}

	.upload-home {
		background-color: #EFF1F6;
		width: 100%;
		height: 100%;
		padding-top: 100upx;

		.table {
			background-color: #FFFFFF;
			font-size: 28upx;
			margin-top: 30upx;
			padding: 30upx;

			.title {
				color: #666;
				font-size: 30upx;
				display: block;
				padding-bottom: 30upx;
				border-bottom: 1px solid #EFF1F6;
			}

			.text-box {
				margin-top: 20upx;

				.input-key {
					display: inline-block;
					height: 80upx;
					line-height: 80upx;
					width: 160upx;
					vertical-align: top;
					color: #555;
					font-size: 32upx;
				}

				.input-val {
					display: inline-block;
					height: 80upx;
					line-height: 80upx;
					vertical-align: top;
					width: calc(100% - 160upx);
					text-align: right;
					color: #333;
					font-size: 32upx;
				}
			}
		}

		.imgList {
			background-color: #fff;
			padding: 30upx;

			.remark {
				font-size: 26upx;
				padding-top: 20upx;
				color: #555;
			}

			.img-title {
				color: #666;
				font-size: 30upx;
				display: block;
				position: relative;

				.down-tmp {
					color: red;
					position: absolute;
					right: 0;
				}
			}

			.img-box {
				margin-top: 20upx;
				background-color: #F3F3F3;
				border-radius: 10upx;
				padding: 15upx;

				.list-img {}
			}
		}





		.htz-image-upload-list {
			display: flex;
			flex-wrap: wrap;
		}


		.htz-image-upload-Item-add {
			font-size: 105rpx;
			/* line-height: 160rpx; */
			text-align: center;
			border: 1px dashed #d9d9d9;
			color: #d9d9d9;
		}

		.htz-image-upload-Item-del {
			background-color: #f5222d;
			font-size: 24rpx;
			position: absolute;
			width: 35rpx;
			height: 35rpx;
			line-height: 35rpx;
			text-align: center;
			top: 0;
			right: 0;
			z-index: 100;
			color: #fff;
		}

		.tips {
			margin: 90upx auto 0;
			border: 1px dashed red;
			padding: 20upx;
			width: 85%;
			border-radius: 15upx;
			font-size: 28upx;
			color: #555;

		}
	}

	.submit {
		position: fixed;
		height: 80upx;
		color: #FFFFFF;
		text-align: center;
		line-height: 80upx;
		width: 80%;
		bottom: 20upx;
		left: 10%;
		font-size: 32upx;
		border-radius: 10upx;
		background-color: #f5222d;
	}

	.frame {
		position: fixed;
		top: 0;
		left: 0;
		height: 100%;
		background-color: rgba($color: #000000, $alpha: 0.7);
		width: 100%;

		.border {
			width: 90%;
			height: 70%;
			// background-color: #007AFF;
			margin: 0 auto;
			margin-top: 100upx;
			image {
				width: 100%;
				height: 100%;
			}
		}


	}
</style>
