<template>
	<scroll-view 
	scroll-y="true" 
	:style="{height: height}"
	@scrolltolower="loadMoreData">
		<view class="workList">
			<view
				@click="$utils.navigateTo('/pages_order/work/workDetail?id=' + 123)"
				: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 : ''
			}
		},
		data() {
			return {
				queryParams: {
					pageNo: 1,
					pageSize: 10,
				},
				total : 0,
				list : 10,
			}
		},
		methods: {
			queryVideoList(){
				if(uni.getStorageSync('token')){
					this.queryParams.token = uni.getStorageSync('token')
				}
				
				this.$api(this.api, this.queryParams, res => {
					if(res.code == 200){
						this.list = res.result
						// this.total = res.result.total
					}
				})
			},
			loadMoreData(){
				if(this.queryParams.pageSize <= this.list.length){
					this.queryParams.pageSize += 10
					this.queryVideoList()
				}
			},
		}
	}
</script>

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