From fd68a2574b62674f8a0679446b2eb3eb53969a78 Mon Sep 17 00:00:00 2001
From: hejianhao <15708179461@qq.com>
Date: 星期一, 24 八月 2026 21:29:52 +0800
Subject: [PATCH] Merge branch 'dev-0806-wql'

---
 traditionalApp/pages/home/home.vue                                         |   43 +++++++-
 traditionalApp/nativeplugins/business-module/android/mylibrary-release.aar |    0 
 traditionalApp/package.json                                                |   50 +++++-----
 traditionalApp/utils/visitorDevice.js                                      |  106 +++++++++++++++++++++
 traditionalApp/nativeplugins/business-module/package.json                  |   23 ++++
 traditionalApp/App.vue                                                     |   10 ++
 traditionalApp/manifest.json                                               |   14 ++
 7 files changed, 214 insertions(+), 32 deletions(-)

diff --git a/traditionalApp/App.vue b/traditionalApp/App.vue
index 612afdd..0cbf4f4 100644
--- a/traditionalApp/App.vue
+++ b/traditionalApp/App.vue
@@ -19,6 +19,7 @@
 		initOpeninstall,
 		registerOpeninstallWakeUp
 	} from '@/utils/openinstall.js'
+	import { HardwareAPI } from '@/utils/visitorDevice.js'
 
 	let lastHandledInvitePayload = ''
 
@@ -27,6 +28,15 @@
 	 */
 	onLaunch(() => {
 		// #ifdef APP-PLUS
+		HardwareAPI.init().then(() => {
+			console.log('[App] 硬件插件全局初始化完成')
+			HardwareAPI.startScan((result) => {
+				console.log('[App] startScan 回调参数:', result)
+				uni.$emit('Hardware-Scan', result)
+			})
+		}).catch((error) => {
+			console.error('[App] 硬件插件全局初始化失败:', error)
+		})
 		initJPushLifecycle()
 		initOpeninstall()
 		registerOpeninstallWakeUp(handleOpeninstallPayload)
diff --git a/traditionalApp/manifest.json b/traditionalApp/manifest.json
index 71fca00..17bfc72 100644
--- a/traditionalApp/manifest.json
+++ b/traditionalApp/manifest.json
@@ -320,6 +320,20 @@
                         }
                     }
                 }
+            },
+            "business-module" : {
+                "__plugin_info__" : {
+                    "name" : "business-module",
+                    "description" : "业务模块插件",
+                    "platforms" : "Android,iOS",
+                    "url" : "",
+                    "android_package_name" : "",
+                    "ios_bundle_id" : "",
+                    "isCloud" : false,
+                    "bought" : -1,
+                    "pid" : "",
+                    "parameters" : {}
+                }
             }
         }
     },
