<template>
  <sail-page type="loading-view" title="房源" isHead>
    <div slot="content" class="project_box">
    	<div class="spacing"></div>
      <emptyPageCard :isEmptyType="homeProjectListInfo.length===0?'regionlist':'normal'"/>
     <!--  <van-list
        v-model="loading"
        :finished="finished"
        @load="onLoad"
        :offset="10"
      > -->         
        <router-link class="link" v-for="(project, index) in homeProjectListInfo" :key="index" :to="`/projectDetails/${project.id}`">
          <HotProjectCard class="HotProjectCard" :data="project" :isPriceLeft="project.publishStatus !== 2" isHouse/>
        </router-link>
     
     <!--  </van-list> -->
    	  	             
    </div>
  </sail-page>
</template>

<script>

import sailPage from "@/components/sail-page.vue";
import HotProjectCard from "@/common/widget/hotProjectCard.vue";
import { mapState } from "vuex";
import emptyPageCard from "@/common/widget/emptyPageCard.vue";
import { List } from "vant"; //继续加载后面数据
export default {
  components: {
    sailPage,
    HotProjectCard,
    emptyPageCard
  },
  computed: {
    ...mapState({
      homeAddList:state => state.findMoreRegionsModule.homeAddList, //获取热门项目
      homeProjectListInfo:state => state.findMoreRegionsModule.homeProjectListInfo

    })
  },
  data: function(){
    return {
      list: [],
      loading: false,
      finished: false,
      currentPage: 1
    }; 
  },
  asyncData({store, route}) { // 异步调取页面接口数据 asyncData
    return store.dispatch("findMoreRegionsModule/findMoreRegions",{
      pn:1,
      pageSize:10000,
      cache: true
    }).then(res=> {
      //this.loading = false
      //
      // store.commit('findMoreRegionsModule/SET_HOME_PROJECT_LIST_ADD_INFO', res.data.data.list)
    });

  },
  methods: {
    onLoad() {
      //this.currentPage++;
      // 
      this.$store.dispatch("findMoreRegionsModule/findMoreRegions",{
        pn:this.currentPage,
        pageSixe:10
      }).then(res=> {
        this.loading = false;
        if(res.data.data.list.length === 0) {
          this.finished = true;
        }
        this.$store.commit("findMoreRegionsModule/SET_HOME_PROJECT_LIST_ADD_INFO", res.data.data.list);
        //
      });       
    }
         
  }
};
</script>
<style lang="less">
  .project_box {
    .van-list {
      height: 87vh;
      overflow: scroll;
    }
  }
</style>
<style lang="less" scoped>
    @import "~@/common/less/variable.less";
    .project_box {
    	width: 375px;
    	min-height: 100vh;
    	background: @nice-bgwhite;
    	.spacing {
    		width: 375px;
    		height: 13px;
    		background: @nice-bgwhite;
    	}
    	.HotProjectCard {
    		width: 347.91px;
    		margin: 0 0 14px 24px;
    	}

    } 

</style>