...
|
...
|
@@ -9,49 +9,25 @@ |
|
|
</head>
|
|
|
<body>
|
|
|
<h1>分享主题</h1>
|
|
|
<button data-mshare="0">点击弹出原生分享面板</button>
|
|
|
<button data-mshare="1">点击触发朋友圈分享</button>
|
|
|
<button data-mshare="2">点击触发发送给微信朋友</button>
|
|
|
</body>
|
|
|
</html>
|
|
|
<script src="__TMPL__/public/assets/js/jquery-2.1.0.js"></script>
|
|
|
<script src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
|
|
|
<script src="__TMPL__/public/assets/js/mshare.js"></script>
|
|
|
<script>
|
|
|
$(function () {
|
|
|
wx.config({
|
|
|
debug: true,
|
|
|
appId: '{$data.appId}',
|
|
|
timestamp: '{$data.timestamp}',
|
|
|
nonceStr: '{$data.nonceStr}',
|
|
|
signature: '{$data.signature}',
|
|
|
jsApiList: [
|
|
|
'updateAppMessageShareData',
|
|
|
'updateTimelineShareData',
|
|
|
]
|
|
|
});
|
|
|
wx.ready(function () { //需在用户可能点击分享按钮前就先调用
|
|
|
wx.updateAppMessageShareData({
|
|
|
title: '分享标题', // 分享标题
|
|
|
desc: '分享描述', // 分享描述
|
|
|
link: 'http://www.starplanet.cn/portal/enjoy/getEnjoyDetail?id=81', // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
|
|
|
imgUrl: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1562352770741&di=353c660582a6727a64cdfdc93c4fb0f0&imgtype=0&src=http%3A%2F%2Fpic.k73.com%2Fup%2Fsoft%2F2016%2F0102%2F092635_44907394.jpg', // 分享图标
|
|
|
success: function (e) {
|
|
|
// 设置成功
|
|
|
alert('分享朋友');
|
|
|
}
|
|
|
});
|
|
|
wx.updateTimelineShareData({
|
|
|
title: '分享朋友圈', // 分享标题
|
|
|
link: 'http://www.starplanet.cn/portal/enjoy/getEnjoyDetail?id=81', // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
|
|
|
imgUrl: '', // 分享图标
|
|
|
success: function () {
|
|
|
// 设置成功
|
|
|
alert('分享朋友圈 ');
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
wx.error(function (res) {
|
|
|
// config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
|
|
|
alert(res);
|
|
|
});
|
|
|
|
|
|
var mshare = new mShare({
|
|
|
title: 'Lorem ipsum dolor sit.',
|
|
|
url: 'http://m.ly.com',
|
|
|
desc: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quaerat inventore minima voluptates.',
|
|
|
img: 'http://placehold.it/150x150'
|
|
|
});
|
|
|
$('button').click(function () {
|
|
|
// 1 ==> 朋友圈 2 ==> 朋友 0 ==> 直接弹出原生
|
|
|
mshare.init(+$(this).data('mshare'));
|
|
|
});
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
...
|
...
|
|