微信分享样式调整,使用微信js-sdk

参考:微信公众平台

一、前端

<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script>
function wx_ready_fenxiang(title, desc, imgUrl,url){
    $.post("getToken.jhtml",{"url":url},function(result){
        if(result.code==0){
            var appid,timestamp,nonceStr,signature;
            appid = result.data.appid;
            timestamp = result.data.timestamp;
            nonceStr = result.data.nonceStr;
            signature = result.data.signature;
            wx.config({
                debug: false,//debug模式会打印日志,微信端会弹框
                appId: appid,
                timestamp:timestamp,
                nonceStr: nonceStr,
                signature: signature,
                jsApiList: [
                    'onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone'
                ]
            });
            _wx(title, desc, imgUrl, 'link',url);
        }
    },"json")
}

function _wx(title, desc, imgUrl, type,url){
    wx.ready(function() {
        //朋友圈
        wx.onMenuShareTimeline({
            title: title, // 分享标题
            link: url, // 分享链接
            imgUrl: imgUrl, // 分享图标
            success: function() {
                //                            alert('谢谢分享');
                // 用户确认分享后执行的回调函数
            },
            cancel: function() {
                //                            alert('谢谢分享');
                // 用户取消分享后执行的回调函数
            }
        });

        //微信好友
        wx.onMenuShareAppMessage({
            title: title, // 分享标题
            desc: desc, // 分享描述
            link: url, // 分享链接
            imgUrl: imgUrl, // 分享图标
            type: type, // 分享类型,music、video或link,不填默认为link
    
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值