|
@@ -25,8 +25,7 @@ export default function wxShare(shareurl,title,desc,imgurl,hide){
|
|
|
if(res.Ret!==4003){
|
|
|
Toast('获取签名失败,请刷新重试!')
|
|
|
}
|
|
|
- //如果需要强制刷新
|
|
|
- //window.location.reload()
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
if( hide==1 ){
|
|
@@ -40,47 +39,11 @@ export default function wxShare(shareurl,title,desc,imgurl,hide){
|
|
|
|
|
|
wx.showOptionMenu();
|
|
|
|
|
|
- wx.updateAppMessageShareData({
|
|
|
+ let shareData = {
|
|
|
title, // 分享标题
|
|
|
desc, // 分享描述
|
|
|
- link: shareurl, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
|
|
|
- imgUrl:imgurl, // 分享图标
|
|
|
- success: function () {
|
|
|
- // 设置成功
|
|
|
- console.log( "分享成功,当前链接:"+shareurl );
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- wx.updateTimelineShareData({
|
|
|
- title, // 分享标题
|
|
|
- link: shareurl, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
|
|
|
- imgUrl:imgurl, // 分享图标
|
|
|
- success: function () {
|
|
|
- // 设置成功
|
|
|
- console.log( "分享成功,当前链接:"+shareurl );
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- wx.onMenuShareTimeline({
|
|
|
- title:title, // 分享标题
|
|
|
- link:shareurl, // 分享链接,该链接域名必须与当前企业的可信域名一致
|
|
|
- imgUrl:imgurl, // 分享图标
|
|
|
- success: function () {
|
|
|
- // 用户确认分享后执行的回调函数
|
|
|
- console.log('分享成功,地址:'+shareurl)
|
|
|
- },
|
|
|
- cancel: function () {
|
|
|
- // 用户取消分享后执行的回调函数
|
|
|
- console.log('取消分享')
|
|
|
- }
|
|
|
- });
|
|
|
- wx.onMenuShareAppMessage({
|
|
|
- title:title, // 分享标题
|
|
|
- desc:desc, // 分享描述
|
|
|
link:shareurl, // 分享链接,该链接域名必须与当前企业的可信域名一致
|
|
|
imgUrl:imgurl, // 分享图标
|
|
|
- type:'', // 分享类型,music、video或link,不填默认为link
|
|
|
- dataUrl:'', // 如果type是music或video,则要提供数据链接,默认为空
|
|
|
success:function () {
|
|
|
// 用户确认分享后执行的回调函数
|
|
|
console.log( "分享成功,当前链接:"+shareurl );
|
|
@@ -89,7 +52,15 @@ export default function wxShare(shareurl,title,desc,imgurl,hide){
|
|
|
// 用户取消分享后执行的回调函数
|
|
|
console.log('取消分享')
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
+
|
|
|
+ wx.updateAppMessageShareData(shareData)
|
|
|
+
|
|
|
+ wx.updateTimelineShareData(shareData)
|
|
|
+
|
|
|
+ wx.onMenuShareTimeline(shareData);
|
|
|
+
|
|
|
+ wx.onMenuShareAppMessage(shareData);
|
|
|
|
|
|
wx.hideMenuItems({
|
|
|
menuList: ['menuItem:share:qq','menuItem:share:weiboApp','menuItem:share:facebook','menuItem:share:QZone','menuItem:openWithSafari','menuItem:share:email'] // 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3
|