h5页面在微信中进行分享

    xiaoxiao2022-06-30  153

    1.引入该文件<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>

    2.

    //微信分享 var now_url=window.location.href; $.ajax({ url : '链接', type : "get", dataType : "json", async : false, data:{ 'accesstoken':'token值', 'url':now_url //当前网址 }, success : function(data) { wx.config({ debug: false, appId: data.appId, timestamp: data.timestamp, nonceStr: data.nonceStr , signature: data.signature , jsApiList: [ 'showOptionMenu', 'onMenuShareTimeline', 'onMenuShareAppMessage' ] }); }, error : function(){ console.log('请求错误') } }), setTimeout(function(){ wx.ready(function () { wx.showOptionMenu(); //“分享到朋友圈” wx.onMenuShareTimeline({ title:'分享出来的标题', link:now_url, imgUrl: 'aa.png', success: function () { console.log("分享成功"); }, cancel: function () { console.log("分享失败"); } }); // “分享给朋友” wx.onMenuShareAppMessage({ title:'分享出来的标题', desc: '进来看看', link:now_url, imgUrl: 'aa.png', type: 'link', // 分享类型,当前是链接link success: function () { console.log("分享成功") }, cancel: function () { console.log("分享失败") } }); }); },500) //微信分享end

     


    最新回复(0)