import NetWork from '../../base/NetWork';
import {Device} from '../../base/Device';
import { WOW } from 'wowjs';
import {UAnimateContainer, UAnimate} from 'vue-wow';
const screenWidth = window.screen.width;
const screenHeight = window.screen.height;
/**
 * @author yeyuchao
 * @description article center.
 */
export default {
  data() {
    return {
      pageListData:'',
      screenWidth:screenWidth,
      screenHeight:screenHeight,
      devicePc:true,
      deviceMobile:false,
      deviceTablet:false,
      marginTop:"",
      height:"",
      width:""
    };
  },
  components: {
    UAnimateContainer,
    UAnimate
  },
  mounted() {
  },
  created() {
    if(!window.loadComplete){
      this.$router.push('/');
      return
    }
    window.itemType = 4;
    this.getPageList();
    const device = new Device();
    if(device.phone){
      this.marginTop = 'calc('+screenWidth*0.92*340/345/2+'px - '+38/2+'px)';
      this.height = 'calc('+screenWidth*0.92*340/345+'px)';
      this.width = screenWidth*0.92+'px';
    }else if(device.tablet){
      this.marginTop = 'calc('+screenWidth*0.92*543/1320/2+'px - '+58/2+'px)';
      this.height = 'calc('+screenWidth*0.92*543/1320+'px)';
      this.width = screenWidth*0.92+'px';
    }else{
      this.marginTop = 'calc('+screenWidth*0.92*343/1320/2+'px - '+62/2+'px)';
      this.height = 'calc('+screenWidth*0.92*343/1320+'px)';
      this.width = screenWidth*0.92+'px';
    }
  },
  methods:{
    getTarget() {
      return this.$el;
    },
    getPageList(){
      const that = this;
      NetWork.fetchGet('listCategory1').then((date)=>{
        that.pageListData = date.data.result.list;
        console.log("article list："+JSON.stringify(that.pageListData));
      }).catch((err)=>{
      })
    },
    navigateToArticle(idx){
      console.log("navigateToArticle:"+idx);
      if(idx !== 0){
       return;
      }
      window.articleParam = this.pageListData[idx];
      this.$router.push('/articleCenter');
    }
  }
};
