<template>
	<view class="content">
		<view class="top-fan"></view>
		<view class="fans-base flex">
			<view class="base-item">
				<view class="base-item-val">
					{{fans.count || 0}}
				</view>
				<view class="base-item-name">
					我的粉丝
				</view>
			</view>
			<view class="jg"></view>
			<view class="base-item">
				<view class="base-item-val">
					{{fans.active || 0}}
				</view>
				<view class="base-item-name">
					活跃粉丝
				</view>
			</view>
			<view class="jg"></view>
			<view class="base-item">
				<view class="base-item-val">
					{{fans.money || 0}}
				</view>
				<view class="base-item-name">
					总成交额
				</view>
			</view>
		</view>
		<view class="fans-tit">
			我的粉丝列表
		</view>
		<view class="fans-list-tit flex">
			<view class="list-item">
				ID
			</view>
			<!-- <view class="list-item">
				粉丝
			</view> -->
			<view class="list-item">
				当日业绩
			</view>
			<view class="list-item">
				粉丝数
			</view>
		</view>
		<scroll-view scroll-y="true" class="swiper-box" :style="{'height':height}" @scrolltolower="getMyfans()">
			<view class="fans-list-val flex" v-for="(item,index) in list" :style="{'background':index%2 ==0 ? '#F9F9F9':'#fff'}">
				<view class="list-item clamp">
					{{item.nickname}}
				</view>
				<!-- <view class="list-item">
					粉丝
				</view> -->
				<view class="list-item">
					{{item.money}}
				</view>
				<view class="list-item">
					{{item.count}}
				</view>
			</view>
			<uni-load-more :status="loadingType"></uni-load-more>
		</scroll-view>
	</view>
</template>

<script>
	import { getMyfans } from '@/api/user.js'
	export default {
		data() {
			return {
				height: '',
				list: [],
				page: 1,
				limit: 10,
				fans: {},
				loadingType: 'more'
			}
		},
		onLoad() {
			this.getMyfans()
		},
		onReady(res) {
			var _this = this;
			uni.getSystemInfo({
				success: resu => {
					const query = uni.createSelectorQuery();
					query.select('.swiper-box').boundingClientRect();
					query.exec(function(res) {
						console.log(res, 'ddddddddddddd');
						_this.height = resu.windowHeight - res[0].top + 'px';
						console.log('打印页面的剩余高度', _this.height);
					});
				},
				fail: res => {}
			});
		},
		methods: {
			getMyfans() {
				let obj = this
				if(obj.loadingType == 'loading' || obj.loadingType == 'noMore') {
					return
				}
				
				getMyfans({
					page: obj.page,
					limit: obj.limit
				}).then(res => {
					console.log(res)
					obj.fans = res.data
					obj.list = obj.list.concat(res.data.user)
					obj.page++
					if(res.data.user.length == obj.limit) {
						obj.loadingType = 'more'
					}else {
						obj.loadingType = 'noMore'
					}
				})
			}
		}
		
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #f3f5f4;
		height: 100%;
	}
	.content {
		background-color: #f3f5f4;
	}
	.top-fan {
		width: 750rpx;
		height: 336rpx;
		background: linear-gradient(-41deg, rgba(60, 237, 237, 0.99), #04B8FF, #375AFE);
		border-radius: 0 0 40rpx 40rpx;
	}
	.fans-base {
		width: 702rpx;
		height: 210rpx;
		background: #FFFFFF;
		box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
		border-radius: 20rpx;
		margin: -147rpx auto 0;
		text-align: center;
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #666666;
		.jg {
			width: 2rpx;
			height: 96rpx;
			background: #DCDCDC;
		}
		.base-item {
			flex-grow: 1;
			.base-item-val {
				font-size: 50rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #0C1732;
			}
		}
	}
	.fans-tit {
		font-size: 32rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #0C1732;
		padding: 45rpx 0 29rpx 40rpx;
	}
	.fans-list-tit {
		width: 710rpx;
		height: 100rpx;
		background: #E2EEFF;
		border-radius: 20rpx 20rpx 0px 0px;
		margin: auto;
		text-align: center;;
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #375AFE;
		.list-item {
			width: 33%;
			flex-shrink: 0;
		}
	}
	.fans-list-val {
		width: 710rpx;
		height: 100rpx;
		margin: auto;
		text-align: center;;
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #0C1732;
		.list-item {
			// flex-grow: 1;
			width: 33%;
			flex-shrink: 0;
		}
	}
</style>
