<template>
	<view class="myBillStyle" :style="{'height':contentHeight}">
		<view style="width: 100%;height: 100%;">
			<u-tabs :list="list" :is-scroll="false" :current="SelectBillState" @change="change" :active-color='mainColor' bg-color='#FFFFFF'></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;
						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;background: #FFFFFF;">
							<view v-for="(item, index) in g" :key="index" class="listbox" @click="goDetails(item)">
							
								<view class="box_b" >
									<view class="box_b_t">
										<text>{{item.Periods}}</text>
										<text :style="{color:item.BillState==1?'#FF4048':'#111111','font-size':'16px'}">{{item.BillState==2?'+':''}}{{item.Money}}元</text>
									</view>
									<view class="box_b_b">
										<text>{{item.SupplierName}}</text>
										<text v-if="item.BillState == 1">待打款</text>
										<text v-if="item.BillState == 2">已打款</text>
										<text v-if="item.BillState == 3">驳回</text>
									</view>
								</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:'',
				g:[],
				
				list:[
					{name: '全部'},
					{name: '待打款'},
					{name: '已打款'},
				
				],
				msg:{
					pageIndex: 1,
					pageSize:10,
					SelectBillState:-1
				},
				SelectBillState:0,
				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;
			 uni.setNavigationBarTitle({
			   title: this.pageTitle,
			 });
			 this.init()
		},
		mounted() {
			
		},
		methods: {
			init(){
				
				uni.showLoading({
					title: '加载中'
				});
				this.request2(
				  {
				  	url: '/api/AppletUser/GetSupplierDistributorBill',
				  	data: this.msg
				  },
							
				  (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){
				
				if(index==0){
					this.msg.SelectBillState = -1;
				}else if(index ==1){
					this.msg.SelectBillState = 1;
				}else if(index ==2){
					this.msg.SelectBillState = 2;
				}
				this.SelectBillState = index;
				this.msg.pageIndex=1;
				this.g=[]
				this.init()
			},
			lower(e) {
			  if (this.msg.pageIndex < this.page_count) {
				this.msg.pageIndex++;
				this.status = "loading";
				this.init();
			  } else {
				this.status = "nomore";
			  }
			},
			goDetails(item){
				uni.navigateTo({
				  url: '/pages/mySupplier/billDetails?ID='+item.Id
				});
			}
		}
	}
</script>

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

	.myBillStyle .listbox{
		width: 94%;
		border-radius: 10rpx;
		background: #fff;
		
	}
	.myBillStyle .listbox .box_b{
		width: 100%;
		padding: 10px;
		/* border-top: 1px solid #f5f5f5; */
		display: flex;
		flex-direction: column;
		align-items: center;
		border-bottom: 1px solid #E2E2E2;
		
	}
	.myBillStyle .listbox .box_b_t{
		width: 100%;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		font-size: 14px;
		color: #000000;
	}
	.myBillStyle .listbox .box_b_b{
		width: 100%;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		font-size: 10px;
		color: #999999;
		margin-top: 10px;
	}
	
	.myBillStyle .text_s{
		font-size: 14px;
		color: #999999;
		margin-top: 3px;
	}
</style>
