<template>
  <div class="home">
    <nav-bar />
    <div class="bj"></div>
    <div class="box">
      <van-list
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="loadMore"
      >
        <ul>
          <li v-for="item in list" :key="item.id">
            <router-link :to="'Jkzd_detail?id=' + item.id">
              <h2>{{ item.title }}</h2>
              <h3><img :src="item.img" /></h3>
            </router-link>
          </li>
        </ul>
        <!-- <van-cell v-for="item in list" :key="item" :title="item" /> -->
      </van-list>
    </div>
  </div>
</template>

<script>
import { apiGetHospitalJylist } from "@/request/api.js"; 
import { Toast } from "vant";
export default {
  components: {},
  mounted() {
    console.log(this.$route.meta.title);
    this.title = this.$route.meta.title;
  },
  data() {
    return {
      title: "",
      flag: false,
      loading: false,
      finished: false,
      paramsData: {
        page: 1,
        pagesize: 10,
      },
      list: [],
    };
  },
  mounted() {
    this.getData();
  },
  methods: {
    // 获取列表
    getData() {
      apiGetHospitalJylist(this.paramsData).then((res) => {
        this.loading = false;
        if (res.data.length < this.paramsData.pagesize) {
          this.finished = true;
          console.log(this.finished);
        }
        this.list = [...this.list, ...res.data];
        console.log(this.list);
      });
    },
    loadMore() {
      if (!this.finished) {
        this.paramsData.page += 1;
        this.getData();
      }
    },
  },
};
</script>


<style scoped lang="scss">
.bj {
  background: #f5f5f5;
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0px;
  left: 0px;
  z-index: -1;
}
.box {
  ul li {
    padding: 30px;
    background: #fff;
    border-bottom: 1px solid #f5f5f5;
    a {
      display: flex;
      align-items: center;
      justify-content: space-between;

      h2 {
        font-size: 32px;
      }
      h3 img {
        width: 80px;
        height: 80px;
        border-radius: 10px;
      }
    }
  }
}
</style>
