This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { wechatApi } from '@/api/index.js';
|
||||
|
||||
export const initWxSdk = async () => {
|
||||
if (typeof wx === 'undefined') return false;
|
||||
if (typeof wx === 'undefined') {
|
||||
return { success: false, error: '请在微信中打开' };
|
||||
}
|
||||
|
||||
try {
|
||||
const currentUrl = window.location.href.split('#')[0];
|
||||
@@ -19,14 +21,14 @@ export const initWxSdk = async () => {
|
||||
});
|
||||
|
||||
return new Promise((resolve) => {
|
||||
wx.ready(() => resolve(true));
|
||||
wx.ready(() => resolve({ success: true }));
|
||||
wx.error((err) => {
|
||||
console.error('wx.config error:', err);
|
||||
resolve(false);
|
||||
resolve({ success: false, error: err.errMsg || '微信配置失败' });
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('WX SDK init failed', e);
|
||||
return { success: false, error: e.message || '获取微信配置失败' };
|
||||
}
|
||||
return false;
|
||||
};
|
||||
Reference in New Issue
Block a user