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