<template>
    <div id="category">
      <!--头部-->
      <!-- <Header/> -->
      <div class="header-title">
        <span class="header-title-return" @click="returnClick"><van-icon name="arrow-left" /></span>
        <span class="header-title-name-bold" style="margin-right: 0px !important;">高管信息</span>
      </div>
  
      <div v-if="total !== ''" class="manage-body" v-for="(item, index) in managerList" :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.name }}</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 style="padding-bottom: 10px;">
        <van-cell style="width: 100%;float: left;">
          <template #title>
              <span class="custom-title cl-gray fs-15">任职职务</span>
          </template>
          <template #label>
              <span class="custom-title cl-black fs-15">{{ item.job }}</span>
          </template>
        </van-cell>
        <van-cell style="width: 50%;">
<!--          <template #title>-->
<!--              <span class="custom-title cl-gray fs-15">持股比例</span>-->
<!--          </template>-->
<!--          <template #label>-->
<!--              <span class="custom-title cl-black fs-15">{{ item.job }}</span>-->
<!--          </template>-->
        </van-cell>
        </div>
      </div>
      <van-empty v-else description="无数据" />
    </div>

  </template>

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

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


  export default {
    name: "ExecutiveInfo",
    data() {
      return {
        show: false,
        text: '',
        managerList: [],
        total: '',
        currentPage: 1,
        loading: false,
        isEndLoading: false,
      }
    },
    components: {
      VanButton: Button,
      VanRow: Row,
      VanCol: Col,
      VanIcon: Icon,
      VanField: Field,
      VanTag: Tag,
      VanEmpty: Empty,
    },
    created() {
      this.postManagerInfo();
    },
    mounted() {
      window.addEventListener('scroll', this.scrollBottom);
    },
    destroyed() {
      window.removeEventListener('scroll', this.scrollBottom)
    },
    methods: {
      // 获取高管信息
      async postManagerInfo(){
        let result = await postQueryManagerInfo({companyId: sessionStorage.getItem('companyId'), pageNum: this.currentPage, pageSize: 10});
        // this.managerList = result.records;
        this.total = result.total;
        if (this.loading) {
          this.managerList = this.managerList.concat(result.records);
        } else {
          this.managerList = result.records;
        }
        if (this.managerList.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.postManagerInfo();
        }
      },

    },
  }
  </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