const app = getApp()
Component({
  properties: {
    // 这里定义了innerText属性,属性值可以在组件使用时指定
    innerText: {
      type: String
      // value: '',
    },
    list: {
      type: Array
    },
    datas: {
      type: Object
    }
  },
  data: {
    // 这里是一些组件内部数据
    message: "Hello World",
    indicatorDots: false,
    vertical: false,
    autoplay: true,
    interval: 2000,
    duration: 500,
    activeIndex: 0,
    bannerHeight: 0,
    firstLoad: false,
    newArr: [],
  },
  ready() {
    console.log('----------------------30')
    this.setData({'newArr':this.newList()})
    console.log(this.data.newArr,this.newList(),'--------32')
  },
  methods: {
    newList(){
      return this.data.datas.componentData.imgList.filter(item=>item.visible==undefined || item.visible==1) || []
    },
    customMethod() {
      console.log("hello world! I am learning 微信小程序");
    },
    bannerChange(val) {
      this.setData({ activeIndex: val.detail.current });
    },
    onClick(data) {
      let item = data.currentTarget.dataset.item;
      console.log(data.currentTarget.dataset.item, "iiii");
      app.trackCpn(data, this.data.datas.componentName, item)
      app.$themeToLink(item.link);
    },
    loadImg(e) {
      let { firstLoad } = this.data;
      if (firstLoad == true) {
        return;
      }
      firstLoad = true;
      let winWid = wx.getSystemInfoSync().windowWidth - this.data.datas.componentData.paddingList[2].value - this.data.datas.componentData.paddingList[3].value; //获取当前屏幕的宽度
      let imgh = e.detail.height; //图片高度
      let imgw = e.detail.width;
      let swiperH = winWid * imgh / imgw + "px";
      this.setData({ bannerHeight: swiperH, firstLoad }); //设置高度
    }
  }
});