微信分享自定义

微信JS-SDK说明文档:https://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E6.AD.A5.E9.AA.A4.E4.B8.80.EF.BC.9A.E7.BB.91.E5.AE.9A.E5.9F.9F.E5.90.8D

http://caibaojian.com/wxshare-config.html

 

//请求分享接口
hostUrl : window.location.href,
share: function(){
var param = {url: xinzhiMobile.hostUrl};
XinZhiCrud.xinzhiQuery({
url: "分享接口",
param: param,
success: function (data) {
xinzhiMobile.shareItems = data;
xinzhiMobile.shareWay();
}
})
xinzhiMobile.isStorage = localStorage.getItem("storage");
if(xinzhiMobile.isStorage == '1'){
$('body').css('overflow', 'visible');
$('html').css('overflow', 'visible');
$('.sTips').css('position', 'fixed');
}
},
//设置分享
shareWay: function(){
document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
WeixinJSBridge.call('showOptionMenu');
});
wx.config({
debug: false,// 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。移动端会通过弹窗来提示相关信息。如果分享信息配置不正确的话,可以开了看对应报错信息
appId: xinzhiMobile.shareItems.appId,
timestamp: xinzhiMobile.shareItems.timestamp,
nonceStr: xinzhiMobile.shareItems.nonceStr,
signature: xinzhiMobile.shareItems.signature,
jsApiList: [//需要使用的JS接口列表,分享默认这几个,如果有其他的功能比如图片上传之类的,需要添加对应api进来
'checkJsApi',
'onMenuShareTimeline',//
'onMenuShareAppMessage',
'onMenuShareQQ',
'onMenuShareWeibo'
]
});
window.share_config = {
"share": {
"imgUrl": "https://sandbox1.51xinzhi.com/web/images/shareLogo.png",//分享图,默认当相对路径处理,所以使用绝对路径的的话,“http://”协议前缀必须在。
"desc" : "包含完整的逐字稿咨询记录、逐字稿批注、督导解答",//摘要,如果分享到朋友圈的话,不显示摘要。
"title" : '您的朋友分享了督导的代表作案例',//分享卡片标题
"link": xinzhiMobile.hostUrl,//分享出去后的链接,这里可以将链接设置为另一个页面。
"success":function(){//分享成功后的回调函数
//alerter("分享成功");
},
'cancel': function () {
//alerter("取消分享");
// 用户取消分享后执行的回调函数
}
}
};
wx.ready(function () {
wx.onMenuShareAppMessage(share_config.share);//分享给好友
wx.onMenuShareTimeline(share_config.share);//分享到朋友圈
wx.onMenuShareQQ(share_config.share);//分享给手机QQ
});
}

posted on 2017-04-26 14:26  王子乔  阅读(186)  评论(0编辑  收藏  举报

导航