<template>
  <div class="home">
    <nav-bar/>
    <div class="search">
      <div class="searchBox" @click="search">
        <router-link to="search">搜索科室、医生</router-link>
      </div>
    </div>
    <div class="box3">
      <van-list
          v-model="loading"
          :finished="finished"
          finished-text="没有更多了"
          @load="loadMore"
      >
        <ul>
          <li v-for="item in list" :key="item.id">
            <router-link :to="'Hospital_zjjs_detail?id=' + item.id">
              <h2><img :src="item.img || require('@/assets/member_tx.png')" /></h2>
              <h3>
                {{ item.name }}<span>{{ item.label }}</span>
                <p>擅长：</p>
                <p v-html="item.grsc"></p>
              </h3>
            </router-link>
          </li>
        </ul>
      </van-list>
    </div>
  </div>
</template>

<script>
// @ is an alias to /src
import {apiGetKsDoctorList, apiGetksLsist, queryConcern} from "@/request/api.js";
import {Toast} from "vant";

export default {
  components: {},
  data() {
    return {
      active: 0,
      title: "",
      flag: false,
      checked: false,

      loading: false,
      finished: false,
      paramsData: {
        mid: null,
        name: "",
        page: 1,
        pagesize: 1000,
      },
      list: [],
      ksList: [],
    };
  },
  mounted() {
    this.getData();
    //this.getKslistData();
  },
  methods: {
    search() {
      this.$router.push({path: "/Search"});
    },
    // 获取列表
    getData() {
      apiGetKsDoctorList(this.paramsData).then((res) => {
        this.loading = false;
        if (res.data.length < this.paramsData.pagesize) {
          this.finished = true;
        }
        // this.list = [...this.list, ...res.data];
        console.log(res);
        this.list = res.data
      });
      queryConcern().then(r => {//查找已经关注
        console.log(r.data)
        sessionStorage.setItem("guanzhudoc", r.data);
      })
    },
    loadMore() {
      if (!this.finished) {
        this.paramsData.page += 1;
        this.getData();
      }
    },
    // 获取科室列表
    getKslistData() {
      apiGetksLsist({
        page: 1,
        pagesize: 1000,
      }).then((res) => {
        this.loading = false;
        // if (res.data.length < this.paramsData.pagesize) {
        //   this.finished = true;
        //   console.log(this.finished);
        // }
        this.ksList = res.data;
      });
    },
    showPopup() {
      this.show = true;
    },
    showMode() {
      this.showe = true;
    },
  },
};
</script>

<style scoped lang="scss">
::v-deep .van-dropdown-menu__bar {
  box-shadow: none;
}

.search {
  width: 100%;
  height: 1rem;
  background-color: #fff;
  position: fixed;
  z-index: 2;
}

.searchBox {
  width: calc(100% - 1rem);
  border-radius: 0.5rem;
  background: #f1f1f1;
  text-align: center;
  line-height: 1rem;
  font-size: 0.375rem;
  position: absolute;
  left: 0.5rem;
}

.box3 {
  position: absolute;
  top: 2.5rem;
  z-index: 1;
  width: 100%;
}

.box3 ul li {
  background: #fff;
  border-bottom: 1px solid #f5f5f5;
  padding: 0 0.5rem;

  a {
    display: flex;
    box-sizing: border-box;
    padding: 0.375rem 0;

    h2 img {
      width: 1.5rem;
      height: 1.5rem;
      border-radius: 50%;
      margin-right: 0.25rem;
    }

    h3 {
      color: #333;
      font-size: 0.375rem;
      position: relative;
      width: calc(100% - 2rem);

      span {
        font-size: 0.325rem;
        color: #666;
        padding-left: 0.25rem;
      }

      p {
        font-size: 0.325rem;
        color: #999;
        display: block;
        padding-top: 0.25rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }
  }
}
</style>
