<template>
	<view class="vipBuyCommission" :style="{'height':contentHeight}">
		<view style="width: 100%;height: 100%;">
			<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;
						padding: 10px 0;
				  ">
					<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">
									<Text style='font-size: 13px;'>订单号：{{item.OrderNo}}</Text>
									<Text style='font-size: 11px;color: #999999;'>{{item.CreateDate}}</Text>
								</view>
								<view class="box_center" >
									<view class="center_l" >
										
										<u-avatar :src="item.Photo" mode="square" size="70"></u-avatar>
										<view class="box_ltext">
											<Text class='l_name'>{{item.UserName}}</Text>
										</view>
										<text style="margin-left: 15px;">{{item.GradeDescription}}</text>
									</view>
									
									<view class="center_l">
										<Text> 已返佣：<Text :style="{color:mainColor}">{{item.Commission}}</Text>元 </Text>
									</view>
								</view>
								<view style="margin: 5px 0;width: 100%;">
									<text style="line-height: 20px;font-size: 12px;color: #888888;">
										备注:{{item.Remark}}
									</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: "VIP购买返佣",
				contentHeight:0,
				mainColor:'',
				secondary:'',
				g:[],
				msg:{
					pageIndex: 1,
					pageSize:10,
					Type:1,
				},
				page_count:1,
				status: "loadmore",
				loadText: {
				  loadmore: "轻轻上拉，加载更多",
				  loading: "努力加载中",
				  nomore: "没有更多了",
				},
			}
		},
	
		created(){
			 this.contentHeight = this.$utils.calcContentHeight(-40)+'px';
			 this.mainColor = this.$uiConfig.mainColor;
			 this.secondary = this.$uiConfig.secondary;
			 this.init()
		},
		mounted() {
			let currentPages = getCurrentPages();
			 let u = "/" + currentPages[currentPages.length-1].route;
			 let pages = wx.getStorageSync("basedata")
			   ? wx.getStorageSync("basedata").bar_title
			   : [];
			 pages.forEach((x) => {
			   if (x.value == u) {
			     this.pageTitle = x.new_name ? x.new_name : x.name;
			   }
			 });
			 uni.setNavigationBarTitle({
			   title: this.pageTitle,
			 });
		},
		methods: {
			init(){
				
				uni.showLoading({
					title: '加载中'
				});
				this.request2(
				  {
				  	url: '/api/AppletUser/GetUserVipCommissionOrdersPageList',
				  	data: this.msg
				  },
							
				  (res) => {
					uni.hideLoading();
					let list = res.data.pageData;
					this.g = this.g.concat(list);
					this.page_count = res.data.pageCount;
					if (this.page_count == 1) {
					  this.status = "nomore";
					}
				  }
			);
			},
			change(index){
				this.msg.DistrbutionOrderSelectStatus = index;
				this.msg.pageIndex=1;
				this.g=[]
				this.init()
			},
			isdetail(index){
				this.g[index].showdetail = !this.g[index].showdetail
			},	
			lower(e) {
			  if (this.msg.pageIndex < this.page_count) {
				this.msg.pageIndex++;
				this.status = "loading";
				this.init();
			  } else {
				this.status = "nomore";
			  }
			},
		}
	}
</script>

<style>
.vipBuyCommission{
	background: #f3f4f6;
	
}

	.vipBuyCommission .listbox{
		width: 100%;
		background: #fff;
		padding: 0 15px;
		margin-bottom: 15px;
		display: flex;
		flex-direction: column;
		align-items: center;
		
	}
	.vipBuyCommission .listbox .box_top{
		width: 100%;
		height: 45px;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		border-bottom: 1px solid #f5f5f5;
	}
	.vipBuyCommission .listbox .box_center{
		width: 100%;
		height: 45px;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		font-size: 13px;
	}
	.vipBuyCommission .center_l{
		display: flex;flex-direction: row;align-items: center;
	}
	.vipBuyCommission .listbox .box_ltext{
		width: 90px;
		margin-left: 5px;
	}
	.vipBuyCommission .listbox .l_name{
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
	}
	.vipBuyCommission .listbox .box_bottom{
		width: 100%;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		padding: 15px 0 0;
		border-top: 1px solid #f5f5f5;
		font-size: 13px;
	}
	.box_bottom .b_r{
		width: calc(100vw - 30px - 50px - 20px);
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		
	}
</style>
