小程序图片点击放大,滑动支持左右滑动功能和导航滑动效果

 <!-- 轮播图 -->
  <view class="banner" wx:if="{{product.ipo_items.length>0}}">
    <swiper autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" circular="{{circular}}" bindchange="bindchange">
      <block  wx:for="{{product.ipo_items}}" wx:key="{{index}}">
        <swiper-item>
          <image bindtap='previewImg' src="{{item.ipo_photo}}" data-index="{{index}}" class="slide-image" width="355" height="150" />
        </swiper-item>
      </block>
    </swiper>
    <view class="xNumber">
      <text>{{currNumber}}/{{product.ipo_items.length}}</text>
    </view>
  </view>
 //点击图片放大
  previewImg: function (e) {
    console.log(e.currentTarget.dataset.index);
    var index = e.currentTarget.dataset.index;
    console.log(index)
    var goodsDetail = this.data.product.ipo_items;
    console.log(goodsDetail)
    var arr=[];
    for (var i=0;i< goodsDetail.length;i++ ){
      arr.push(goodsDetail[i]['ipo_photo'])
    }
    console.log(arr)
    wx.previewImage({
      current: arr[index],     //当前图片地址
      urls: arr,               //所有要预览的图片的地址集合 数组形式
    })
  },
<view class='main-wraper'>
    <navBar background='#FF584E' back="{{true}}" home="{{true}}" bindback="handlerGobackClick" bindhome="handlerGohomeClick" extClass="lxy-navbar-extclass" iconTheme='white'>
      <view class="centerTit" slot="center">
      <text bindtap="chooseBtn" wx:for="{{tabitem}}" wx:key="index" bindtap="setTab" data-index="{{index}}" class="{{currId==index?'titWei':'titOne'}}">{{item.text}}</text>
      <view class="tab-line" style="transform:translateX({{280*showtab}}%);"></view>
    </view>
    </navBar>
</view>
 tabitem: [{
        "id": 0,
        "text": "商品"
      },
      {
        "id": 1,
        "text": "评价"
      }
    ]

 // 导航滑动效果
  setTab: function(e) {
    const index = e.currentTarget.dataset.index;
    if (index) {
      this.setData({
        showtab: index,
        currId: index,
        containerBox: false,
        pinglunBox: true,
      })
    } else if (!index) {
      this.setData({
        showtab: index,
        currId: index,
        containerBox: true,
        pinglunBox: false,
      })
    }
  },
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值