<template>
	<view class="home-pages">
		<view style="color: #707070;
			font-size: 28rpx;">
		</view>
		<view class="home-content">
			
			<u-tabs
			:list="tabList"
			lineWidth="70"
			lineHeight="3"
			lineColor= "#00CCCC"
			:activeStyle="{
				color: '#000000',
				fontWeight: 'bold',
				transform: 'scale(1.35)'
			}"
			:inactiveStyle="{
				color: '#000000',
				transform: 'scale(1)'
			}"
			itemStyle="padding-left: 15px; padding-right: 15px; height: 34px;"
			@click="tabClick"
			>
			</u-tabs>
			
			
			<scroll-view scroll-y="true" class="scroll-y" 
				
					<card v-for="(item,i) in studyList" :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,
					labelClass:'0',
					pageSize:10,
					total: null,
					isLock: true
				},
				current:0,
				studyList:[],
				tabList: [
					{
						id:'0',
						name:'地址信息'
					},
				]
			}
		},
		onLoad() {
			this.studyList = [];
			this.params.labelClass = "0";
			this.params.pageNo = 1;
			this.params.total = null;
			this.params.isLock = true;
			this.queryPageListJobRelease();
		},
		// 隐藏微信h5的标题栏
		onReady() {
			this.$com.displayNav()
		},
		onPullDownRefresh() {
			this.studyList = [];
			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('getAddressList',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.studyList = this.studyList.concat(res.result.records);
						this.params.isLock = true;
					}else {
						if(this.params.pageNo>1){
							uni.hideLoading();
						}
						this.params.isLock = true;
					}	
				})
			},
			tabClick(e){
				this.params.labelClass = e.id;
				this.params.pageNo =1;
				this.studyList = [];
				this.queryPageListJobRelease();
			},
		}
	}
</script>

<style lang="scss" scoped>
	.home-pages {
		padding: 28rpx 29rpx 0;
		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>