huangxw преди 1 ден
родител
ревизия
293567f75b
променени са 3 файла, в които са добавени 58 реда и са изтрити 8 реда
  1. 5 6
      src/components/ut-album/ut-album.vue
  2. 4 1
      src/plant/base/base-edit/index.vue
  3. 49 1
      src/plant/code/code-query/index.vue

+ 5 - 6
src/components/ut-album/ut-album.vue

@@ -17,11 +17,11 @@
                             :src="item.url"
                             object-fit="cover"
                             :controls="false"
-                            :show-center-play-btn="true"
+                            :show-center-play-btn="false"
                             :show-play-btn="false"
-                            :enable-play-gesture="true"
+                            :enable-play-gesture="false"
                         />
-                        <view v-if="item.coverUrl" class="play-mask">
+                        <view class="play-mask">
                             <up-icon name="play-circle" color="#fff" size="48rpx"></up-icon>
                         </view>
                     </view>
@@ -152,7 +152,6 @@ const formatSize = (bytes) => {
 // 预览逻辑:图片/视频/文件
 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);
@@ -170,10 +169,10 @@ const previewImages = (clickedItem) => {
 const previewVideo = (item, index) => {
     // #ifdef MP-WEIXIN
     const allVideos = items.value.filter((i) => i.type === 'video');
-    const sources = allVideos.map((i) => ({ url: i.url, type: 'video', poster: i.coverUrl || '' }));
+    const sources = allVideos.map((i) => ({ url: i.url, type: 'video', poster: i?.coverUrl || '' }));
     const current = allVideos.findIndex((i) => i.url === item.url);
     // @ts-ignore
-    wx.previewMedia({ sources, current: current >= 0 ? current : 0 });
+    uni.previewMedia({ sources, current: current >= 0 ? current : 0 });
     // #endif
     // #ifndef MP-WEIXIN
     uni.showToast({ title: '当前平台暂不支持视频预览', icon: 'none' });

+ 4 - 1
src/plant/base/base-edit/index.vue

@@ -663,7 +663,6 @@ const mapDrawArea = async () => {
     });
 };
 const clickPlotSwipe = (e: any, item: any, idx: number | string, title = '编辑地块') => {
-    console.log(e, item);
     const index = e.index;
     if (index == 0) {
         // 编辑
@@ -674,6 +673,10 @@ const clickPlotSwipe = (e: any, item: any, idx: number | string, title = '编辑
     }
     if (index == 1) {
         // 删除
+        // 判断删除的这条数据是否有id,如果有id则调用接口删除,没有id则直接在页面删除
+        if (item.id) {
+            form.value?.landDelIds?.push(item?.id)
+        }
         form.value.landInfoList.splice(idx, 1);
     }
 };

+ 49 - 1
src/plant/code/code-query/index.vue

@@ -4,7 +4,7 @@
             <ut-navbar title="追溯码查询" :fixed="false"></ut-navbar>
         </template>
         <view class="pd-20">
-            <up-button class="bg-fff" type="primary" plain>
+            <up-button class="bg-fff" type="primary" plain @click="handleScan">
                 <image class="w-36 h-36 mr-10" src="https://yujin-szyy.oss-cn-chengdu.aliyuncs.com/szyy/images-plt/common/primary_scan.png" mode="widthFix" />
                 <span>请扫描追溯码查询</span>
             </up-button>
@@ -28,6 +28,54 @@ const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 const { pt_code_downflag } = toRefs<any>(proxy?.useDict('pt_code_downflag'));
 const paging = ref();
 const info = ref<any>(null);
+// 获取追溯码信息
+const getInfo = async (code: string) => {
+    // 
+}
+
+const getQueryParam = (url: string, key: string) => {
+    const queryIndex = url.indexOf('?');
+    if (queryIndex < 0) {
+        return '';
+    }
+    const query = url.slice(queryIndex + 1);
+    const pairs = query.split('&').filter(Boolean);
+    for (const pair of pairs) {
+        const [rawKey, ...rest] = pair.split('=');
+        if (decodeURIComponent(rawKey || '') !== key) {
+            continue;
+        }
+        return decodeURIComponent((rest.join('=') || '').replace(/\+/g, ' '));
+    }
+    return '';
+};
+
+const resolveTraceCode = (result: string) => {
+    const value = (result || '').trim();
+    if (!value) {
+        return '';
+    }
+    // 扫描到地址码时优先取参数 c,普通码则直接返回原值。
+    return getQueryParam(value, 'c') || value;
+};
+
+const handleScan = () => {
+    // #ifdef MP-WEIXIN
+    uni.scanCode({
+        onlyFromCamera: true,
+        success: (res) => {
+            const result = (res.result || '').trim();
+            const code = resolveTraceCode(result);
+            if (!code) {
+                return;
+            }
+            console.log('扫码结果:', result);
+            console.log('追溯码:', code);
+        },
+        fail: () => {},
+    });
+    // #endif
+};
 
 onMounted(() => {