调用 initWxConfig () { let thisVM = this getWxConfig({}, function (res) { if (res.data.success === true) { let data = res.data.obj thisVM.$wechat.config({ debug: false, appId: data.appId + '', // 必填,公众号的唯一标识 timestam
initWxConfig () {
let thisVM = this
getWxConfig({}, function (res) {
if (res.data.success === true) {
let data = res.data.obj
thisVM.$wechat.config({
debug: false,
appId: data.appId + '', // 必填,公众号的唯一标识
timestamp: data.timestamp, // 必填,生成签名的时间戳
nonceStr: data.nonceStr + '', // 必填,生成签名的随机串
signature: data.signature + '', // 必填,签名,见附录1
jsApiList: ['closeWindow'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
})
thisVM.$wechat.ready(function () {
})
}
}, function () {
})
}
配置
// 微信JS-SDK初始化设置
export const getWxConfig = function (data, sucesFN, errFN) {
const href = window.location.href.split('?')[0]
if (href.indexOf('favicon.ico') > -1) {
return
}
axiosGet(webApp + `/wx/jsConfig?configUrl=${href}`, data, sucesFN, errFN)
}
