import {Device} from '../../base/Device';
import NetWork from '../../base/NetWork';
/**
 * @author yeyuchao
 * @description who is Elab.
 */
const website = "https://dm.static.elab-plus.com/";
const screenWidth = window.screen.width;
const screenHeight = window.screen.height;
export default {
  data() {
    return {
      website:website+'ElabHomeProject/',
      screenWidth:screenWidth,
      articleParam:"",
      marginTop:"",
      height:"",
      width:"",
      articleList:[]
    };
  },
  mounted() {
  },
  created() {
    if(window.loadedResource.length===0){
      this.$router.push('/');
      return
    }

    this.articleParam = window.articleParam;
    const device = new Device();
    if(device.phone){
      this.marginTop = 'calc('+50+'vh - '+40+'px - '+68/2+'px)';
      this.height = 'calc('+100+'vh - '+64+'px'+' - '+30+'px)';
    }else if(device.tablet){
      this.marginTop = 'calc('+50+'vh - '+40+'px - '+68/2+'px)';
      this.height = 'calc('+100+'vh - '+64+'px'+' - '+50+'px)';
    }else{
      this.marginTop = 'calc('+screenWidth*0.92*634/1413/2+'px - '+82/2+'px)';
      this.height = 'calc('+100+'vh - '+64+'px'+' - '+50+'px)';
      // this.height = 'calc('+screenWidth*0.92*634/1413+'px)';
    }
    this.getData(this.articleParam.id);
  },
  methods:{
    getData(id){
      const that = this;
      NetWork.fetchGet('listCategory2?parent='+id).then((date)=>{
        // that.pageListData = date.data.result.list;
        that.articleList = date.data.result.list;
        console.log("article list："+JSON.stringify(date.data.result.list));
      }).catch((err)=>{
      })
    },
    navigateToArticleDetail(idx){
      console.log("navigateToArticleDetail:"+idx);
      if(idx == 0){
        // this.$router.push('/skyDetail');
        window.location.href="http://h5test.elab-plus.com/test/ElabGuanWang/WebView/webView/projects-1-1.html";
      }
    },
    closeArticle(){
      console.log("closeArticle");
      this.$router.push('/article');
    }
  }
};
