0000
This commit is contained in:
59
template/headSwiper/headSwiper.js
Normal file
59
template/headSwiper/headSwiper.js
Normal file
@@ -0,0 +1,59 @@
|
||||
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
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
4
template/headSwiper/headSwiper.json
Normal file
4
template/headSwiper/headSwiper.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
7
template/headSwiper/headSwiper.wxml
Normal file
7
template/headSwiper/headSwiper.wxml
Normal file
@@ -0,0 +1,7 @@
|
||||
<view>
|
||||
<swiper autoplay="{{autoplay}}" circular="{{circular}}" class="swiper" duration="{{duration}}" indicatorActiveColor="#4cadf1" indicatorColor="#eee" indicatorDots="true" interval="{{interval}}" style="height:{{swiperHeight}}px">
|
||||
<swiper-item wx:for="{{banner}}" wx:key="{{ index }}">
|
||||
<image bindload="load" bindtap="previewImg" class="slide-image" data-index="{{index}}" data-url="{{item.url}}" mode="widthFix" src="{{item.image}}"></image>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
</view>
|
||||
11
template/headSwiper/headSwiper.wxss
Normal file
11
template/headSwiper/headSwiper.wxss
Normal file
@@ -0,0 +1,11 @@
|
||||
.slide-image {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.swiper {
|
||||
margin:0 0 0;
|
||||
}
|
||||
|
||||
image {
|
||||
height: 20px;
|
||||
}
|
||||
Reference in New Issue
Block a user