微信小程序swiper实现图片带描述标题翻页预览

效果:

html:

  <view class='specialImglist'>
      <block wx:for="{{ projectObject.SalesHouse_AtlasAtlasList }}" wx:key="id">

        <view class='imagesList'  bindtap="onToPageSpecial" data-index='{{index}}'>
          <image class='imageBox'  bindtap="onToPageBanner"  src="{{ item.coverImage.accessUrl }}" style="height:218rpx;width:218rpx;">
          </image>
          <view class='imagebumberText'>
            {{item.imageCount}}张
          </view>
          <view class='imagesListatlasName'>{{item.atlasName}} </view>
        </view>
      </block>
    </view>
<view class='tip-content-dialog' wx:if="{{imgListIsShow}}">
  <text class='tip-content-dialog-title'>{{ imagesListObject.atlasName}}</text>
  <text class='dialogClose block tc font24 white' bind:tap='closerule' tap="onClick">×</text> 
  <text class='imagenumber-index'>{{current+1}}/{{ imagesListObject.imageCount}}</text>
  <view class="tip-dialog-view tc bg_rule p_all15 p_b20" scroll-y='true' style='height:85%;'>
     <swiper class='swiper-box image_iameg_div' bindchange="swiperChange"    skip-hidden-item-layout="{{ true }}">
        <block wx:for="{{ imagesListObject.imageList}}" wx:key="id">
          <swiper-item>
            <image bindtap="onToPage"  class="image-image" src="{{ item.imageObj.accessUrl }}" ></image>
            <view  class='imageListText'>{{ item.remark}}</view>
          </swiper-item>
        </block>
      </swiper>
  </view>
</view>

bindtap="onToPageSpecial"  事件进入图片预览。

js:代码

  data: {
    projectObject: {},
    bannerIsShowS:true,
    content:'',
    id:0,
    indicatorDots: true,
    autoplay: true,
    interval: 5000,
    duration: 1300,
    isShow:false,
    imgListIsShow:false,
    imagesListObject:null,
    current: 0
    }
 onToPageSpecial(e){
    var index = e.currentTarget.dataset.index;
    var that = this;
    that.setData({
      imgListIsShow: true,
      imagesListObject: this.data.projectObject.SalesHouse_AtlasAtlasList[index]
    })
 
  }
  closerule(){
    var that = this;
    that.setData({
      imgListIsShow:false
    })
  }


 onToPage:function(){
    var that = this;
    that.setData({
      imgListIsShow: false
    })
  }
    swiperChange: function (e) {
    var that = this;
    if (e.detail.source == 'touch') {
      that.setData({
        current: e.detail.current
      })
    }
  }

css:

 

.tip-content-dialog {
  position: fixed;
  display: flex;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #000;
  z-index: 99999;
  /* margin-top: 80rpx; */
}

.tip-content-dialog .tip-dialog-view {
  width: 100%;
  margin: auto;
  border-radius: 25rpx;
  vertical-align: middle;
  animation: tanchu 400ms ease-in;
  /* overflow: hidden; *//* padding: 20rpx; */
  margin-top: 180rpx;
}

.tip-content-dialog .btn {
  background: #f2f7fa;
}

.tip-content-dialog-title {
  position: absolute;
  text-align: center;
  width: 100%;
  margin-top: 65rpx;
  font-size: 32rpx;
  color: rgba(255, 255, 255, 0.80);
}
.imagenumber-index {
  position: absolute;
  right: 20rpx;
  top: 94rpx;
  width: 80rpx;
  height: 80rpx;
  line-height: 80rpx;
  text-align: center;
  font-size: 32rpx;
  margin-top: 10rpx;
  color: rgba(255, 255, 255, 0.80);
}

.image_iameg_div {
  margin-top: 30%;
  width: 100%;
  height: 100%;
}

.image-image {
  height: 444rpx;
  width: 100%;
}

.imageListText {
  text-align: center;
  width: 100%;
  font-size: 32rpx;
  color: rgba(255, 255, 255, 0.80);
  margin-top: 400rpx;
}
wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值