<template>
  <div>
    <van-nav-bar
      @click-left="onClickLeft"
      @click-right="onClickRight"
      style="background-color: #1989fa"
    >
      <template #title>
        <van-col style="color: #ffffff">逾期待缴款客户</van-col>
      </template>
      <template #left>
        <i
          class="fa fa-arrow-circle-left"
          aria-hidden="true"
          style="color: #ffffff; font-size: 18px"
        ></i>
      </template>
      <template #right>
        <van-icon name="replay" size="18" color="#ffffff" />
      </template>
    </van-nav-bar>

    <van-pull-refresh v-model="isLoading" @refresh="onRefresh">
      <van-list
        v-model="loading"
        :finished="finished"
        loading-text="加载中..."
        finished-text="我是有底线的~"
        @load="onLoad"
      >
        <van-cell
          v-for="item in listdata"
          :key="item.clientId"
          :value="item.num"
          border
        >
          <template #default>
            <van-row>
              <van-cell :title="item.name" is-link arrow-direction border :to="'/clientdetail?id='+item.clientId+'&name='+item.name"  />
            </van-row>
            <van-row class="borderTop">
              <van-col span="20">
                <van-row>
                  <van-col span="5" class="title1">认购单号</van-col>
                  <van-col span="19">{{ item.billCode }}</van-col>
                </van-row>
                <van-row>
                  <van-col span="5" class="title1">房源名称</van-col>
                  <van-col span="19">{{ item.roomName }}</van-col>
                </van-row>
                <van-row>
                  <van-col span="5" class="title1">计划日期</van-col>
                  <van-col span="19">{{ item.planDate }}</van-col>
                </van-row>
              </van-col>
              <van-col span="4">
                <van-row>
                  <van-col span="24">{{ item.overDays }}</van-col>
                  <van-col span="24" class="title1">逾期/天</van-col>
                </van-row>
              </van-col>
            </van-row>
          </template>
        </van-cell>
      </van-list>
    </van-pull-refresh>
  </div>
</template>

<script>
import { GetRemindArrearage } from "@/common/api/loginApi.js";
export default {
  name: "login",
  data() {
    return {
      listdata: [], 
      loading: false,
      finished: false,
      isLoading: false,
      page:"1"
    };
  },
  created: function () {
    console.info("created");
    //console.info(this.$util);
    this.$util.persistLogin(this);
  },
  methods: {
    GetRemindArrearage: function () {
      var that = this;
      var data = {
        userCode: that.$store.state.data.userCode,
        projectId: that.$store.state.projectId,
        page: that.page,
        pageCount: "5",
        dateRange0: "",
        dateRange1: "",
      };
      console.info("data", data);
      GetRemindArrearage(data).then((res) => {
        console.info("GetRemindArrearage", res);
        if (!res.result) {
          that.$toast(res.msg);
          return;
        }
        if(res.data!=null&&res.data.listdata.length>0){
          that.loading=false;
          res.data.listdata.forEach(function (item, index, array) {
            that.listdata.push(item);
            //console.info('length:'+res.data.listdata.length,'index:'+index);
            if(res.data.listdata.length-1==index){
              that.page++;
              if(res.data.page.totalPages==that.page-1){
                that.finished=true;
              }
            }
          });
          if(res.data==null||res.data.listdata==null||res.data.listdata.length==0){
            that.finished = true;
          }
          
        }
         else{
          that.finished=true;
        }
      });
    },
    // 列表加载
    onLoad () {
      setTimeout(() => {
        this.GetRemindArrearage()
        this.loading = true
      }, 500)
    },
    onRefresh () {
      setTimeout(() => {
        // 重新初始化这些属性
        this.isLoading = false
        this.listdata = []
        this.page = 1
        this.loading = false
        this.finished = false
        //this.noData = false
        // 请求信息
        this.GetRemindArrearage()
      }, 500)
    },
    onClickLeft() {
      // this.$toast('返回')
      console.info("left");
      this.$router.go(-1);
    },
    onClickRight() {
      this.$router.go(0);
    },
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.title1 {
  color: #999;
}
.value1 {
  color: #999;
  font-size: 18px;
}
.borderTop {
  border-top: #efefef solid 1px;
}
</style>
