最近做微信开发,对微信公众号的开发,现在好的都是分享到朋友圈,QQ,分享给好友等分享功能,这里记录下,有需要的朋友也可以看下。
分享
var wx = require('wechat-sdk');
rewardsResultService.getWechatInfo().then(function(data) {
var conf = data;
wx.config({
debug: false,appId: 'wx34e783920b37ee91',timestamp: conf.timestamp,nonceStr: conf.noncestr,signature: conf.signature,jsApiList: ['onMenuShareAppMessage','onMenuShareTimeline','onMenuShareQQ']
});
configWeChatInterface();
});
var iconUrl = 'http://'+location.host+'/images/icon-200yuan.png';
function configWeChatInterface() {
//<a href="https://www.jb51.cc/tag/fenxiang/" target="_blank" class="keywords">分享</a>给朋友
wx.onMenuShareAppMessage({
title: '一言不合就发红包,金蛛送您200元红包!',desc: '一言不合就发红包,金蛛送您200元红包!',link: location.href,imgUrl: iconUrl,type: 'link',success: function() {
// alert('share success');
},cancel: function() {
}
});
//<a href="https://www.jb51.cc/tag/fenxiang/" target="_blank" class="keywords">分享</a>到朋友圈
wx.onMenuShareTimeline({
title: '一言不合就发红包,金蛛送您200元红包!',// <a href="https://www.jb51.cc/tag/fenxiang/" target="_blank" class="keywords">分享</a><a href="https://www.jb51.cc/tag/lianjie/" target="_blank" class="keywords">链接</a>
imgUrl: iconUrl
});
//<a href="https://www.jb51.cc/tag/fenxiang/" target="_blank" class="keywords">分享</a>到QQ
wx.onMenuShareQQ({
title: '一言不合就发红包,金蛛送您200元红包!',// <a href="https://www.jb51.cc/tag/fenxiang/" target="_blank" class="keywords">分享</a><a href="https://www.jb51.cc/tag/biaoti/" target="_blank" class="keywords">标题</a>
desc: '一言不合就发红包,金蛛送您200元红包!',// <a href="https://www.jb51.cc/tag/fenxiang/" target="_blank" class="keywords">分享</a>描述
link: location.href,// <a href="https://www.jb51.cc/tag/fenxiang/" target="_blank" class="keywords">分享</a><a href="https://www.jb51.cc/tag/lianjie/" target="_blank" class="keywords">链接</a>
imgUrl: iconUrl,// <a href="https://www.jb51.cc/tag/fenxiang/" target="_blank" class="keywords">分享</a>图标
success: function () {
// <a href="https://www.jb51.cc/tag/yonghu/" target="_blank" class="keywords">用户</a>确认<a href="https://www.jb51.cc/tag/fenxiang/" target="_blank" class="keywords">分享</a><a href="https://www.jb51.cc/tag/houzhixing/" target="_blank" class="keywords">后执行</a>的回调<a href="https://www.jb51.cc/tag/hanshu/" target="_blank" class="keywords">函数</a>
},cancel: function () {
// <a href="https://www.jb51.cc/tag/yonghu/" target="_blank" class="keywords">用户</a>取消<a href="https://www.jb51.cc/tag/fenxiang/" target="_blank" class="keywords">分享</a><a href="https://www.jb51.cc/tag/houzhixing/" target="_blank" class="keywords">后执行</a>的回调<a href="https://www.jb51.cc/tag/hanshu/" target="_blank" class="keywords">函数</a>
}
});
}</pre>
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
原文链接:https://www.f2er.com/js/44973.html