<template>
	<view class="home-pages">
		<view style="color: #707070;
			font-size: 28rpx;">
		</view>
		<view class="home-content">
			<scroll-view scroll-y="true" class="scroll-y" 
				<card v-for="(item,i) in list" :item="item" :key="i" :i="i"  @seeDetail="seeDetail"></card>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import card from '@/components/active-card/address-list.vue'
	export default{
		components:{
			card,
		},
		data(){
			return{
				params:{
					pageNo:1,
					pageSize:10,
					total: null,
					isLock: true
				},
				list:[
					
				]
			}
		},
		onLoad() {
			this.params.pageNo = 1;
			this.params.total = null;
			this.params.isLock = true;
			this.queryPageListJobRelease();
		},
		onReady() {
			this.$com.displayNav()
		},
		onPullDownRefresh() {
			this.list = [];
			this.params.pageNo = 1;
			this.params.total = null;
			this.params.isLock = true;
			this.queryPageListJobRelease()
		},
		onReachBottom() {
			if(this.params.isLock){
				this.params.isLock = false;
				if(this.params.total !== null && this.params.pageNo * this.params.pageSize >= this.params.total){
					this.$Toast('没有更多数据了哦！');
					setTimeout(()=>{
						this.params.isLock = true;
					},3000)
					return
				}
				this.params.pageNo+=1;
				this.$Toast('数据加载成功！');
				this.queryPageListJobRelease();
			}
		},
		methods:{
			queryPageListJobRelease(){//学习列表
				if(this.pageNo>1){
					uni.showLoading({})
				}
				this.$api('getKwList',this.params)
				.then(res=>{
					if(res.code == 200){
						if(this.params.total== null) {
							this.params.total = res.result.total
						}
						
						if(this.params.pageNo>1){
							uni.hideLoading();
						}
						this.list = this.list.concat(res.result.records);
						this.params.isLock = true;
					}else {
						if(this.params.pageNo>1){
							uni.hideLoading();
						}
						this.params.isLock = true;
					}	
				})
			},
			seeDetail(item){
				uni.navigateTo({
					url:`/pages/my/kanwudetails?id=`+item.id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.home-pages {
		padding: 28rpx 29rpx 0;
		min-height: 80vh;
		background-color: #F7F7F7;
		
		.swiper{
			position: relative;
			height: calc(100% -7vh);
			width: 100%;
			height: 1800px;
		}
		.scroll-Y {
			height: calc(300vh - 660rpx);
			padding-top: 20rpx;
		}
		
		.home-content {
			.active-card{
				margin-top: 20rpx;;
				border-radius: 0;
				border: none;
				border-style: none;
				box-shadow: none;
			}
		}
		
	}
	
</style>