From 715e4f6f7deca4d822e631c4c9f44be0fd1f6b2e Mon Sep 17 00:00:00 2001 From: sexygoat <1538832180@qq.com> Date: Fri, 17 Apr 2026 10:45:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=89=AB=E4=B8=80?= =?UTF-8?q?=E6=89=AB=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/login/login.vue | 1 + utils/wxsdk.js | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/pages/login/login.vue b/pages/login/login.vue index 6aa0fd3..6179f49 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -127,6 +127,7 @@ const handleScanLogin = async () => { // #ifdef H5 const ready = await initWxSdk(); + console.log(ready); if (!ready) { uni.showToast({ title: '扫一扫功能暂不可用', icon: 'none' }); return; diff --git a/utils/wxsdk.js b/utils/wxsdk.js index a6332d9..336a1b3 100644 --- a/utils/wxsdk.js +++ b/utils/wxsdk.js @@ -1,15 +1,17 @@ -import { APP_ID } from './env.js'; import { wechatApi } from '@/api/index.js'; export const initWxSdk = async () => { if (typeof wx === 'undefined') return false; try { - const data = await wechatApi.getJssdkConfig(window.location.href); + const currentUrl = window.location.href.split('#')[0]; + console.log('JSSDK URL:', currentUrl); + const data = await wechatApi.getJssdkConfig(currentUrl); + console.log('JSSDK Config:', data); wx.config({ - debug: false, - appId: APP_ID, + debug: true, + appId: data.app_id, timestamp: data.timestamp, nonceStr: data.nonce_str, signature: data.signature, @@ -18,7 +20,10 @@ export const initWxSdk = async () => { return new Promise((resolve) => { wx.ready(() => resolve(true)); - wx.error(() => resolve(false)); + wx.error((err) => { + console.error('wx.config error:', err); + resolve(false); + }); }); } catch (e) { console.error('WX SDK init failed', e);