<template>
	<view class="rf-category">
		<view class="icoStyle">
			<u-navbar :back-text-style="backStyle" back-icon-color="#fff" title-color="#fff"
				:title="i18n('ReportDetails')" :background="background">
			</u-navbar>
		</view>
		<view>
			<image src="../../../static/img/finance/header1.png" mode="" style="width: 100%;height:  214upx;"></image>
		</view>

		<view style="text-align: center;" v-for="item in pdfCtrl">
			<img :src="websiteUrl + initdata.fileAddress+'\\'+ (++item)+'.png'" mode="" style="width: 100%;"></img>
		</view>
		<view style="text-align: center;" v-if="pdfnum<1">
			{{$t('common.NoFile')}}
		</view>
		<view class="footerBox">
			<image src="../../../static/img/finance/footer2.png" mode=""
				style="width: 100%;height:  214upx; position: absolute;"></image>
			<view class="footerText">

				<text>{{$t('common.GEIDcpTitle')}}</text>
				<text class="footerName">{{$t('common.mail')}}：geidcp-info@geidco.org</text>
				<text class="footerName">{{$t('common.tel')}}：010-66598554</text>
			</view>
		</view>
		<rf-back-top :scrollTop="scrollTop1"></rf-back-top>

	</view>
</template>

<script>
	import rfSearchBar from '@/components/rf-search-bar';
	import {
		gateResearchResultFileById
	} from "@/api/research/baseResearchResultView";
	import {
		getBaseProjectEvaluationReportInfos
	} from "@/api/financialService/baseProjectEvaluationReportInfo";
	export default {
		components: {
			rfSearchBar,
		},
		data() {
			return {
				baseEntityId: null,
				projectData: '',
				initdata: '',
				// scrollTop:0,
				// old:{
				// 	scrollTop:0
				// },
				status: 'loadmore',
				pdfCtrl: [],
				listNum: 0,
				scrollTop1: 0,
				background: {
					backgroundImage: 'linear-gradient(270deg, #4BC0E2 0%, #538BE7 100%)',
				},
				backStyle: {
					color: '#fff'
				},
				pdfnum: 0,

			}
		},
		onLoad(data) {
			this.baseEntityId = data.key;
		},
		onShow() {
			this.getproject();
		},
		onPageScroll(e) {
			this.scrollTop1 = e.scrollTop;
		},
		methods: {
			back() {
				uni.navigateBack();
			},
			//获取项目详情
			async getproject() {
				let params = {
					language: this.$i18n.locale.toUpperCase(),
					baseEntityId: this.baseEntityId,
					statusDict: '2'
				}
				const res = await this.$myRequest({
					url: '/project/baseProjectEvaluationReportInfos/',
					data: {
						...params
					}
				});
				if (res.data) {
					this.projectData = res.data.baseProjectEvaluationReportInfos[0];
					this.getInitdata()
				}
			},
			//获取pdf详情
			async getInitdata() {
				let dataPrams = {
					pageNo: 1,
					pageSize: 1,
					language: this.$i18n.locale.toUpperCase(),
					researchResultFileId: this.projectData.pdfToPictureFileIds
				}
				const res = await this.$myRequest({
					url: '/resourceshare/baseResearchResultViews/gateResearchResultFile',
					data: {
						...dataPrams
					}
				});
				// let res = await gateResearchResultFileById(dataPrams);

				if (res.data.baseResearchResultFile !== "无数据") {
					this.initdata = res.data.baseResearchResultFile;
					this.listNum = this.initdata.filePages;
					this.goForpage()
				} else {
					this.initdata = {}
				}

			},
			goForpage() {
				this.pdfCtrl = [];
				for (let i = 0; i < this.initdata.filePages; i++) {
					this.pdfCtrl.push(i)
				}
				this.pdfnum = this.pdfCtrl.length;

			},
			i18n(data) {
				return this.$t('common.' + data);
			},
			//滚动到底的时候执行，实现加载更多
			// lower(e){
			// 	this.status='loading';
			// 	setTimeout(()=>{
			// 		this.status='loadmore';
			// 	},2000)
			// 	console.log(e)
			// },
		}
	}
</script>

<style lang="scss" scoped>
	uni-page-body {
		height: 100%;
		margin: 0;
		padding: 0;
	}

	.rf-category {
		background-color: $color-white;
		// height: 100%;
		position: relative;
		/*  #ifdef  APP-PLUS  */
		// margin-top: calc(20upx + var(--status-bar-height));

		/*  #endif  */
		.icoStyle {
			display: flex;
			align-items: center;

			.leftArrow {
				width: 36upx;
				height: 36upx;
				position: fixed;
				z-index: 99;
				/*  #ifdef  APP-PLUS  */
				padding-top: calc(20upx + var(--status-bar-height));
				/*  #endif  */
			}
		}

		.dataList {
			position: absolute;
			height: 99%;
			background-color: #fff;
			padding: 020upx;

		}

		.loademore {
			position: fixed;
			bottom: 0;
			z-index: 999;
			margin: 0 auto;
			width: 100%;
			height: 80upx;
			line-height: 80upx;
			background-color: #fff;
		}

		.footerBox {
			width: 100%;

			.footerText {
				z-index: 99;
				width: 100%;
				text-align: center;
				color: #fff;
				position: absolute;
				left: 50%;
				transform: translate(-50%, 20%);

				.footerName {
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
					display: block;
				}

			}

		}

		.backTop {
			bottom: 120px !important;
		}
	}
</style>
