wechatshare.js 1.54 KB
function setShare(url, imgurl, descript, gourl) {
    setShareNew(document.title, url, imgurl, descript, gourl);
}
function setShareNew(title, url, imgurl, descript, gourl) {
    wx.ready(function () {
        wx.onMenuShareAppMessage({
            title: title,
            desc: descript,
            link: url,
            imgUrl: imgurl,
            trigger: function (res) {
                //alert('用户点击发送给朋友');
            },
            success: function (res) {
                if (gourl) window.location.href = gourl;
            },
            cancel: function (res) {
                //alert('已取消');
            },
            fail: function (res) {
                //alert(JSON.stringify(res));
            }
        });
        //注册分享到朋友圈
        wx.onMenuShareTimeline({
            title: title,
            desc: descript,
            link: url,
            imgUrl: imgurl,
            trigger: function (res) {
                //alert('用户点击发送给朋友');
            },
            success: function (res) {
                if (gourl) window.location.href = gourl;
            },
            cancel: function (res) {
                //alert('已取消');
            },
            fail: function (res) {
                //alert(JSON.stringify(res));
            }
        });
    });
}

//隐藏复制按钮
function HideCopyMenu() {
    wx.ready(function() {
        wx.hideMenuItems({
            menuList: ["menuItem:copyUrl", "menuItem:openWithQQBrowser", "menuItem:openWithSafari"]
    });
    });
}