diff --git a/traditionalApp/nativeplugins/business-module/android/mylibrary-release.aar b/traditionalApp/nativeplugins/business-module/android/mylibrary-release.aar
new file mode 100644
index 0000000..717a30f
--- /dev/null
+++ b/traditionalApp/nativeplugins/business-module/android/mylibrary-release.aar
Binary files differ
diff --git a/traditionalApp/nativeplugins/business-module/package.json b/traditionalApp/nativeplugins/business-module/package.json
new file mode 100644
index 0000000..71be55c
--- /dev/null
+++ b/traditionalApp/nativeplugins/business-module/package.json
@@ -0,0 +1,23 @@
+{
+  "_dp_type": "nativeplugin",
+  "name": "business-module",
+  "id": "business-module",
+  "version": "1.0.0",
+  "_dp_nativeplugin": {
+    "android": {
+      "plugins": [
+        {
+          "type": "module",
+          "name": "business-module",
+          "class": "com.example.mylibrary.BusinessModule"
+        }
+      ],
+      "integrateType": "aar",
+      "useAndroidX": true,
+      "minSdkVersion": 24,
+      "permissions": [
+        "android.permission.INTERNET"
+      ]
+    }
+  }
+}
\ No newline at end of file
diff --git a/traditionalApp/package.json b/traditionalApp/package.json
index 12a6485..d7c2ad5 100644
--- a/traditionalApp/package.json
+++ b/traditionalApp/package.json
@@ -1,28 +1,28 @@
 {
-    "id": "wlp-progress-new",
-    "name": "超级好用的最基础的半、全、渐变圆环进度条组件,可二次开发或者联系我二次开发哟",
-    "displayName": "超级好用的最基础的半、全、渐变圆环进度条组件,可二次开发或者联系我二次开发哟",
-    "version": "1.0.0",
-    "description": "超级好用的最基础的圆环进度条组件,可二次开发,半圆,全圆,渐变等等,利用canvas实现",
-    "keywords": [
-        "进度条",
-        "半圆环",
-        "全圆环",
-        "渐变"
-    ],
-    "dcloudext": {
-        "type": "component-vue",
-        "sale": {
-            "regular": {
-                "price": "0.00"
-            },
-            "sourcecode": {
-                "price": "0.00"
-            }
-        }
-    },
-    "uni_modules": {
-        "dependencies": [],
-        "encrypt": []
+  "id": "wlp-progress-new",
+  "name": "超级好用的最基础的半、全、渐变圆环进度条组件,可二次开发或者联系我二次开发哟",
+  "displayName": "超级好用的最基础的半、全、渐变圆环进度条组件,可二次开发或者联系我二次开发哟",
+  "version": "1.0.0",
+  "description": "超级好用的最基础的圆环进度条组件,可二次开发,半圆,全圆,渐变等等,利用canvas实现",
+  "keywords": [
+    "进度条",
+    "半圆环",
+    "全圆环",
+    "渐变"
+  ],
+  "dcloudext": {
+    "type": "component-vue",
+    "sale": {
+      "regular": {
+        "price": "0.00"
+      },
+      "sourcecode": {
+        "price": "0.00"
+      }
     }
+  },
+  "uni_modules": {
+    "dependencies": [],
+    "encrypt": []
+  }
 }
\ No newline at end of file
diff --git a/traditionalApp/pages/home/home.vue b/traditionalApp/pages/home/home.vue
index 8d4761b..9608c3a 100644
--- a/traditionalApp/pages/home/home.vue
+++ b/traditionalApp/pages/home/home.vue
@@ -139,10 +139,12 @@
 </template>
 
 <script setup lang="ts">
-	import { computed, ref, onMounted } from "vue";
+	import { computed, ref, onMounted, onUnmounted } from "vue";
 	import { onPullDownRefresh, onShow } from "@dcloudio/uni-app";
 	import { createLiveRoomEntry, getBannerList, getHomeFeaturedContent, getHomeLiveCourseList, getLiveRoomSetting } from "./service";
+	import { HardwareAPI } from '@/utils/visitorDevice.js';
 	import { resolveCurrentAppUserId } from "@/utils/app-user.js";
+	import { jumpToMiniProgramPay } from '@/utils/weizan-pay-bridge.js';
 
 	interface HomeBannerItem {
 		id : number | string;
@@ -222,10 +224,27 @@
 		return liveCourseList.value.filter((item) => String(item.courseId) !== String(selectedCourseId));
 	});
 
