<!-- 实验室列表 -->
<template>
	<view id="meCertificate">

		<scroll-view scroll-y @scrolltolower="scrollGet" class="for-max-box">
			<img class="null-img" v-if="!dataList[0]" src="@/pages_manage/images/null-data-1.png">
			<view class="bottom-for-box" v-for="(item,index) in dataList" :key="index">
				<view class="bottom-top-box">{{item.certTitle}}</view>
				<view class="bottom-bottom-box">
					<view class="bottom-right-box">{{item.createTime}}获得</view>
					<view class="bottom-right-box">到期时间:{{item.expirationTime}}</view>
				</view>
			</view>
			<view class="get-data-null-p" v-if="getDataType">- 没有更多数据 -</view>
		</scroll-view>
	</view>
</template>

<script>
	import $mqtt from '@/utils/mqtt.min.js';
	import {
		config
	} from '@/api/request/config.js'
	
	import {
		examExamQueryMyCert
	} from '@/pages_student/api/index.js'
	export default {
		data() {
			return {
				total: 0,
				dataList: [],
				getDataType: false,
				
				// 查询参数
				queryParams: {
					page: 1,
					pageSize: 10,
				},
			}
		},
		onLoad() {
			
			this.getList()
		},
		onShow() {},
		methods: {
			
			//滚动加载事件
			scrollGet() {
				let self = this;
				if (self.total / self.queryParams.pageSize <= self.queryParams.page) {
					this.$set(this, 'getDataType', true);
				} else {
					this.queryParams.page += 1;
					this.$nextTick(() => {
						this.getList();
					})
				}
			},
			//获取实验室列表
			async getList() {
				let self = this;
				let obj = JSON.parse(JSON.stringify(this.queryParams));
				
				const {
					data
				} = await examExamQueryMyCert(obj);
				if (data.code == 200) {
					if (self.queryParams.page == 1) {
						this.dataList = data.data.records;
						this.total = data.data.total;
						if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
							this.$set(this, 'getDataType', true);
						}
					} else {
						this.dataList = [...this.dataList, ...data.data.records]
						this.total = data.data.total;
						if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
							this.$set(this, 'getDataType', true);
						}
					}
				}
			},
			
		},
	}
</script>

<style lang="stylus" scoped>
	#meCertificate {
		height: 100%;
		display flex;
		flex-direction column;

		.for-max-box {
			flex: 1;

			overflow-y scroll;

			.null-img {
				display block;
				width: 276rpx;
				height: 321rpx;
				position absolute;
				top: 200rpx;
				left: 274rpx;
			}

			.for-box:nth-child(1) {
				border-top: none;
			}

			.bottom-for-box {
				height: 154rpx;
				margin: 0 20rpx;
				border-top: 1rpx solid #E0E0E0;
			
				overflow hidden;
			
				.bottom-top-box {
					font-size: 28rpx;
					line-height: 28rpx;
					color: #333;
					display: block;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
					margin: 36rpx 0 30rpx;
				}
			
				.bottom-bottom-box {
					display flex;
			
					view {
						flex: 1;
						line-height: 48rpx;
						font-size: 28rpx;
						color: #999999;
						display: block;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
					}
			
					view:nth-child(2) {
						text-align right
					}
			
				}
			}

			.get-data-null-p {
				text-align: center;
				line-height: 40rpx;
				padding-bottom: 40px;
				color: #999;
			}
		}
	}
</style>
