<template>
<div class="parent">
  <template v-if="guider">
    <div class="boxs" @click="close">
      <home class="all top" :outside="true" v-if="guider" @close="close"></home>
      <div class="all-mask" v-if="guider" @click="close"></div>
      <home class="all" :outside="false"></home>
    </div>
  </template>
  <template v-else>
    <pull-to class="pull" :top-load-method="refresh" :top-config="topConfig">
      <home class="all" :outside="false" ref="home"></home>
    </pull-to>
    <div class="loading">刷新加载</div>
  </template>
</div>
</template>
<script>

import home from './page/home';
import { getUrlParameter, isWeChatApplet, formatUrl, getEllipsisText } from "@js/tooler";
import PullTo from 'vue-pull-to'
// import PullToRefresh from '../components/pull-to-refresh'
function checkGuider(){
  var param = getUrlParameter("param");
  try{
    var list = param.split("_");
    return list[1] == 1;
  }
  catch(e){

  }
  return false;
}

export default {
  data() {
    return {
      // guider: getUrlParameter("step") == 1 && !localStorage.getItem("guider")
      guider: checkGuider(),
      topConfig: {
        triggerDistance: 90 * window.innerWidth / 750
      }
    }
  },
  components: {
    home, PullTo
  },  
  methods: {
    close(){
      console.log("close");
      this.guider = false;
    },
    refresh(loaded){
      setTimeout(()=>{
        loaded("done");
      }, 300);
      console.log("refresh");
      this.$refs.home.refresh();
    }
  },
  created() {
    console.log("guider: " + this.guider);
  }
}
</script>

<style lang="less" scoped>
.parent{
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: #999;
}
.boxs{
  position: relative;
}
.all{
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  z-index: 1;
}
.pull{
  position: relative;
  z-index: 1;
  background: rgb(167, 51, 51);
}
.loading{
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 90px;
  line-height: 90px;
  text-align: center;
  color: #fff;
  font-size: 24px;
}
.top{
  top: 0;
  opacity: 1;
  z-index: 3;
}
.all-mask{
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 2;
}
</style>