+	const handleHardwareScan = (result : unknown) => {
+		console.log('[home] Hardware-Scan 参数:', result);
+		let content = '';
+		try {
+			content = typeof result === 'string' ? result : JSON.stringify(result);
+		} catch (error) {
+			content = String(result);
+		}
+		uni.showModal({
+			title: 'startScan 回调参数',
+			content: content || '空参数',
+			showCancel: false
+		});
+		jumpToMiniProgramPay(result);
+	};
+
 	/**
 	 * 初始化导航栏所需系统信息。
 	 */
 	onMounted(() => {
+		uni.$on('Hardware-Scan', handleHardwareScan);
 		uni.getSystemInfo({
 			success: (res) => {
 				statusBarHeight.value = res.statusBarHeight || 0;
@@ -234,6 +253,10 @@
 		setTimeout(() => {
 			refreshHomeData();
 		}, 0);
+	});
+
+	onUnmounted(() => {
+		uni.$off('Hardware-Scan', handleHardwareScan);
 	});
 
 	/**
@@ -379,13 +402,19 @@
 				return;
 			}
 
-			const webviewUrl = `/pages/weizanLive/weizanLive?url=${encodeURIComponent(targetUrl)}&title=${encodeURIComponent('微赞直播')}`;
-			console.log('[goWeiZanLive] 准备跳转 WebView:', webviewUrl);
-
-			uni.navigateTo({
-				url: webviewUrl
+			const webPayOptions = {
+				ua: 'webchatPay/wx074c1f0cf5a0ecf4 InAppPay',
+				url: targetUrl,
+				title: '微赞直播'
+			};
+			// #ifdef APP-PLUS
+			HardwareAPI.openWebPay(webPayOptions).catch((error) => {
+				console.error('[goWeiZanLive] openWebPay 调用失败:', error);
 			});
-			console.log('[goWeiZanLive] navigateTo 调用完成');
+			return;
+			// #endif
+
+			return;
 		} catch (error) {
 			console.error('[goWeiZanLive] 异常捕获:', error);
 			uni.showToast({ title: '获取直播间地址失败', icon: 'none' });
diff --git a/traditionalApp/utils/visitorDevice.js b/traditionalApp/utils/visitorDevice.js
new file mode 100644
index 0000000..d0fa0b7
--- /dev/null
+++ b/traditionalApp/utils/visitorDevice.js
@@ -0,0 +1,106 @@
+// 安卓业务插件桥接,保持与设备初始化页相同的插件入口。
+let HardwarePlugin = null;
+if (typeof uni !== 'undefined' && typeof uni.requireNativePlugin === 'function') {
+  HardwarePlugin = uni.requireNativePlugin('business-module');
+}
+let initPromise = null;
+let initResult = null;
+
+const getPluginMethod = (methodNames = []) => {
+  if (!HardwarePlugin) {
+    return null;
+  }
+
+  return methodNames.find((methodName) => typeof HardwarePlugin[methodName] === 'function') || null;
+};
+
+export const HardwareAPI = {
+  init(options = {}) {
+    if (initResult) {
+      return Promise.resolve(initResult);
+    }
+    if (initPromise) {
+      return initPromise;
+    }
+
+    initPromise = new Promise((resolve, reject) => {
+      // #ifdef APP-PLUS
+      const methodName = getPluginMethod(['init']);
+      if (!methodName) {
+        initPromise = null;
+        reject(new Error('当前插件未提供初始化能力'));
+        return;
+      }
+
+      let isSettled = false;
+      let fallbackTimer = null;
+      const finishInit = (result) => {
+        if (isSettled) {
+          return;
+        }
+        isSettled = true;
+        if (fallbackTimer) {
+          clearTimeout(fallbackTimer);
+        }
+        initResult = result;
+        resolve(result);
+      };
+
+      try {
+        HardwarePlugin[methodName](options, (result) => {
+          if (result) {
+            finishInit(result);
+          }
+        });
+        fallbackTimer = setTimeout(() => {
+          finishInit({ code: 200, msg: 'init_called_without_callback' });
+        }, 300);
+      } catch (error) {
+        initPromise = null;
+        reject(error);
+      }
+      // #endif
+
+      // #ifndef APP-PLUS
+      initResult = { code: 200, msg: 'success' };
+      resolve(initResult);
+      // #endif
+    });
+
+    return initPromise;
+  },
+
+  startScan(callback) {
+    // #ifdef APP-PLUS
+    const methodName = getPluginMethod(['startScan']);
+    if (!methodName) {
+      throw new Error('当前插件未提供 startScan 能力');
+    }
+    HardwarePlugin[methodName]({ duration: 2000 }, (result) => callback?.(result));
+    return;
+    // #endif
+    // #ifndef APP-PLUS
+    throw new Error('当前平台不支持 startScan');
+    // #endif
+  },
+
+  openWebPay(options = {}) {
+    return new Promise((resolve, reject) => {
+      // #ifdef APP-PLUS
+      const methodName = getPluginMethod(['openWebPay']);
+      if (!methodName) {
+        reject(new Error('当前插件未提供网页支付能力'));
+        return;
+      }
+      try {
+        HardwarePlugin[methodName](options, resolve);
+      } catch (error) {
+        reject(error);
+      }
+      // #endif
+      // #ifndef APP-PLUS
+      reject(new Error('当前平台不支持网页支付'));
+      // #endif
+    });
+  },
+};

--
Gitblit v1.7.1