123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <template>
- <view>
- <view v-if="banners && banners.length > 0" class="swiper-wrapper">
- <swiper class="swiper" :style="{height: itemHeight}" circular :duration="400" autoplay :interval="3000"
- @change="change">
- <swiper-item class="swiper-item" :style="{height: itemHeight}" v-for="(item, index) in banners" :key="index"
- @click="showNext(item)">
- <image :src="item.cover" webp class="image" :style="{height: itemHeight}" mode="aspectFill" />
- </swiper-item>
- </swiper>
- <view class="dot-wrapper translateX flex-align-around">
- <view v-for="item in banners.length" :key="item" class="dot" :class="[active === item && 'active']"></view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- active: 0
- }
- },
- computed: {
- itemHeight() {
- let width = this.$store.state.systemInfo.screenWidth - uni.upx2px(56)
- return Math.floor((210 / 1053) * width) + 'px'
- },
- banners() {
- if (!this.$store.state.pageConfig || !this.$store.state.pageConfig['magic_luck']) {
- return null
- }
- let components = this.$store.state.pageConfig['magic_luck'].components
- if (!components || components.length === 0) return null
- let data = null
- for (let i = 0; i < components.length; i++) {
- if (components[i].type === 'capsule') {
- data = components[i].elements
- }
- }
- if(!!this.$store.state.hide) {
- data.forEach((item, index) => {
- if (item.path && item.path.params && item.path.params.url === 'hidden_activity') {
- data.splice(index, 1);
- }
- })
- }
- return data
- }
- },
- methods: {
- change(e) {
- this.active = e.detail.current
- },
- showNext(item) {
- this.$common.showNext(item)
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .swiper-wrapper {
- margin: 20rpx 28rpx 0;
- overflow: hidden;
- border-radius: 20rpx;
- position: relative;
- .swiper {
- width: 100%;
- border-radius: 20rpx;
- overflow: hidden;
- .swiper-item {
- width: 100%;
- border-radius: 20rpx;
- overflow: hidden;
- .image {
- width: 100%;
- border-radius: 20rpx;
- }
- }
- }
- .dot-wrapper {
- position: absolute;
- bottom: 8rpx;
- width: 60rpx;
- height: 8rpx;
- .dot {
- width: 8rpx;
- height: 8rpx;
- border-radius: 4rpx;
- background: rgba($color: #000000, $alpha: 0.4);
- &.active {
- background: #fff;
- }
- }
- }
- }
- </style>
|