<template>
	<view class="ayuu">
		<view class="cpsahnty">
			<view class="cpsahtxt">
				<text>
					上传体检报告
				</text>
			</view>
			<view class="fzddrew cpsahngc" @click="getimg">
				<image :src="img?img:'../../static/user/cp-sc.png'" mode="widthFix"></image>
			</view>
		</view>
		<view class="list-box">
			<view class="list-title">
				<view class="" style="font-weight: bold;">我已上传的测评报告:</view>
				<view class=""></view>
			</view>
			<view class="table-box">
				<uni-table border stripe emptyText="暂无更多数据" >
					<!-- 表头行 -->
					<uni-tr>
						<uni-th align="center">体检报告名称</uni-th>
						<uni-th align="center">测评结果</uni-th>
					</uni-tr>
					<!-- 表格数据行 -->
					<uni-tr v-for="(item,index) in reviewLogList" :key="index">
						<uni-td>报告{{index + 1}}</uni-td>
						<!-- <uni-td>
							<view class="td-view">
								<view class="">测评排队中</view>
								<view class="">[前方等待8人,还需1天]</view>
							</view>
						</uni-td> -->
						<uni-td>
							<view class="td-view" style="color: #ff0000;" @click="goTojg(item.id)">查看测评结果</view>
						</uni-td>
					</uni-tr>
					
				</uni-table>
				
			</view>
			</view>
			<view style="height: 120rpx;"></view>
		<view class="fzddrew fknbee">
			<view class="fzddrew fkdibr" style="background: #95bf7f;" @click="subInfo">
				<text>立即上传</text>
			</view>
		</view>
	</view>
</template>
<style>
	page {
		background: #FAFAFA;
	}
</style>
<script>
	export default {
		data() {
			return {
				img: '',
				reviewLogList: [],
				tempFilePaths: null
			}
		},
		onLoad() {
			this.user_id = uni.getStorageSync('id');
			this.vip_pay = uni.getStorageSync('is_vip');
			this.getReviewLog();
		},
		methods: {
			goTojg(id){
				uni.navigateTo({
					url: '/pages/user/cp-jg?id=' + id
				})
			},
			getReviewLog(){
				let that = this;
				that.$request.getReviewLog({}).then( res =>{
					console.log(res)
					if(res.code == 0){
						this.reviewLogList = res.data;
					}else{
						uni.showToast({
							title: res.message,
							icon: "none",
						})
						if(res.message == '请先登录'){
							uni.setStorageSync('userinfo',null);
							uni.setStorageSync('id','');
							uni.setStorageSync("token",'');
							setTimeout( () =>{
								uni.reLaunch({
									url:'/pages/lecturer/my'
								})
							},2000)
						}
					}
				}).catch( e =>{
					console.log(e)
				})
			},
			getimg() {
				let that = this;
				// chooseImage
				
				// 用户已经同意小程序使用相册
				  uni.chooseMedia({
						count: 1,
						sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
						sourceType: ['album'], //从相册选择
						success: (res) => {
							console.log(res)
							let tempFiles = res.tempFiles;
							that.img = tempFiles[0].tempFilePath;
							that.tempFilePaths = tempFiles[0];
						},
						fail:(res) => {
							console.log(res)
						},
					})
				
				
			},
			// 提交信息
			subInfo(){
				let that = this;
				if(!that.img){
					uni.showToast({
						title:'请选择体检报告',
						icon:'none'
					})
					return
				}
				uni.showLoading({
					title:'加载中...',
					mask:true
				})
				setTimeout( () =>{
					uni.hideLoading();
					uni.navigateTo({
						url:'../user/cp-pay?tempFilePaths='+ JSON.stringify(that.tempFilePaths)
					})
				},2000)
		
			}

		}
	}
</script>

<style lang="scss" scoped>
	.ayuu{
		height: 100vh;
		overflow-y: auto;
	}
	.list-box{
		width: 100%;
		height: auto;
		margin-top: 20rpx;
		padding: 10rpx 20rpx;
		box-sizing: border-box;
	}
	.list-title{
		font-size: 28rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		
	}
	.table-box{
		margin-top: 10rpx;
		padding: 20rpx 0;
		box-sizing: border-box;
		background: #fff;
	}
	.table-box /deep/ .uni-table-th{
		padding: 12rpx 10rpx;
		color: #000;
	}
	.td-view{
		text-align: center;
	}

</style>
