ios会记录一进去的页面路径所以在,app.vue页面里存下进入页面的路径
created () {
window.localStorage.setItem('sigUrl',window.location.href)
}
然后在公共封装的方法里进行判断
/**
*
* @desc 微信分享
* @param parmas(url地址链接,title分享的标题,desc分享的描述,imgUrl分享的图片链接,success)
*/
static wxShare(parmas) {
// if(!parmas){
var a = this.isWeiXinAndIos() ? window.localStorage.getItem('sigUrl') : window.location.href
post('/im/queryScan.action', {
url: a
}).then(response => {
if (response.data && response.respCode == 1001) {
console.log('ddddddddddddddd')
wx.config({
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端openAlert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
appId: response.data.appId, // 必填,公众号的唯一标识
timestamp: response.data.timestamp, // 必填,生成签名的时间戳
nonceStr: response.data.nonceStr, // 必填,生成签名的随机串
signature: response.data.signature, // 必填,签名,见附录1
jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo',
'onMenuShareQZone', 'updateAppMessageShareData', 'updateTimelineShareData'
]
// 必填,需要使用的JS接口列表,所有JS接口列表见附录2
})
wx.ready(function () {
console.log('cccccc')
// 微信分享的数据
var shareData = {
'imgUrl': parmas.imgUrl ? parmas.imgUrl : '默认', // 分享显示的缩略图地址
'link': parmas.url ? parmas.url : window.location.href, // 分享地址
'desc': parmas.desc ? parmas.desc : '默认', // 分享描述
'title': parmas.title ? parmas.title : '默认', // 分享标题
success: function () {
parmas.success && parmas.success()
}
}
wx.onMenuShareTimeline(shareData)
wx.onMenuShareAppMessage(shareData)
wx.onMenuShareQQ(shareData)
wx.onMenuShareWeibo(shareData)
wx.onMenuShareQZone(shareData)
})
wx.error(function (res) {
console.log(res)
})
}
})
// }
}