<template>
    <div class="app-container">
      <van-nav-bar
        left-arrow
        fixed
        placeholder
        @click-left="$router.back(-1)"
      >
        <template #title>
          <p style="font-weight: bold;">证书查看</p>
        </template>
      </van-nav-bar>
      <van-list
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="getList"
      >
        <van-swipe-cell  v-for="(item,index) in applicationList" :key="index">
          <van-cell :title="item.zrfdbmc+'-'+item.lzfs" value="查看证书" center :to="{name:'certificateSee', query: {id:item.id}}">
            <template #icon>
              <van-icon name="../../../static/images/onlineHome/icon_zjd7.png" size="30" color="#7790FE" style="margin-right: 10px;" />
            </template>
            <template #label>
              <p>{{item.zrfdbzjhm}}</p>
            </template>
          </van-cell>
        </van-swipe-cell>
      </van-list>
    </div>
</template>

<script>
import { getList } from "@/api/onlineHome/homestead/circulation";
export default {
    name: "certificateList",
  data() {
    return {
      applicationList:[],
      houseApplyStatus:[],
      auditStatus:[],
      loading: false,
      finished: false,
      queryParams:{
        pageNum:1,
        pageSize:10,
        orderByColumn:'createTime',
        isAsc:'desc',
        printLicense: "Y"
      }
    };
  },
  created() {
    this.houseGetDicts("lzfs").then((response) => {
      this.houseApplyStatus = response.data;
    });
  },
  methods: {
    getList(){
      setTimeout(() => {
        getList(this.queryParams).then(response => {
          console.log(response)
          for (var i = 0; i < response.rows.length; i++) {
            var houseApplyStatus = this.selectDictLabel(this.houseApplyStatus, response.rows[i].lzfs);
            response.rows[i].lzfs = houseApplyStatus;
            var auditStatus = this.selectDictLabel(this.auditStatus, response.rows[i].auditStatus);
            response.rows[i].auditStatus = auditStatus;
            this.applicationList.push(response.rows[i]);
          }
          console.log(this.applicationList.length >= response.total)
          if(this.applicationList.length >= response.total){
            this.finished = true;
            return;
          }else{
            this.loading = false;
            this.queryParams.pageNum += 1 ;
          }
        });
      }, 1000);
    },
  },
}
</script>

<style scoped>
  .app-container {
    padding: 0.2rem 3%;
  }
  /deep/.van-cell__title{
    flex: 0.7;
  }
  /deep/.van-cell__title span{
    font-family: Arial;
    font-size: 0.4rem;
    font-weight: normal;
  }
  /deep/.van-cell__value{
    flex: 0.3;
    color: #1D6FE9;
    font-weight: bold;
  }
  /deep/.van-swipe-cell{
    margin-bottom: 0.2rem;
    border-radius: 0.2rem;
    overflow: hidden;
    box-shadow: 0px 3px 6px 0px rgba(0,0,0,0.16);
  }
  /deep/van-ellipsis{
    font-weight: bold;
  }
  .delete-button {
    height: 100%;
  }
</style>
