huangxw 5 giorni fa
parent
commit
2151fa739b

+ 15 - 13
src/components/ut-album/ut-album.vue

@@ -1,7 +1,7 @@
 <template>
     <view class="ut-album-card" :style="albumStyle">
         <template v-for="(item, index) in displayItems" :key="index">
-            <view class="card-item" :style="{ width: itemSize, height: itemSize }" @click="onPreview(index)">
+            <view class="card-item" :style="{ width: itemSize, height: itemSize }" @click="onItemClick(item, index)">
                 <!-- 图片缩略图 -->
                 <template v-if="item.type === 'image'">
                     <image class="thumb" :src="getThumb(item)" mode="aspectFill" />
@@ -11,8 +11,17 @@
                 <template v-else-if="item.type === 'video'">
                     <view class="video-box">
                         <image v-if="item.coverUrl" class="thumb" :src="item.coverUrl" mode="aspectFill" />
-                        <view v-else class="video-placeholder">VIDEO</view>
-                        <view class="play-mask">
+                        <video
+                            v-else
+                            class="thumb native-video"
+                            :src="item.url"
+                            object-fit="cover"
+                            :controls="false"
+                            :show-center-play-btn="true"
+                            :show-play-btn="false"
+                            :enable-play-gesture="true"
+                        />
+                        <view v-if="item.coverUrl" class="play-mask">
                             <up-icon name="play-circle" color="#fff" size="48rpx"></up-icon>
                         </view>
                     </view>
@@ -141,9 +150,9 @@ const formatSize = (bytes) => {
 };
 
 // 预览逻辑:图片/视频/文件
-const onPreview = (displayIndex) => {
-    const item = displayItems.value[displayIndex];
+const onItemClick = (item, displayIndex) => {
     if (!item) return;
+    if (item.type === 'video' && !item.coverUrl) return;
     if (item.type === 'image') return previewImages(item);
     if (item.type === 'video') return previewVideo(item, displayIndex);
     return previewFile(item);
@@ -222,15 +231,8 @@ const previewFile = (item) => {
             width: 100%;
             height: 100%;
             position: relative;
-            .video-placeholder {
-                width: 100%;
-                height: 100%;
-                color: #fff;
+            .native-video {
                 background: #000;
-                display: flex;
-                align-items: center;
-                justify-content: center;
-                font-size: 28rpx;
             }
             .play-mask {
                 position: absolute;

+ 8 - 0
src/pages.json

@@ -694,6 +694,14 @@
                     "style": {
                         "navigationBarTitleText": "选择追溯码码段"
                     }
+                },
+                // 打开预览view-web-view
+                {
+                    "path": "webview/index",
+                    "style": {
+                        "navigationBarTitleText": "预览webview页面",
+                        "navigationStyle": "custom"
+                    }
                 }
             ]
         },

+ 1 - 1
src/plant/models/batch-info.vue

@@ -53,7 +53,7 @@
             <span class="c-#666">是否符合GAP要求:</span>
             <span class="c-#333">{{ +info?.gapFlag ? '是' : '否' }}</span>
         </view>
-        <view class="d-flex flex-cln j-c a-c pd-30">
+        <view @click="$u.route({ url: '/tools/webview/index', params: { title: '溯源信息', url: info?.packBatchUrl } })" class="d-flex flex-cln j-c a-c pd-30">
             <image class="w-140 h-140" src="https://yujin-szyy.oss-cn-chengdu.aliyuncs.com/szyy/images-plt/print-codes/code_logo_export.png" mode="widthFix" />
             <view class="f-s-26 c-#333">点击查看溯源信息</view>
         </view>

+ 0 - 2
src/tools/view-html/index.vue

@@ -26,8 +26,6 @@ onLoad((options) => {
         url: obj.url,
         success: (res: any) => {
             // 只要body内容
-            console.log(res);
-            
             content.value = res.data as string;
         },
     });

+ 17 - 0
src/tools/webview/index.vue

@@ -0,0 +1,17 @@
+<template>
+    <web-view :src="url"></web-view>
+</template>
+<script setup lang="ts">
+import { recursiveDecodeURIComponentSimple } from '@/utils/ruoyi';
+const content = ref<string>('');
+const title = ref('');
+const paging = ref();
+const url = ref('');
+onLoad((options) => {
+    // 设置标题
+    const obj = recursiveDecodeURIComponentSimple(options);
+    uni.setNavigationBarTitle({ title: obj?.title || '-' });
+    title.value = obj.title || '-';
+    url.value = obj.url || '';
+});
+</script>