<template>
    <div id="category">
      <!--头部-->
      <div class="header-title">
        <span class="header-title-return-back" @click="returnClick"><van-icon name="arrow-left" /></span>
        <span class="header-title-name-bold">股东信息</span>
      </div>
  
      <div class="manage-body" v-for="(item, index) in partnerList" :key="index">
        <div class="hg-3-rem">
            <div class="ft-left wt-15-per hg-100-per">
                <div class="mg-lt-5 hg-25-rem wt-2-rem firm-icon-body">
                    <van-icon class="firm-icon" color="#fff" size="1.5rem" name="contact" />
                </div>
            </div>
            <div class="ft-right wt-84-per hg-14-rem">
                <span class="ft-left fs-16 fw-bold">{{ item.stockName }}</span>
<!--                <van-tag class="ft-right fs-14" color="#E9F1FD" text-color="#2372EB">关联企业：2</van-tag>-->
            </div>
<!--            <div class="ft-right wt-84-per hg-13-rem">-->
<!--                <van-tag class="mg-rt-5" color="#FDF3E7" text-color="#EE8C15">大股东</van-tag>-->
<!--            </div>-->
        </div>
        <div>
        <van-cell style="width: 50%;float: left;">
          <template #title>
              <span class="custom-title cl-gray fs-14">股东类型</span>
          </template>
          <template #label>
              <span class="custom-title cl-black fs-14">{{ item.stockType }}</span>
          </template>
        </van-cell>
        <van-cell style="width: 50%;">
          <template #title>
              <span class="custom-title cl-gray fs-14">持股比例</span>
          </template>
          <template #label>
              <span class="custom-title cl-black fs-14">{{ item.stockPercent }}</span>
          </template>
        </van-cell>
        </div>
        <div style="padding-bottom: 20px;">
        <van-cell style="width: 50%;float: left;">
          <template #title>
              <span class="custom-title cl-gray fs-14">认缴出资额</span>
          </template>
          <template #label>
              <span class="custom-title cl-black fs-14">{{ item.shouldCapi }}</span>
          </template>
        </van-cell>
        <van-cell style="width: 50%;">
          <template #title>
              <span class="custom-title cl-gray fs-14">认缴出资日期</span>
          </template>
          <template #label>
              <span class="custom-title cl-black fs-14">{{ item.shoudDate }}</span>
          </template>
        </van-cell>
        </div>
      </div>
    </div>

  </template>

  <script>
  import { Button, Col, Row, Icon, Field, Tag } from 'vant';

  // 3. 引入接口
  import {postQueryPartnerInfo} from "@/service/api/customerDashboard";


  export default {
    name: "ShareholderInfo",
    data() {
      return {
        partnerList: [],
        currentPage: 1,
        loading: false,
        isEndLoading: false,
      }
    },
    components: {
      VanButton: Button,
      VanRow: Row,
      VanCol: Col,
      VanIcon: Icon,
      VanField: Field,
      VanTag: Tag,
    },
    created() {
      this.postPartnerInfo();
    },
    mounted() {
      window.addEventListener('scroll', this.scrollBottom);
    },
    destroyed() {
      window.removeEventListener('scroll', this.scrollBottom)
    },
    methods: {
      // 获取股东信息
      async postPartnerInfo(){
        let result = await postQueryPartnerInfo({companyId: sessionStorage.getItem('companyId'), pageNum: this.currentPage, pageSize: 10});
        // this.partnerList = result.records;
        if (this.loading) {
          this.partnerList = this.partnerList.concat(result.records);
        } else {
          this.partnerList = result.records;
        }
        if (this.partnerList.length < result.total) {
          this.isEndLoading = false;
        } else {
          this.isEndLoading = true;
        }
        this.loading = false;
      },
      returnClick() {
        this.$router.go(-1)
      },

      scrollBottom() {
        let scrollTop = document.documentElement.scrollTop || document.body.scrollTop  //页面滚动的高度
        let clientHeight = document.documentElement.clientHeight  //可视区域高度
        let scrollHeight = document.documentElement.scrollHeight  //可滚动内容的高度
        let bottomOfWindow = scrollTop + clientHeight + 1000 >= scrollHeight    //是否滚动到底部
        //loading 和 this.tableData.length和this.total是自己的判断条件
        if (scrollTop !== 0 && bottomOfWindow && !this.loading) {
          this.loading = true;
          this.currentPage += 1;
          this.postPartnerInfo();
        }
      },

    },
  }
  </script>
  
  <style lang="less" scoped>
  
  .header-title {
    height: 46px;
    width: 100%;
    background-color: #fff;
    text-align: center;
  }
  .header-title-name {
    font-weight: bold;
    line-height: 46px;
    align-items: center;
    justify-content: center;
    display: inline-flex;
  }
  .header-title-return {
    position: absolute;
    top: 13px;
    left: 20px;
    font-size: 15px;
  }
  .manage-body {
    margin-top: 10px;
    background-color: #fff;
    padding: 20px 10px 0px 10px;
  }
  .firm-icon-body {
    background-color: #2372EB;
    border-radius: 5px;
}
.firm-icon {
    line-height: 2.5rem;
    margin-left: 0.5rem;
}
  </style>../../service/api/index