<template>
	<view class="content">
		<view class="content-money">
			<view class="money-box">
				<view class="goback-box" @click="toBack"><image class="goback" src="../../static/img/fanhui.png" mode=""></image></view>
				<view class="header">我的推广</view>
				<image src="../../static/img/anchor9.png" mode="" class="money_bg"></image>
				<view class="money">
					<text>共</text>
					{{ all.all || 0 }}
					<text>人</text>
				</view>
			</view>
		</view>
		<view class="navbar flex">
			<view class="nav-item">
				<view class="num">0</view>
				<view class="font">个人消费</view>
			</view>
			<view class="xian"></view>
			<view class="nav-item">
				<view class="num">0</view>
				<view class="font">团体消费</view>
			</view>
		</view>
		<view class="swiper-box" :style="{ height: height }">
			<scroll-view scroll-y="true" class="list-scroll-content" @scrolltolower="loadData" :style="{ height: height }">

				<!-- 空白页 -->
				<!-- <empty v-if="list.length === 0"></empty> -->

				<!-- 订单列表 -->
				<view class="order-item flex" v-for="(item, index) in list" :key="index">
					<view class="title-box flex_item">
						<view class="title-avatar"><image :src="item.avatar || '/static/error/missing-face.png'"></image></view>
						<view class="list_tpl">
							<view class="title">
								<text>{{ item.mobile || item.email }}</text>
							</view>
							<view class="time">
								<text>{{ item.time }}</text>
							</view>
						</view>
					</view>
				</view>
				<uni-load-more :status="loadingType"></uni-load-more>
			</scroll-view>
		</view>
	</view>
</template>

<script>
import { spread_children,num } from '@/api/user.js';
import { mapState, mapMutations } from 'vuex';
import { getMoneyStyle, getTime } from '@/utils/rocessor.js';
import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
import empty from '@/components/empty';
export default {
	components: {
		empty,
		uniLoadMore
	},
	onReady(res) {
		var obj = this;
		uni.getSystemInfo({
			success: resu => {
				const query = uni.createSelectorQuery();
				query.select('.swiper-box').boundingClientRect();
				query.exec(function(res) {
					console.log(res, 'ddddddddddddd');
					obj.height = resu.windowHeight - res[0].top + 'px';
					console.log('打印页面的剩余高度', obj.height);
				});
			},
			fail: res => {}
		});
	},
	data() {
		return {
			// 头部图高度
			height: '',
			tabCurrentIndex: 0,
			all: '',
			list: [],
			loadingType: 'more',
			limit: 10,
			page: 1,
			id: ''
		};
	},
	onShow() {
		this.id = this.userInfo.id;
		num().then(({data}) =>{
			console.log(data)
			this.all = data
		})
		this.loadData();
	},
	computed: {
		...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
	},
	methods: {
		loadData() {
			const obj = this;
			if (obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
				return;
			}
			obj.loadingType == 'loading';
			spread_children({ limit: obj.limit, page: obj.page }, obj.id).then(({ data }) => {
				data.forEach(e => {
					e.time = getTime(e.createtime);
				});
				console.log(data,'123456');
				obj.list = obj.list.concat(data);
				// obj.list = data
				obj.page++;
				if (data.length == obj.limit) {
					obj.loadingType = 'more';
					return
				} else {
					obj.loadingType = 'noMore';
				}
			});
		},
		navto(e) {
			uni.navigateTo({
				url: e
			});
		},
		toBack() {
			uni.switchTab({
				url: '/pages/user/user'
			});
		}
	}
};
</script>

<style lang="scss">
page {
	background: #f1f1f1;
	height: 100%;
}
.content-money {
	height: 480rpx;
	padding-bottom: 30rpx;
	background: $page-color-base;
	position: relative;
	.moneyTx {
		position: absolute;
		top: 150rpx;
		right: 0rpx;
		width: 150rpx;
		padding: 10rpx 30rpx;
		border: 2px solid #ffffff;
		border-top-left-radius: 99rpx;
		border-bottom-left-radius: 99rpx;
		color: #ffffff;
		line-height: 1;
		font-size: $font-base;
	}
	.buttom-box {
		background-color: #ffffff;
		text-align: center;
		margin: 0 30rpx;
		padding: 20rpx 0;
		border-radius: $border-radius-sm;
		margin-top: -60rpx;
		.buttom {
			font-size: $font-lg;
			flex-grow: 1;
		}
		.interval {
			width: 2px;
			height: 60rpx;
			background-color: #eeeeee;
		}
		.icon {
			height: 50rpx;
			width: 48rpx;
			margin: 0 auto;
			.icon-img {
				width: 100%;
				height: 100%;
			}
		}
	}
}
.money-box {
	height: 470rpx;
	color: #FFFFFF;
	text-align: center;
	position: relative;
	.header {
		position: absolute;
		left: 0;
		top: 0;
		width: 100%;
		height: 80rpx;
		font-size: 32rpx;
		font-weight: 700;
		z-index: 99;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.goback-box {
		position: absolute;
		left: 18rpx;
		top: 0;
		height: 80rpx;
		display: flex;
		align-items: center;
	}
	.goback {
		z-index: 100;
		width: 34rpx;
		height: 34rpx;
	}
	.money_bg {
		width: 100%;
		height: 470rpx;
		display: block;
	}
	.text {
		padding-top: 80rpx;
		font-size: $font-sm;
	}
	.money {
		position: absolute;
		top: 0;
		width: 100%;
		padding-top: 186rpx;
		font-size: 60rpx;
		font-weight: bold;
		font-size: 82rpx;
		text {
			font-size: 36rpx;
		}
	}
}

.navbar {
	width: 702rpx;
	height: auto;
	padding: 20rpx 0;
	background: #FFFFFF;
	border-radius: 10rpx;
	position: relative;
	z-index: 10;
	margin: -60rpx auto;
	.xian {
		width: 2rpx;
		height: 54rpx;
		background: #eeeeee;
	}
	.nav-item {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		height: 100%;
		font-size: 15px;
		color: #fff;
		position: relative;
		width: 50%;
		.num {
			font-size: 32rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #333333;
		}
		.font {
			margin-top: 10rpx;
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #000;
		}
	}
}
//列表


.swiper-box {
	margin-top: 74rpx;
	background: #FFFFFF;
	.order-item {
		padding: 20rpx 30rpx;
		line-height: 1.5;

		.title-box {
			width: 100%;

			.title-avatar {
				width: 100rpx;
				height: 100rpx;
				margin-right: 25rpx;
				border-radius: 100%;
				image {
					width: 100%;
					height: 100%;
					border-radius: 100%;
				}
			}

			.list_tpl {
				width: 85%;

				.title {
					font-size: $font-lg;
					color: $font-color-base;
					overflow: hidden; //超出的文本隐藏
					text-overflow: ellipsis; //溢出用省略号显示
					white-space: nowrap;
				}

				.time {
					font-size: $font-base;
					color: $font-color-light;
				}
			}
		}

		.money {
			color: #db1935;
			font-size: $font-lg;
		}
	}
}
.content {
	height: 100%;
	.empty-content {
		background-color: #000;
	}
}
</style>
