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); wx.config({ debug: false, appId: APP_ID, timestamp: data.timestamp, nonceStr: data.nonce_str, signature: data.signature, jsApiList: ['scanQRCode'] }); return new Promise((resolve) => { wx.ready(() => resolve(true)); wx.error(() => resolve(false)); }); } catch (e) { console.error('WX SDK init failed', e); } return false; };