h5微信分享

function WeiXinShare(title, link, imgurl, sharedesc) {
var _data = {
url: location.href,
t: Math.random()
};
var _getWechatSignUrl = ‘/home/JsSdk’;
$.ajax({
url: _getWechatSignUrl,
data: {
tempurl: location.href,
t: Math.random()
},
success: function (res) {
res = JSON.parse(res);
console.log(res.code);

        if (res.code == 1) {
            wxConfig(res.data.data.appid, res.data.data.timestamp, res.data.data.nonceStr, res.data.data.signature);
        }
    }
});
// var tt=location.href;
console.log(location.href);
//debugger;
function wxConfig(_appId, _timestamp, _nonceStr, _signature) {
    wx.config({
        debug: false,
        appId: _appId,
        timestamp: _timestamp,
        nonceStr: _nonceStr,
        signature: _signature,
        jsApiList: [
             'checkJsApi',
            'onMenuShareTimeline',
            'onMenuShareAppMessage'
        ]
    });



}
wx.ready(function () {   //需在用户可能点击分享按钮前就先调用
    wx.onMenuShareTimeline({
        title: title, // 分享标题
        link: location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
        imgUrl: 'http://school.fg1413.com/' + imgurl, // 分享图标
        success: function () {
            // 用户点击了分享后执行的回调函数
        }
    });
    wx.onMenuShareAppMessage({
        title: title, // 分享标题
        desc: sharedesc, // 分享描述
        link: location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
        imgUrl: 'http://school.fg1413.com/' + imgurl, // 分享图标
        type: '', // 分享类型,music、video或link,不填默认为link
        dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空
        success: function () {
            // 用户点击了分享后执行的回调函数
        }
    });
});

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值