From 08c9d23e86b545a34e00a5fb5dae81ebabe50dea Mon Sep 17 00:00:00 2001
From: ‘chensiAb’ <‘chenchenco03@163.com’>
Date: Tue, 25 Mar 2025 13:54:19 +0800
Subject: [PATCH] feat:上传图片组件-添加lpg的接口路径

---
 bases/Pilot.js |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/bases/Pilot.js b/bases/Pilot.js
index 6fa3641..6dcacf0 100644
--- a/bases/Pilot.js
+++ b/bases/Pilot.js
@@ -4,8 +4,7 @@
  */
 
 import Taro, { getCurrentInstance, getCurrentPages } from '@tarojs/taro';
-import { Fetcher } from './Fetcher';
-import { Tools } from '@components/common/Tools';
+import { $hostBoot } from '@components/bases/HostBoot';
 import project from '@project';
 
 export class Pilot {
@@ -22,10 +21,15 @@
             methods: {},
         };
         const names = [];
+        let parent = null;
         // 实例本身的字段
         Object.getOwnPropertyNames(this).forEach(name => names.push(name));
-        // 类的字段
-        Object.getOwnPropertyNames(Object.getPrototypeOf(this)).forEach(name => names.push(name));
+        // 基类的字段,直到Pilot为止(不含Pilot)
+        parent = Object.getPrototypeOf(this);
+        while (parent instanceof Pilot) {
+            Object.getOwnPropertyNames(parent).forEach(name => names.push(name));
+            parent = Object.getPrototypeOf(parent);
+        }
         // 传递
         names.forEach(name => {
             // 构造器忽略,如果存在属性 $methods 也忽略
@@ -93,7 +97,7 @@
     static createPoster($vm) {
         return (pageType, action, data) => {
             // 解除引用关系
-            const nextData = JSON.parse(JSON.stringify(data));
+            const nextData = JSON.parse(JSON.stringify(data || {}));
             // 下一页
             if (pageType === 'nextPage') {
                 // 持续 3 秒,检测下一页是否存在
@@ -107,7 +111,7 @@
                     const nextPage = currentPages[pageIndex + 1];
                     if (nextPage) {
                         clearInterval(timer);
-                        nextPage.$component.$onMessage(action, nextData);
+                        nextPage.$component?.$onMessage(action, nextData);
                     }
                 }, 50);
             } else if (pageType === 'prevPage') {
@@ -115,12 +119,12 @@
                 const pageIndex = currentPages.findIndex(page => page.$component === $vm);
                 const prevPage = currentPages[pageIndex - 1];
                 if (prevPage) {
-                    prevPage.$component.$onMessage(action, nextData);
+                    prevPage.$component?.$onMessage(action, nextData);
                 }
             } else if (pageType === 'rootPage') {
                 const currentPages = getCurrentPages();
                 const rootPage = currentPages[0];
-                rootPage.$component.$onMessage(action, nextData);
+                rootPage.$component?.$onMessage(action, nextData);
             }
         };
     }
@@ -145,7 +149,7 @@
             }
             // 小程序
             else if (process.env.TARO_ENV === 'weapp') {
-                assets2[key] = Fetcher.host + project.host.assetsPath + asset;
+                assets2[key] = $hostBoot.getHost() + project.host.assetsPath + asset;
             }
         });
         return assets2;

--
Gitblit v1.9.1