export const defaultWxshare = (shareImg,shareDesc,shareTitle) => { let LocUrl = encodeURIComponent(location.href.split("#")[0]); LocUrl = LocUrl.replace(/\&/g, "%26"); axios .get(`http://api.pinpaizw.com/interface/pinpai3/mobile/wx_get_signature.php?url=${LocUrl}`) .then(response => { let link = response.data.res.url; let shareUrl = link let wxConfig = { debug: false, appId: response.data.res.appid, timestamp: response.data.res.timestamp, nonceStr: response.data.res.nonceStr, signature: response.data.res.signature, jsApiList: [ "checkJsApi", "onMenuShareTimeline", "onMenuShareAppMessage" ] } wx.config(wxConfig); wx.ready(function () { let shareConfig = { title: shareTitle, link: shareUrl, desc: shareDesc, imgUrl: shareImg } console.log(shareTitle); console.log(shareDesc); console.log(shareImg); wx.onMenuShareTimeline(shareConfig); wx.onMenuShareAppMessage(shareConfig); wx.error(function (errText) { console.log(errText); }); }); }) .catch(errorVal => { console.log(errorVal.errMsg); }); }
|