xiaohaizhao пре 1 месец
родитељ
комит
9cd4e42021
3 измењених фајлова са 43 додато и 7 уклоњено
  1. 3 2
      CRM/wmycontract/confirm.scss
  2. 39 4
      components/Yl_Files/index.js
  3. 1 1
      components/Yl_Files/index.wxml

+ 3 - 2
CRM/wmycontract/confirm.scss

@@ -91,13 +91,14 @@ page {
   z-index: 999;
   box-sizing: border-box;
   overflow: hidden;
+  width: 100vw;
 }
 
 .new-submit {
-  width: 100% !important;
+  width: 355px !important;
   height: 88rpx !important;
   line-height: 88rpx !important;
-  border-radius: 44rpx !important;
+  border-radius: 8rpx !important;
   font-size: 32rpx !important;
   background: linear-gradient(135deg, #3874F6, #5b9bff) !important;
   border: none !important;

+ 39 - 4
components/Yl_Files/index.js

@@ -35,10 +35,19 @@ Component({
                 index,
                 type
             } = e.currentTarget.dataset;
-            wx.previewMedia({
-                current: index,
-                sources: type == 'image' ? this.data.files.viewImages : this.data.files.viewVideos,
-            })
+            if (type == 'image') {
+                // 用 localPath(如有)替代原始 url,确保真机预览正常
+                const sources = this.data.files.viewImages.map(v => {
+                    const img = this.data.files.images.find(i => i.url === v.url);
+                    return { url: (img && img.localPath) || v.url, type: 'image' };
+                });
+                wx.previewMedia({ current: index, sources });
+            } else {
+                wx.previewMedia({
+                    current: index,
+                    sources: this.data.files.viewVideos,
+                });
+            }
         },
         /* 预览文档 */
         viewFlies(e) {
@@ -229,5 +238,31 @@ Component({
                 attachmentids: this.getFiles().attachmentids
             })
         },
+        /* 图片加载失败 - 通过原生通道下载到本地临时路径(绕过 iOS ATS 对 HTTP 的限制) */
+        onImageError(e) {
+            const { index } = e.currentTarget.dataset;
+            const item = this.data.files.images[index];
+            if (!item || item._retrying || item.localPath) return;
+            item._retrying = true;
+            wx.getImageInfo({
+                src: item.url,
+                success: (res) => {
+                    if (res.path) {
+                        this.setData({ [`files.images[${index}].localPath`]: res.path });
+                    }
+                },
+                fail: () => {
+                    // getImageInfo 也失败时,尝试 downloadFile
+                    wx.downloadFile({
+                        url: item.url,
+                        success: (res) => {
+                            if (res.statusCode === 200) {
+                                this.setData({ [`files.images[${index}].localPath`]: res.tempFilePath });
+                            }
+                        }
+                    });
+                }
+            });
+        },
     }
 })

+ 1 - 1
components/Yl_Files/index.wxml

@@ -1,7 +1,7 @@
 <view class="media" wx:if="{{attachmentids.length > 0}}">
     <!-- 图片 -->
     <navigator url="#" class="item" wx:for="{{files.images}}" wx:key="attachmentid">
-        <image src="{{item.url}}" data-index="{{index}}" data-type='image' mode="aspectFill" bindtap="viewMedias" />
+        <image src="{{item.localPath || item.cover || item.url}}" data-index="{{index}}" data-type='image' mode="aspectFill" bindtap="viewMedias" binderror="onImageError" />
         <image wx:if="{{delete}}" class="delete" src="/static/image/delete.png" data-item="{{item}}" bindtap="handleDeleteFile" />
     </navigator>
     <!-- 视频 -->