From 5c279028c30ff05dbb5c6dd23e8e6fbe12f0d11a Mon Sep 17 00:00:00 2001 From: liguigong Date: Sat, 11 Oct 2025 10:32:12 +0800 Subject: [PATCH] =?UTF-8?q?feat(h5):=20=E5=BC=95=E5=85=A5=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1JSSDK=E5=B9=B6=E5=AE=9E=E7=8E=B0=E8=B7=A8=E5=9F=9F?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E9=80=9A=E4=BF=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在H5环境中动态加载微信JSSDK 实脚本 -现向父窗口发送postMessage消息 - 支持向微信小程序发送postMessage消息 - 添加延迟执行机制确保消息发送时机 - 增强与微信小程序的交互能力 --- App.vue | 6 ++++++ pages/uploadClothes/index.vue | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/App.vue b/App.vue index c17f8d1..4443e17 100644 --- a/App.vue +++ b/App.vue @@ -3,6 +3,12 @@ import { ShoproInit } from './sheep'; onLaunch(() => { + // #ifdef H5 + const script = document.createElement('script'); + script.src = 'https://res.wx.qq.com/open/js/jweixin-1.6.0.js'; + script.type = 'text/javascript'; + document.body.appendChild(script); + // #endif // 隐藏原生导航栏 使用自定义底部导航 uni.hideTabBar({ fail: () => {}, diff --git a/pages/uploadClothes/index.vue b/pages/uploadClothes/index.vue index 0dc1719..6112e59 100644 --- a/pages/uploadClothes/index.vue +++ b/pages/uploadClothes/index.vue @@ -113,6 +113,27 @@ onLoad((options) => { console.log('🚀 ~ 🐶106 ~ options: ', options); + setTimeout(() => { + window?.parent?.postMessage( + { + data: { + code: 'success', + test: '我是子页面的test!', + }, + }, + '*', + ); + wx?.miniProgram?.postMessage({ + data: { + action: 'type', + message: '1234', + timestamp: new Date().getTime(), + }, + }); + console.log(wx?.miniProgram?.postMessage); + console.log(window?.parent); + }, 2000); + if (options?.fileUrl) { isEdit.value = true; }