<template>
	<view class="web_box">
		<!-- <u-navbar height="44" leftIcon="arrow-left" leftIconColor="#000" leftText="我的证书" @leftClick="leftClick" :autoBack="true" bgColor="#fff">
		</u-navbar> -->
		<view class="list" v-if="certificateList.length > 0">
			<block v-for="(item,index) in certificateList" :key="index">
				<view class="list_item hflex acenter">
					<u-image :src="item.certificate" width="320rpx" height="232rpx" @click="clickimg(index)"></u-image>
					<view class="img_right vflex jbetween">
						<view class="name">证书名称：{{item.name}}</view>
						<view>
							<view class="text_style1">证书编号：{{item.certificate_number}}</view>
							<view class="text_style1">颁发时间：{{item.create_at}}</view>
						</view>
					</view>
				</view>
			</block>
		</view>
		<view class="list vflex acenter jcenter" v-else>
			<image src="../../static/images/common/collect_none.png" class="img_none"></image>
			<view class="text_none">
				暂无证书
			</view>
		</view>
	</view>
</template>

<script>
	import $api from '@/static/js/api.js'
	export default {
		data() {
			return {
				certificateList: [
					
				],
				page: 1,
				limit: 10,
				total: 0
			}
		},
		onLoad() {
			this.getCertificateList()
		},
		methods: {
			leftClick() {
				
			},
			// 获取证书列表
			getCertificateList() {
				var that = this
				$api.req({
					url: '/api/User/myCertificate',
					data: {
						page: that.page,
						limit: that.limit
					}
				}, function(res) {
					if (res.code == 1) {
						if(that.page == 1) {
							that.certificateList = res.data.list
							that.total = res.data.count
						} else {
							that.certificateList = that.certificateList.concat(res.data.list)
						}
						
					}
				})
			},
			// 触底事件
			onReachBottom() {
				console.log("到底了");
				console.log(Number(this.page) , Number(this.limit));
				if (Number(this.page) * Number(this.limit) >= Number(this.total)) {
					$api.info("没有更多了")
				} else {
					this.page++
					this.getCertificateList()
				}
			},
			clickimg(index) {
				var that = this
				uni.previewImage({
					urls: [that.certificateList[index].certificate],
					current: '',
					success:function(res){
						
					}
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.web_box::v-deep {
		padding: 0 30rpx;
		
		.u-navbar {
			width: 100%;
			box-sizing: border-box;
			padding: 36px 16px 58rpx 0;
		}
		.list {
			width: 100%;
		}
		.list_item {
			width: 100%;
			margin-top: 20rpx;
		}
		.img_right {
			width: calc(100% - 320rpx);
			height: 232rpx;
			box-sizing: border-box;
			padding: 32rpx 0 24rpx 10rpx;
		}
		.name {
			font-size: 27rpx;
			font-weight: 500;
			color: #333;
			line-height: 40rpx;
		}
		.text_style1 {
			font-size: 24rpx;
			font-weight: 400;
			color: #333333;
		}
		.text_none {
			font-size: 32rpx;
			color: #333333;
			margin-top: 44rpx;
		}
		.img_none {
			margin-top: 300rpx;
			width: 570rpx;
			height: 328rpx;
		}
	}
</style>