<template>
  <div>
    <title-bar :title="title" @clickLef="onClick">
      <van-icon slot="left" name="cross" size="24" />
    </title-bar>
    <div v-if="nodata" class="h-scroller flex-1-dhc customer-management-information-content">
      <scroller-view v-calculate-height :pulldown="pulldown" :pullup="pullup" :refresh-data="selectCustInfo" :load-data="onloaddata">
        <div v-for="(item, index) in itemData" :key="index" class="customer-data-list" @click="onClientInfo(item)">
          <div class="data-title">{{ item.title }}</div>
          <div class="cusData">
            <div>发布日期：{{ item.sortTimeString }}</div>
            <div>来源网站：{{ item.siteName }}</div>
          </div>
        </div>
      </scroller-view>
    </div>
  </div>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import TitleBar from "@/components/general/TitleBar.vue";
import Public from "@/public/ts/Public";
import nettyApi from "@/constants/api/ms-netty/netty.api";
import { NativeUI } from "@/public/ts/NativeUI";
import IF from "@/public/factory/InterFaceFactory";
/**
 * @Description 法院公告
 * @Author JiangTao
 * @Date 2022-02-10 上午 11:58
 */
@Component({
  name: "FYGGList",
  components: { TitleBar },
})
export default class FYGGList extends Vue {
  title = "法院公告"; // 页面标题

  itemData = [];
  pageNo = 1;
  pullup = true;
  pulldown = true;
  nodata = true;
  activated() {
    console.log(this.$store.getters.getCustInfo);
    this.selectCustInfo();
  }

  onClick() {
    console.log(111111);
  }
  onClientInfo(item: any) {
    this.$router.push({
      name: "FYGGDetail",
      params: item
    });
  }
  //上拉加载
  onloaddata() {
    this.pageNo = Math.ceil(this.itemData.length / 10) + 1;
    return this.selectCustInfo(this.pageNo);
  }
  selectCustInfo(pageNo = 1) {
    let param = {
      pname: this.$store.getters.getCusInfo.cus_name,
      pageno: pageNo,
      beginTime: '',
      endTime: '',
      ProdId: Public.getProdId(),
      SvrCode: Public.getSvrCode(nettyApi.TRADE_CODE.selectFYGG),
      ClientNo: this.$store.getters.getCusInfo.cus_id,
      tc: nettyApi.TRADE_CODE.selectFYGG
    };
    NativeUI.showWaiting('正在查询...');
    return IF.transferDataInter(nettyApi.commonRq, param).then((res: any) => {
      NativeUI.closeWaiting();
      if (res.rc == '1') {
        if (res.fyggList.length !== 0) {
          if (pageNo == 1) {
            this.itemData = res.fyggList;
          } else {
            this.itemData = this.itemData.concat(res.fyggList);
          }
        }
      } else {
        if (res.ret_code != '4999999') {
          NativeUI.toast(res.msg);
        }
      }
      if (res.cpwsList && res.cpwsList.length < 10) {
        this.pullup = false;
      }
      if (this.itemData.length == 0) {
        this.nodata = false;
        this.pulldown = false;
      }
    });
  }
}
</script>

<style scoped>
.cusData {
  display: flex;
  align-items: center;
}
.cusData > div:nth-child(1) {
  margin-right: 20px;
}
</style>
