<template>
    <div>
      <van-tabs :active="active" @change="onChange">
        <van-tab title="共享资源" :name="0">
          <shareResources ref="shareResources"/>
        </van-tab>
        <van-tab title="预约历史" :name="1">
          <appointmentHistory ref="appointmentHistory"/>
        </van-tab>
      </van-tabs>
    </div>
</template>

<script>
import shareResources from "./components/shareResources.vue";
import appointmentHistory from "./components/appointmentHistory.vue";
export default {
  components:{
    shareResources,
    appointmentHistory
  },
  name: "index",
  data(){
    return{
      active:0
    }
  },
  onPullDownRefresh() {
    this.getList()
  },
  onShow(){

  },
  methods:{
    getList(){
      if(this.active === 0){
        this.$refs.shareResources.getList()
        setTimeout(function () {
          uni.stopPullDownRefresh();
        }, 1000);
      }
      if(this.active === 1){
        this.$refs.appointmentHistory.getList()
        setTimeout(function () {
          uni.stopPullDownRefresh();
        }, 1000);
      }
    },
    onChange(e){
      this.active = e.detail.name
    },
    otherFun(object) {
      if (object) {
        this.getList()
      }
    },
  }
}
</script>

<style scoped>

</style>
