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.
 
 
 
 

48 lines
1.7 KiB

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