控制微信分享的标题,图片等等
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript">
wx.config({
debug: false,
appId: '<{$signPackage.appId}>',
timestamp: <{$signPackage.timestamp}>,
nonceStr: '<{$signPackage.nonceStr}>',
signature: '<{$signPackage.signature}>',
jsApiList: [
// 所有要调用的 API 都要加到这个列表中
'onMenuShareAppMessage',
'onMenuShareTimeline',
'hideMenuItems'
]
});
wx.ready(function () {
// 2.1 监听“分享给朋友”,按钮点击、自定义分享内容及分享结果接口
wx.onMenuShareAppMessage({
title: '这里写标题',
desc: '描述',
link: '链接',
imgUrl: '图片地址',
trigger: function (res) {
// 不要尝试在trigger中使用ajax异步请求修改本次分享的内容,因为客户端分享操作是一个同步操作,这时候使用ajax的回包会还没有返回
//alert('用户点击发送给朋友');
},
success: function (res) {
//window.location.href="<{$returnurl}>";
//alert('已分享成功');
},
cancel: function (res) {
//alert('已取消');
},
fail: function (res) {
//alert(JSON.stringify(res));
}
});
//alert('已注册获取“发送给朋友”状态事件');
// 2.2 监听“分享到朋友圈”按钮点击、自定义分享内容及分享结果接口
wx.onMenuShareTimeline({
title: '标题',
link: '链接',
imgUrl: '图片地址>',
trigger: function (res) {
// 不要尝试在trigger中使用ajax异步请求修改本次分享的内容,因为客户端分享操作是一个同步操作,这时候使用ajax的回包会还没有返回
//alert('用户点击分享到朋友圈');
},
success: function (res) {
//window.location.href="";
//alert('已分享');
},
cancel: function (res) {
//alert('已取消');
},
fail: function (res) {
//alert(JSON.stringify(res));
}
});
//alert('已注册获取“分享到朋友圈”状态事件');
// 8.3 批量隐藏菜单项
wx.hideMenuItems({
menuList: [
'menuItem:readMode', // 阅读模式
'menuItem:copyUrl', // 复制链接
'menuItem:originPage', //原网页
'menuItem:openWithQQBrowser',//在QQ浏览器中打开
'menuItem:openWithSafari',//在Safari中打开
'menuItem:share:email' //邮件
],
success: function (res) {
//alert('已隐藏“阅读模式”,“分享到朋友圈”,“复制链接”等按钮');
},
fail: function (res) {
//alert(JSON.stringify(res));
}
});
});//wx.read结束
</script>
备忘….
微信扫一扫,打赏作者吧~