<template>
	<view class="bg-white">
		<!-- 顶部 -->
		<cu-custom bgColor="bg-blue" :isBack="true">
			<block slot="backText">影像资料</block>
			<block slot="content"></block>
			<block slot="right">
				<view class="flex justify-center">
					<!-- <button class="margin-top-ssm cu-btn round line-blue text-white">生成二维码</button> -->
				</view>
			</block>
		</cu-custom>
		<view class="text-orange title-font">
			*上传的单张图片大小不超过15MB，单个视频大小不超过500MB！
		</view>
		<view>
			<view v-for="(item,index) in list" :key="item.name">
				<template v-if="item.list.length >0">
				<view class="bg-gray padding-sm text-bold color-black">
					{{item.name}}
				</view>
				<view v-for="(item2,index2) in item.list" :key="item2.id" class="flex solid-bottom padding-sm justify-between align-center" @tap="toMedialist(item2)">
					<view class="flex align-center">
						<text class="text-gray icon-size" :class="[item2.fileType=='0' ? 'cuIcon-album' : 'cuIcon-video']"></text>
						<view>
							<view class="text-bold text-xl color-black">{{item2.name}}</view>
							<view class="text-df">{{item2.fileN}}{{item2.fileType=="0"?'张照片':'个视频'}}</view>
						</view>
					</view>
					<text class="lg text-gray cuIcon-right"></text>
				</view>
				</template>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo:null,
				project:null,
				list:[
					{
						name:'项目前期',
						list:[]
					},
					{
						name:'项目中期',
						list:[]
					},{
						name:'交工竣工',
						list:[]
					},
				]
			}
		},
		onLoad(e) {
			var userInfo = uni.getStorageSync("userInfo")
			if(userInfo){
				this.userInfo = userInfo;
				this.project =  uni.getStorageSync("porject"+"_"+userInfo.id);
			}
			
		},
		onShow() {
			this.loadTable();
		},
		methods: {
			toMedialist(item){
				//是否按部位保存
				//0是，1否
				if(!item.isAssociatedNode){
					uni.navigateTo({
						url: "/pages/multimedia/divide?type=" + item.fileType +"&tagId=" + item.id + "&titleName=" + encodeURIComponent(item.name)
					})
				}else{
					uni.navigateTo({
						url: "/pages/multimedia/medialist?type=" + item.fileType +"&tagId=" + item.id + "&titleName=" + encodeURIComponent(item.name)
					})
				}
			},
			
			loadTable(){
				this.http.request('/app/multimedia/list', {
					contractId:this.project.contractId,
					projectId:this.project.id,
					owner:this.project.contract_type
				}).then((result)=>{
					if(result.result == 1){
						this.list[0].list = [];
						this.list[1].list = [];
						this.list[2].list = [];
						for (let i = 0; i < result.datas.length; i++) {
							this.list[result.datas[i].period].list.push(result.datas[i]);
						}
					}			   
				})
			},
			
		},
	}
</script>

<style>
	.title-font{
		font-size: 30rpx;
		padding: 20rpx;
	}
	.color-black{
		color: #333333;
	}
	.icon-size{
		font-size: 60rpx;
		margin-right: 16rpx;
	}
</style>
