<style>
.receiptList {
  width: 100%;
  height: 100%;
  background: #F3F5F7;
  font-family: aa;

}
.receiptList .details{
	width: 100%;
	padding: 0 10px;
}
.receiptList .item{
	width: 100%;
	margin-top: 15px;
	border-radius: 9px;
	background: #FFFFFF;
	box-shadow:0 4px 10px 1px #D2D2D2;
	
}
.receiptList .item_t{
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: space-between;
	height: 45px;
	padding: 0 15px;
	background: #F7F9FB;
	border-radius:  9px 9px 0px 0px;
}
.receiptList .item_t_text{
	font-size: 12px;
	
	
}
.receiptList .item_c{
	padding: 0 15px;
}
.item_c_box{
	border-bottom: 1px solid #DFDDD8;
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	padding: 15px 0 ;
	
}
.receiptList .item_c_l{
	font-size: 14px;
	color: #111111;
	width: 130rpx;
}
.receiptList .item_c_r{
	font-size: 14px;
	color: #111111;
	flex:1;
	width:1px;
	font-weight: 500;
	text-align: right;
}

</style>
<template>
  <view class="receiptList" :style="{ height: contentHeight }">
    <u-empty v-if="g.length == 0" text="暂无财务收据" mode="coupon"></u-empty>
    <view
      v-if="g.length > 0"
      style="
        height: calc(100vh);
        width: calc(100vw);
        overflow: hidden;
      "
    >
      <scroll-view
        :scroll-y="true"
        :enable-back-to-top="true"
        :enable-flex="true"
        @scrolltolower="lower"
        :style="{ height: '100%' }"
      >
        <view class="details" >
		  <view class="item" v-for="(x, i) in g" :key="i" @click="godetails(x)">
		    <view class="item_t">
				<span style="color: #111111;font-weight: 800;">{{x.ReceiptNo}}</span>
				<span class='item_t_text' v-if="x.State==1" :style="{'color':mainColor}">已认领</span>
				<span class='item_t_text' v-if="x.State==2" style="color: #40766E;">未认领</span>
			</view>
			<view class="item_c">
				<view class="item_c_box">
					<view class="item_c_l">交款人</view>
					<view class="item_c_r">{{x.Remitter}}</view>
				</view>
				<view class="item_c_box">
					<view class="item_c_l">金额</view>
					<view class="item_c_r">{{x.Money}}</view>
				</view>
				<view class="item_c_box">
					<view class="item_c_l">收款事由</view>
					<view class="item_c_r" style="overflow: hidden;display: inline-block;white-space: nowrap; text-overflow:ellipsis;width: 100%;">{{x.Remark}}</view>
				</view>
				<view class="item_c_box">
					<view class="item_c_l">开票人</view>
					<view class="item_c_r">{{x.CreateByName}}</view>
				</view>
				<view class="item_c_box" style="border-bottom: none;">
					<view class="item_c_l">开票时间</view>
					<view class="item_c_r">{{x.CreateTime}}</view>
				</view>
			</view>
		  </view>
        </view>
     
		<u-loadmore
		  :status="status"
		  :load-text="loadText"
		  :font-size="24"
		  :margin-top="20"
		  :margin-bottom="20"
		  bg-color="#F3F5F7"
		/>
      </scroll-view>
    </view>
	
    <!-- 加载中 -->
    <view class="loading" v-if="loading">
      <u-loading mode="flower" size="48">></u-loading>
      <Text style="color: #fff; margin-top: 10rpx;">加载中...</Text>
    </view>
    <!-- 取消提示 -->
    <u-toast ref="uToast" />
   <auth v-if="showAuth" @changeuserinfo="reloadUserinfo" @gbAuth= 'gbAuth'></auth>
  </view>
</template>

<script>
import auth from "@/components/auth/index.vue";
export default {
  components: {
    auth
  },
  data() {
    return {
      pageTitle: "收据列表",
      showAuth:false,
	  u:{},
     
      mainColor: "",
      contentHeight: 0,
	  msg:{
		  pageIndex: 1,
		  pageSize:10,
	  },
      page_count: 1,
      g: [],
      loading: false,
	  status: "loadmore",
	  loadText: {
	    loadmore: "轻轻上拉，加载更多",
	    loading: "努力加载中",
	    nomore: "没有更多了",
	  },
    };
  },
  created() {
    this.contentHeight = this.$utils.calcContentHeight(-40) + "px";
    this.mainColor = this.$uiConfig.mainColor;
  },
  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,
    });
  },
  onLoad: function (option) {    
    this.u = uni.getStorageSync("mall_UserInfo");
    if (!this.u) {
      this.u = {
    	nickName: "未登录",
    	avatarUrl: ""
      };
      this.showAuth = true;
    }	else{
    	this.init();
    }
  },
  methods: {
    
    init() {
	  this.request2(
	  	{
	  		url: '/api/AppletEducation/GetMyEduReceiptInfoPageList',
	  		data: this.msg
	  	},
	  	res => {
	  		if(res.resultCode==1){
	  				this.loading = false;
	  				this.g = this.g.concat(res.data.pageData);
					 this.page_count = res.data.pageCount;
					 if (this.page_count == 1) {
					   this.status = "nomore";
				}
	  		}
	  	}
	  );
    },

    lower(e) {
      if (this.msg.pageIndex < this.page_count) {
        this.msg.pageIndex++;
		this.status = "loading";
        this.init();
      } else {
        
		this.status = "nomore";
      }
    },
	godetails(x){//跳转详情
		uni.navigateTo({
			url: "/pages/school/personal/receiptDetails?FinanceId="+x.FinanceId,
			
		});
	},
	reloadUserinfo() {
	  this.u = uni.getStorageSync("mall_UserInfo");
	  this.init();
	},
	//关闭登录窗口
	gbAuth(){
		uni.navigateBack()
	},	
  },
};
</script>

