created () {
this.generateJsApiSign()
},
methods: {
generateJsApiSign (callback) {
if (this.$isWechat) {
home.generateJsApiSign((data) => {
if (data) {
wx.config({
debug: false,
appId: this.$appid,
timestamp: data.timestamp,
nonceStr: data.nonceStr,
signature: data.signature,
jsApiList: ['scanQRCode', 'chooseWXPay'],
success: () => {
this.isconfig = true
}
})
wx.ready(() => {
if (callback) callback()
console.log('wx ready')
})
wx.error(function (res) {
if (res.errMsg == 'config:ok') this.isconfig = true
})
}
})
}
},