Quellcode durchsuchen

始宁农业小程序:商品新增、编辑发售时间选择

panyong vor 2 Jahren
Ursprung
Commit
26df48125d

+ 10 - 0
htmldev/shiningWxMini/pages/goodsDetail/goodsDetail.js

@@ -164,5 +164,15 @@ Page({
     this.setData({
       active: value
     })
+  },
+  handlePreviewImage(e) {
+    const { imgs, index } = e.currentTarget.dataset
+
+    if (Array.isArray(imgs)) {
+      wx.previewImage({
+        urls: imgs,
+        current: imgs[index]
+      })
+    }
   }
 })

+ 9 - 3
htmldev/shiningWxMini/pages/goodsDetail/goodsDetail.wxml

@@ -7,8 +7,11 @@
     autoplay="{{false}}">
     <block
       wx:for="{{objProductDetail.product_rotation_img_list}}"
-      wx:key="*this">
-      <swiper-item>
+      wx:key="index">
+      <swiper-item
+        data-index="{{index}}"
+        data-imgs="{{objProductDetail.product_rotation_img_list}}"
+        bind:tap="handlePreviewImage">
         <view class="swiper-item">
           <image
             mode="widthFix"
@@ -99,7 +102,10 @@
     src="{{item}}"
     mode="widthFix"
     wx:for="{{objProductDetail.product_detail_img_list}}"
-    wx:key="index"></image>
+    wx:key="index"
+    data-index="{{index}}"
+    data-imgs="{{objProductDetail.product_detail_img_list}}"
+    bind:tap="handlePreviewImage"></image>
 </view>
 
 <view

+ 10 - 0
htmldev/shiningWxMini/pages/news/news.js

@@ -267,5 +267,15 @@ Page({
     wx.navigateTo({
       url: '/pages/addNews/addNews'
     })
+  },
+  handlePreviewImage(e) {
+    const { imgs, index } = e.currentTarget.dataset
+
+    if (Array.isArray(imgs)) {
+      wx.previewImage({
+        urls: imgs,
+        current: imgs[index]
+      })
+    }
   }
 })

+ 5 - 2
htmldev/shiningWxMini/pages/news/news.wxml

@@ -32,7 +32,7 @@
         </view>
         <view class="blogger-name-wrap">
           <view class="user-name">{{item.user_nickname}}</view>
-          <view class="business-name">商铺:{{item.shop_name}}</view>
+          <view class="business-name" wx:if="{{!!item.shop_name}}">商铺:{{item.shop_name}}</view>
         </view>
         <button
           class="follow"
@@ -50,7 +50,10 @@
             wx:for="{{item.track_img_url}}"
             wx:for-item="img"
             wx:for-index="idx"
-            wx:key="idx">
+            wx:key="idx"
+            data-index="{{idx}}"
+            data-imgs="{{item.track_img_url}}"
+            bind:tap="handlePreviewImage">
             <image src="{{img}}"></image>
           </view>
         </view>