callback && callback()

dev_cs
hjm 5 years ago
parent fd8b631651
commit c436e780d4

@ -16,41 +16,45 @@ const urlDoneMap = {}
function requestForSignatrue (callback) {
const currentUrl = window.location.href.split('#')[0]
if (window.wx && !urlDoneMap[currentUrl]) {
const wx = window.wx
const url = '/wechats/js_sdk_signature.json'
urlDoneMap[currentUrl] = true
// window.encodeURIComponent()
axios.post(url, {
url: window.__testUrl || currentUrl,
}).then((response) => {
console.log('got res')
const data = response.data;
wx.config({
debug: false,
appId: data.appid,
timestamp: data.timestamp,
nonceStr: data.noncestr,
signature: data.signature,
jsApiList: [
'onMenuShareTimeline',//
'onMenuShareAppMessage',
'onMenuShareQQ',
'onMenuShareWeibo',
'onMenuShareQZone'
]
});
wx.ready(function () {
callback && callback()
});
wx.error(function (res) {
console.log('wx is error')
console.log(res)
//alert(res.errMsg);//错误提示
});
}).catch((error) => {
console.log(error)
})
if (window.wx) {
if (urlDoneMap[currentUrl]) {
callback && callback()
} else {
const wx = window.wx
const url = '/wechats/js_sdk_signature.json'
urlDoneMap[currentUrl] = true
// window.encodeURIComponent()
axios.post(url, {
url: window.__testUrl || currentUrl,
}).then((response) => {
console.log('got res')
const data = response.data;
wx.config({
debug: false,
appId: data.appid,
timestamp: data.timestamp,
nonceStr: data.noncestr,
signature: data.signature,
jsApiList: [
'onMenuShareTimeline',//
'onMenuShareAppMessage',
'onMenuShareQQ',
'onMenuShareWeibo',
'onMenuShareQZone'
]
});
wx.ready(function () {
callback && callback()
});
wx.error(function (res) {
console.log('wx is error')
console.log(res)
//alert(res.errMsg);//错误提示
});
}).catch((error) => {
console.log(error)
})
}
}
}
/**

Loading…
Cancel
Save