<template>
	<view>
		<view class="list">
			<view class="li" v-for="(item,index) in pageList" :key="index" @click="jumpUrl('/leaflet/detail/index?code=' + item.code)">
				<image :src="item.pic" mode="aspectFill"></image>
				<view class="info">
					<view class="title">{{item.title}}</view>
					<view class="person">已报名<text>{{item.submitCount}}</text>人</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const app = getApp();
	const req = require("../../utils/request.js");
	export default {
		data() {
			return {
				form: {
					page: 1,
					limit: 10
				},
				pageList: [],
				isLoad: true,
				hasmore: true,
			};
		},
		onLoad: function(options) {
			this.getList();
		},
		onReachBottom: function() {
			this.form.page++
			this.getList()
		},
		methods: {
			getList() {
				let that = this;
				if (!that.isLoad) return false;
				that.isLoad = false;
				let form = that.form
				form.rootCode = 'brochure'
				req.getRequest('/api/v3/material/library', form, data => {
					if (data&&data.list && data.list.length >= 10) that.isLoad = true;
					if (that.page > 1) data.list = that.pageList.concat(data.list);
					that.pageList = data.list
				});
			},
			jumpUrl(url){
				uni.navigateTo({
					url: url
				})
			}
		}
	};
</script>

<style>
	@import "./index.css"
</style>
