微信分享

作者:夏雨芭蕉时间:2016-05-10 13:43:16 浏览量:

function nowUrl(){
    var a = window.location.href;
    var b = a.split('//')[1].split('/');
    var c = b.length-1;
    var d = b[c];
    return a.replace(d,'');
}
function wx_init_refresh(){
     if(!isWx()) return;
    var _preUrl=nowUrl();
    var shareLink=_preUrl+'index.html';
    var _imgUrl=_preUrl+'images/share-logo.jpg';//分享logo
    var shareUrl_p=window.location.href;
    var obj = sign(localStorage.getItem("ticket"),  shareUrl_p);
    wx.config({
        debug: false,
        appId: 'wxd7fc6660f09f82c9',
        timestamp: obj.timestamp,
        nonceStr: obj.nonceStr,
        signature: obj.signature,
        jsApiList: [
            'onMenuShareTimeline',
            'onMenuShareAppMessage'
        ]
    });

    wx.ready(function () {
         //runajax();
        var imgUrl = _imgUrl;
        var shareTitle = "居然擦身而过,不服再战!";
        var descContent = "哎呀,一定是姿势不对。换个手指试试!";
        var lineLink = shareLink;
        runfun(function () {
            wx.onMenuShareAppMessage({
                title: shareTitle,
                desc: descContent,
                link: lineLink,
                imgUrl: imgUrl,
                success: function () {
                    //location.href=nowUrl()+'success.html';
                },
                cancel: function () { }
            });
        })
        runfun(function () {
            wx.onMenuShareTimeline({
                title: shareTitle,
                link: lineLink,
                imgUrl: imgUrl,
                success: function () {
                    //location.href=nowUrl()+'success.html';
                },
                cancel: function () { }
            });
        });
      
    });
     wx.error(function (res) {
         init_runwx();
     });

}


Copyright © 2016 Allister All Rights Reserved