<template>
	<view class="myClientsStyle" :style="{'height':contentHeight}">
		<view style="width: 100%;height: 100%;">
			<u-tabs :list="list" name="GradeName" :is-scroll="false" :current="current" @change="change" :active-color='mainColor' ></u-tabs>
			<u-empty v-if="g.length==0" text="暂无数据" mode="data"></u-empty>
			<template v-if="g.length > 0">
				<view  
				  style="
						height: calc(100vh - 50px);
						width: calc(100vw);
						overflow: hidden;
						
				  ">
					<scroll-view
						:scroll-y="true"
						:enable-back-to-top="true"
						:enable-flex="true"
						@scrolltolower="lower"
						:style="{ height: '100%' }">
						<view style="display: flex;flex-direction: column;align-items: center;">
							<view v-for="(item, index) in g" :key="index" class="listbox">
								<view class="box_top">
									
									<u-avatar :src="item.Photo"  size="64"></u-avatar>
									<view class="box_r">
										<view style="width: 100%;display: flex;flex-direction: row;align-items: center;justify-content: space-between;">
											<view style="width: 190px;">
												<Text class='l_name'>{{item.UserName}}</Text>
											</view>
											<Text style='font-size: 12px;'>推广{{item.GeneralizeNum}}人</Text>
										</view>
										<Text style='font-size: 10px;color: #999999;'>{{item.CreateDate}}</Text>
									</view>
								</view>
								<view class="box_b">
									<Text style='color: #878787;font-size: 13px;'> <text style='color: #FF3F47;'> {{item.Income}}</text> 元</Text>
									<Text style='color: #878787;font-size: 13px;'>{{item.OrderNum}}个订单</Text>
								</view>
								
							</view>
						</view>
						<u-loadmore
						  :status="status"
						  :load-text="loadText"
						  :font-size="24"
						  :margin-top="20"
						  :margin-bottom="20"
						  bg-color="#f3f4f6"
						/>
					</scroll-view>
					
				</view>
			</template>
		</view>
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageTitle: "我的团队",
				contentHeight:0,
				mainColor:'',
				secondary:'',
				current:0,
				g:[],
				list:[
					
				],
			
				msg2:{
					pageIndex: 1,
					pageSize:10,
					FXGradeId:0,
					
				},
				page_count:1,
				status: "loadmore",
				loadText: {
				  loadmore: "轻轻上拉，加载更多",
				  loading: "努力加载中",
				  nomore: "没有更多了",
				},
				IsEnableFXGrade:0,
			
			}
		},
	
		created(){
			 this.contentHeight = this.$utils.calcContentHeight(-40)+'px';
			 this.mainColor = this.$uiConfig.mainColor;
			 this.secondary = this.$uiConfig.secondary;
			 
		},
		onLoad(option){
			
				this.list=[{GradeName: '普通会员'},]//设置默认值
				this.getUserMyTeamTitelListForFX()
				
			
			
		},
		mounted() {
			
			 uni.setNavigationBarTitle({
			   title: this.pageTitle,
			 });
		},
		methods: {
			getUserMyTeamTitelListForFX(){
				uni.showLoading({
					title: '加载中'
				});
				this.request2(
					{
						url: '/api/AppletUser/GerSmallShopsMyTeamTitelListForFX',
						data: {}
					},
							
				  (res) => {
					uni.hideLoading();
					this.list=res.data;
					this.msg2.FXGradeId = this.list[0].Id;
					this.init2()
				  }
				);
			},
			init2(){
				
				uni.showLoading({
					title: '加载中'
				});
				this.request2(
					{
						url: '/api/AppletUser/GetUserMyTeamPageListForFX',
						data: this.msg2
					},
							
				  (res) => {
					 uni.hideLoading();
					 this.g = this.g.concat(res.data.pageData);
					 this.page_count = res.data.pageCount;
					 if (this.page_count == 1) {
					   this.status = "nomore";
					 }
					
				  }
				);
			},
	
			change(index){
				this.current = index
			
					this.msg2.FXGradeId = this.list[index].Id;
					this.msg2.pageIndex=1;
					this.g=[]
					this.init2()
				
				
			},
			lower(e) {
				
					if (this.msg2.pageIndex < this.page_count) {
						this.msg2.pageIndex++;
						this.status = "loading";
						this.init2();
					} else {
						this.status = "nomore";
					}
				
			 
			},
			
		}
	}
</script>

<style>
.myClientsStyle{
	background: #f3f4f6;
	
}
.myClientsStyle .loading{
		width: 200rpx;
		height: 200rpx;
		background: #000000;
		opacity: 0.7;
		border-radius: 10rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		position: fixed;
		left: 50%;
		top:30%;
		margin-left: -100rpx;
		z-index: 999;
	}
	.myClientsStyle .listbox{
		width: 100%;
		background: #fff;
		padding: 0 15px;
		margin-top: 15px;
		display: flex;
		flex-direction: column;
		align-items: center;
		
	}
	.myClientsStyle .box_top{
		width:100% ;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		padding: 10px 0 ;
		/* border-bottom: 1px solid #f5f5f5; */
		
	}
	.myClientsStyle .box_r{
		width: calc(100vw - 30px - 32px - 20px);
		height: 32px;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}
	.box_r .l_name{
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
	}
	.myClientsStyle .box_b{
		width: 100%;
		height: 40px;
		padding: 0 10px;
		background: #F7F5F5;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		border-radius: 4px;
		margin: 10px 0;
	}
</style>
