You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

37 lines
1.3 KiB

import API from '@/common/js/api.js'
const wxApi = {
/**
* [wxRegister 微信Api初始化]
*/
wxRegister(callback) {
let _this = this;
let signUrl = encodeURIComponent(location.href.split("#")[0]);
let jsApiList = ["chooseInvoiceTitle"];
// 接口请求传入路径
API.getJsSdkData({url:signUrl}, res => {
jWeixin.config({
beta: true,//用于方法未对外公开的情况
debug: false, // 开启调试模式
appId: res.data.appId, // 必填,公众号的唯一标识
timestamp: res.data.timestamp, // 必填,生成签名的时间戳
nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
signature: res.data.signature, // 必填,签名
jsApiList: jsApiList // 必填,需要使用的JS接口列表
// openTagList:['wx-open-launch-weapp','wx-open-subscribe']
});
jWeixin.ready(() => {
callback && callback();
});
jWeixin.error((optinos) => {
// config信息验证失败会执行error函数,
//如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,
//也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
console.log(optinos, 'optinos')
// console.log(optinos, 'optinos')
// App.showError(optinos.errMsg)
});
});
}
}
export default wxApi