<template>
	<view >
		<loadlogo v-if="!loadlogo" />
		<view class="yellowGoods" v-if="loadlogo">
			<view  v-if="cardlist">
				<business-card :businCard_list="cardlist" :is_collcet="'0'" :is_have="1" :is_pading="false" :is_yellow="true" @deleteis="deleteis"></business-card>
			</view>
			<load-more :isMore="isMore"></load-more>
		</view>
		<far-bottom></far-bottom>
		<!-- <phoneNavBar :checked="'收藏'"></phoneNavBar> -->
		<TabBars :tabBarAct="0" :pageType="'19'"></TabBars>
	</view>
</template>

<script>
	import App from '@/common/js/app.js';
	import businessCard from '@/components/page/pageComponents/businessCard.vue';
	import loadMore from '@/components/template/loadmore.vue';
	import Loadlogo from '@/components/template/loadlogo.vue';
	import phoneNavBar from '@/components/template/phoneNavBar';
	import TabBars from '@/components/template/tabBar.vue';
	export default{
		components:{
			businessCard,
			phoneNavBar,
			loadMore,
			Loadlogo,
			TabBars
		},
		data(){
			return{
				cardlist:null,
				isMore:true,
				count:1,
				loadlogo:false,
				page:1
			}
		},
		onLoad() {
			
		},
		onShow() {
			this.getlist();
		},
		computed:{
			curLoction(){
				return uni.getStorageSync('curLoction')
			}
		},
		methods:{
			deleteis(){
				this.getlist();
			},
			getlist(){
				let _this = this;
				for(let i = 0;i < _this.page;i++){
					let data={
						page:i,
						lng:this.curLoction.longitude || '',
						lat:this.curLoction.latitude || '',
					}
					App._post_form(
						`&p=yellowpage&do=myCollectList`,
						data,
						res => {
							console.log(res);
							if(i == 0){
								_this.setData({
									cardlist: res.data.list
								});
								_this.count = res.data.total;
							}else{
								_this.cardlist = _this.cardlist.concat(res.data.list);
							}
						},
						false,
						() => {
							_this.loadlogo = true;
						}
					);
				}
				
			}
		},
		// 页面上拉触底事件的处理函数
		onReachBottom: function() {
			let _this = this;
			this.isMore = false;
			console.log(this.page,this.count)
			if (this.page == this.count) {
				this.isMore = true;
			} else {
				this.page++;
				let data={
					page:_this.page,
					lng:this.curLoction.longitude || '',
					lat:this.curLoction.latitude || '',
				};
				App._post_form(
					`&p=yellowpage&do=myCollectList`,
					data,
					res => {
						console.log(res)
						this.cardlist = this.cardlist.concat(res.data.list);
						this.isMore = true;
						// this.count = res.data.total;
					},
					false,
					() => {}
				);
			}
		}
	}
</script>

<style>
	page{
		background-color: #F7F7F7;
	}
</style>
<style lang="scss" scoped>
	.yellowGoods{
		padding: 30upx 30upx 150upx;
	}
</style>
