<template>
	<view>
		<uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="备品备件申请单" @clickLeft="back"></uni-nav-bar>
		<pickCard :list="list" />
		<view v-show="list.length === 0" class="no_data">
			<u-empty mode="data"></u-empty>
		</view>

	</view>
</template>

<script>
	import pickCard from '@/pages/maintenanceWorkorder/components/pickCard.vue'
	import {
		getList
	} from '@/api/repair'
	let [page, size, isEnd] = [1, 10, true]
	export default {
		components: {
			pickCard
		},
		data() {
			return {
				list: [],
			}
		},
		onShow() {
			this.getFirstList()
		},
		onReachBottom: function() {
			console.log(11, 'a')
			if (isEnd) {
				return
			}
			// 显示加载图标
			uni.showLoading({
				title: '数据加载中'
			})
			this.getMoreLists()
		},
		methods: {
			getFirstList: function() {
				page = 1
				isEnd = true
				this.getList()
			},
			getMoreLists: function() {
				//获取更多数据
				page++
				this.getList()
			},
			getList() {
				uni.showLoading({
					title: '数据加载中'
				})
				let params = {
					pageNum: page,
					size
				}
				getList(params)
					.then(res => {

						if (page == 1) {
							this.list = res.list
						} else {
							res.list.forEach(element => {
								this.list.push(element)
							})
						}
						isEnd = this.list.length >= res.count
						uni.hideLoading()
					})
					.catch(() => {
						uni.hideLoading()
					})
			},

		}
	}
</script>

<style lang="scss" scoped>

</style>