123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- <template>
- <view class="swiperBg" :style="'padding-top:' + marginTop +'rpx;background: linear-gradient(180deg, '+ bgColor0 +' 50%, '+ bgColor1 +' 100%);'">
-
- <block v-if="swiperType == 0">
- <view class="item-img" v-for="(item,index) in imgUrls" :key="index" :style="{padding:'0 '+paddinglr+'rpx',marginBottom:itemEdge+'rpx'}">
- <image @click="goDetail(item)" :src="item.img"></image></view>
- </block>
- <block v-else>
- <view class="swiper page_swiper" :class="[docConfig == 1 ? 'square' : docConfig == 0 ? 'circular' : 'nodoc',imgConfig ? '' : 'fillet','dot'+txtStyle]"
- :style="'padding: 0 '+ paddinglr +'rpx;'"
- v-if="imgUrls.length">
- <swiper
- indicator-dots="true"
- :autoplay="true"
- :circular="circular"
- :interval="interval"
- :duration="duration"
- indicator-color="rgba(255,255,255,0.6)"
- indicator-active-color="#fff"
- :style="'height:'+(imageH+10)+'rpx;'"
- :current="swiperCur"
- @change="swiperChange"
- >
- <block v-for="(item,index) in imgUrls" :key="index">
- <swiper-item :class="{ active: index == swiperCur }">
- <view @click="goDetail(item)" class='slide-navigator acea-row row-between-wrapper'>
- <image :src="item.img" class="slide-image aa" :style="'height:'+ imageH +'rpx;'" mode="aspectFill"></image>
- </view>
- </swiper-item>
- </block>
- </swiper>
-
- </view>
- </block>
- </view>
- </template>
- <script>
-
-
-
-
-
-
-
-
-
-
- import {merPath} from "@/utils/index"
- export default {
- name: 'swiperBg',
- props: {
- dataConfig: {
- type: Object,
- default: () => {}
- },
- merId:{}
- },
- data() {
- return {
- indicatorDots: false,
- circular: true,
- autoplay: true,
- interval: 3000,
- duration: 500,
- imgUrls: [],
- bgColor0: this.dataConfig.isShow.val ? this.dataConfig.bgColor.color[0].item : 'transparent',
- bgColor1: this.dataConfig.isShow.val ? this.dataConfig.bgColor.color[1].item : 'transparent',
- marginTop: this.dataConfig.mbConfig.val*2,
- paddinglr: this.dataConfig.lrConfig.val*2,
- docConfig: this.dataConfig.docConfig.type,
- imgConfig: this.dataConfig.imgConfig.type,
- txtStyle: this.dataConfig.txtStyle.type,
- imageH: 310,
- swiperCur: 0,
- swiperType: 1,
- };
- },
- watch: {
- imageH(nVal, oVal) {
- let self = this
- this.imageH = nVal
- }
- },
- created() {
- this.imgUrls = this.dataConfig.swiperConfig.list
- },
- mounted() {
- let that = this;
- that.$nextTick(function() {
- uni.getImageInfo({
- src: that.setDomain(that.imgUrls[0].img),
- success: function(res) {
- if (res && res.height > 0) {
- let height = res.height * ((750-20) / res.width)
- that.$set(that, 'imageH', height);
- } else {
- that.$set(that, 'imageH', 375);
- }
- },
- fail: function(error) {
- that.$set(that, 'imageH', 375);
- }
- })
- })
- },
- methods: {
-
- setDomain: function(url) {
- url = url ? url.toString() : '';
-
- if (url.indexOf("https://") > -1) return url;
- else return url.replace('http://', 'https://');
- },
- swiperChange(e) {
- let { current, source } = e.detail;
- if (source === 'autoplay' || source === 'touch') {
- this.swiperCur = e.detail.current;
- }
- },
- goDetail(url){
- let urls = url.info[1].value
- urls = merPath(urls, this.merId)
- this.$util.JumpPath(urls);
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .swiperBg {
- position: relative;
- background: #fff;
- z-index: 1;
- .colorBg {
- position: absolute;
- left: 0;
- top: 0;
- height: 130rpx;
- width: 100%;
- }
- .page_swiper {
- position: relative;
- width: 100%;
- box-sizing: border-box;
- height: auto;
- margin: 0 auto;
- border-radius: 10rpx;
- overflow-x: hidden;
- /* #ifdef MP */
- z-index: 20;
- /* #endif */
- /* 设置圆角 */
- &.fillet {
- .swiper-item, image, .acea-row.row-between-wrapper{
- border-radius: 10rpx;
- }
- }
- .swiper-item, image, .acea-row.row-between-wrapper {
- width: 100%;
- height:100%;
- margin: 0 auto;
- }
- swiper{
- width: 100%;
- display: block;
- height: auto;
- }
- image {
- transform: scale(0.93);
- transition: all 0.6s ease;
- }
- swiper-item.active {
- image {
- transform: scale(1);
- }
- }
- }
- }
- .item-img image{
- display: block;
- width: 100%;
- }
- </style>
|