IOS 下调用 wx.config 鉴权第一次失败,报 config:invalid signature,第二次之后成功,稳定复现。android 下无问题
appid: wx065d450153703be7
initConfig() {
const params = {
appid: wxAPPID,
url: window.location.href.split('#')[0],
};
if (this.hasWxConfigReady) {
return Promise.resolve();
}
return new Promise((resolve, reject) => {
// 从服务端获取签名参数
api.chat
.getSDKParams(params)
.then((res) => {
if (res && res.data) {
const { timestamp, nonceStr, signature } = res.data;
wx.config({
debug: false,
appId: wxAPPID,
timestamp,
nonceStr,
signature,
jsApiList: ['chooseImage', 'uploadImage'],
});
wx.error((err) => {
console.log('wx-config-error', err);
});
wx.ready(() => {
resolve();
});
} else {
throw new Error('获取签名数据错误');
}
})
.catch((err) => {
reject(err);
});
});
},
参考一下:https://developers.weixin.qq.com/community/develop/doc/0006824d31852025ab3bea42453c00?_at=1646289813081