最新js分享到第三方平台代码

HTML代码

                


js代码

  $('.sidebar-share a').on('click', function() {
        let type = $(this).data('share');
        switch (type) {
            case 'wechat':
                layer.open({
                    type: 1,
                    title: false,
                    closeBtn: false,
                    scrollbar: false,
                    btnAlign: 'c',
                    btn: ['关闭'],
                    area: ['330px', '390px'],
                    content: '微信扫一扫,转发朋友圈或好友',
                    success: function() {
                        $('.promote-qrcode').each(function() {
                            var defaultParams = {
                                text: share.url,
                                width: 252,
                                height: 252,
                                colorDark: '#000000',
                                colorLight: '#ffffff',
                                correctLevel: layui.qrcode.CorrectLevel.L
                            };
                            return new layui.qrcode(this, defaultParams);
                        });
                    }
                });
                return false;
            case 'weibo':
                var url = 'http://service.weibo.com/share/share.php?url=' + share.url + '&title=%23芦虎导航%23 %23好站推荐%23 ' + share.title + '&appkey=3001084155&pic=' + share.pic,
                    w = 650,
                    h = 490;
                break;
            case 'qq':
                var url = 'http://connect.qq.com/widget/shareqq/index.html?url=' + share.url + '&showcount=0&desc=&summary=' + share.desc + '&title=' + share.title + '&site=www.bldhw.com&pics=' + share.pic + '&style=203&width=19&height=22',
                    w = 750,
                    h = 650;
                break;
            case 'qzone':
                var url = 'https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?to=qzone&url=' + share.url + '&title=' + share.title + '&summary=' + share.desc,
                    w = 650,
                    h = 490;
                break;
            case 'douban':
                var url = 'https://www.douban.com/share/service?image=' + share.pic + '&href=' + share.url + '&name=' + share.title,
                    w = 750,
                    h = 610;
                break;
            case 'huaban':
                var url = 'https://huaban.com/bookmarklet/?url=' + share.url + '&title=' + share.title + '&media=' + share.pic,
                    w = 710,
                    h = 560;
                break;
            case 'collect':
                try {
                    window.external.addFavorite(share.url, share.title);
                } catch (e) {
                    try {
                        window.sidebar.addPanel(share.title, share.url, '');
                    } catch (e) {
                        layer.msg("请按 Ctrl+D 键添加到收藏夹", {
                            time: 2000
                        });
                    }
                }
                return false;
            case 'print':
                window.print();
                return false;
        }

        var openTop = (window.screen.height - 30 - h) / 2,
            openLeft = (window.screen.width - 10 - w) / 2;
        window.open(url, "newwindow", "height=" + h + ", width=" + w + ", top=" + openTop + ",left=" + openLeft + ", toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no")
    })


本文永久地址:http://www.huanghaiping.com/article/94.html
本文出自 黄海平博客 ,转载时请注明出处及相应链接。

发表我的评论
  

网友最新评论 (1)

  1. 推荐一个仓鼠博客:https://www.shuvet.com
    小仓医2023-02-27 回复
返回顶部