<template>
	<scroll-view 
	scroll-y="true" 
	:style="{height: height}"
	@scrolltolower="loadMoreData">
		<view class="workList">
			<view
				@click="$utils.navigateTo('/pages_order/work/workDetail?id=' + item.id)"
				:key="index"
				v-for="(item, index) in list">
				<workItem :item="item"/>
			</view>
		</view>
	</scroll-view>
</template>

<script>
	import workItem from './workItem.vue'
	export default {
		components : {
			workItem,
		},
		props : {
			height : {
				default : 'auto'
			},
			api : {
				default : 'getJobPage'
			}
		},
		data() {
			return {
				queryParams: {
					pageNo: 1,
					pageSize: 10,
				},
				total : 0,
				list : [],
			}
		},
		methods: {
			getData(title){
				this.queryParams.title = title
				this.$api(this.api, this.queryParams, res => {
					uni.stopPullDownRefresh()
					if(res.code == 200){
						this.list = res.result.records || res.result
						this.total = res.result.total || res.result.length
					}
				})
			},
			loadMoreData(){
				if(this.queryParams.pageSize <= this.list.length){
					this.queryParams.pageSize += 10
					this.getData()
				}
			},
		}
	}
</script>

<style scoped lang="scss">
	.workList {
		&>view{
			margin: 20rpx;
		}
	}
</style>