var Nova = getApp().Nova
Component({
    /**
     * 组件的属性列表
     */
    properties: {
        options: null
    },
    ready: function() {
        // 在组件布局完成后执行,确保options参数中有data信息
        this.loadData()
    },
    /**
     * 组件的初始数据
     */
    data: {},

    /**
     * 组件的方法列表
     */
    methods: {
        async loadData() {
            let { options } = this.data
            console.log('多图组', this.data)
            let {
                data,

                style
            } = options
            console.log(style, className)
            let { className, src, filter, list } = data
            this.setData({
                list,
                src,
                style,
                className,
                filter
            })
        },
        goNovaURL: function(ev) {
            let item = ev.currentTarget.dataset.item
            let url = ''
            if (item.className == 'ShopGoods' && item.objectId) {
                url =
                    '/nova-shop/pages/shop-goods/goods-detail/index?id=' + item.objectId
            }
            if (item.className == 'Article' && item.objectId) {
                url = '/common-page/pages/cates/article-detail/index?id=' + item.objectId
            }
            if (item.className == 'Lesson' && item.objectId) {
                url = ''
            }
            if (item.url) {
                url = item.url
            }
            Nova.goNovaURL(url)
        }
    },
    attached: function() {
        // let { options } = this.data
        // console.log('多图组', options)
        // var that = this
        // var allData = that.data.noramalData
        // //定义两个临时的变量来记录左右两栏的高度,避免频繁调用setData方法
        // var leftH = that.data.leftHight
        // var rightH = that.data.rightHight
        // var leftData = []
        // var rightData = []
        // for (let i = 0; i < allData.length; i++) {
        //   var currentItemHeight = parseInt(
        //     Math.round((allData[i].CoverHeight * 345) / allData[i].CoverWidth)
        //   )
        //   allData[i].CoverHeight = currentItemHeight + 'rpx' //因为xml文件中直接引用的该值作为高度,所以添加对应单位
        //   if (leftH == rightH || leftH < rightH) {
        //     //判断左右两侧当前的累计高度,来确定item应该放置在左边还是右边
        //     leftData.push(allData[i])
        //     leftH += currentItemHeight
        //   } else {
        //     rightData.push(allData[i])
        //     rightH += currentItemHeight
        //   }
        // }
        // //更新左右两栏的数据以及累计高度
        // that.setData({
        //   leftHight: leftH,
        //   rightHight: rightH,
        //   leftList: leftData,
        //   rightList: rightData
        // })
    }
})