var t, e = require("../../@babel/runtime/helpers/defineProperty");

Component({
    properties: {
        banner: Array
    },
    lifetimes: {
        attached: function() {
            this.attachedIn();
        }
    },
    attached: function() {
        this.attachedIn();
    },
    data: (t = {
        autoplay: !0
    }, e(t, "autoplay", !0), e(t, "interval", 3e3), e(t, "duration", 500), e(t, "circular", !0), 
    e(t, "swiperHeight", 100), e(t, "swiperWidth", 300), e(t, "imgUrl", []), t),
    observers: {
        banner: function(t) {
            0 == t.length && this.setData({
                swiperHeight: 0
            });
        }
    },
    methods: {
        attachedIn: function() {
            var t = this, e = this.createSelectorQuery();
            e.select(".swiper").boundingClientRect(), e.exec(function(e) {
                t.setData({
                    swiperWidth: e[0].width
                });
            });
        },
        previewImg: function(t) {
            var e = t.currentTarget.dataset.url;
            if (e) return wx.navigateTo({
                url: "/" + e
            }), !1;
            if (0 == this.data.imgUrl.length) {
                var i = [];
                this.properties.banner.map(function(t) {
                    i.push(t.image);
                }), this.setData({
                    imgUrl: i
                });
            }
            wx.previewImage({
                current: this.data.imgUrl[this.data.current],
                urls: this.data.imgUrl
            });
        },
        load: function(t) {
            this.setData({
                swiperHeight: this.data.swiperWidth * t.detail.height / t.detail.width
            });
        }
    }
});