分享

<!DOCTYPE html>
<html>
<head>
    <title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=2.0, user-scalable=no">
</head>
<body>
<button id="weixin_share_to_friend">
    分享到微信好友
</button>
<button id="weixin_share_to_timeline">
    分享到微信朋友圈
</button>
<button id="share_link">
    点击调分享
</button>
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
<script type="text/javascript">
share={
    'shareRead_link':"http://www.yongche.com/weixin/activity/2015060102/activity/2015/user-to-user/inviteguest.php?id=9chl533htsosow44",
    'shareRead_pics':"<{asset:images/app/i/user-to-user/wx_log.png}>",
    'shareRead_title':"专车券,送30太小气,领5折+70,才够爽!",
    'shareRead_content':"给好友发5折专车券+70元礼包,您的好友完成首单,您同样会获得5折专车券,多邀多赠!",
    'shareRead_sourceType':42,
    'titleBarShareButtonShow':1
    //1代表标题有分享文字;0代表没有
};
$('#weixin_share_to_friend').click(function(){
    ShareTools.shareThisPageToFriend();
});
$('#weixin_share_to_timeline').click(function(){
    ShareTools.shareThisPageToTimeline();
});
$('#share_link').click(function(){
    ShareTools.shareBase();
});
</script>
<script type="text/javascript">
     // 分享变量设置
    var _protocolLinkBase = "yongche://share?";
    var _protocolLinkFriend = "yongche://shareToFriend?";
    var _protocolLinkTimeline = "yongche://shareToTimeline?";
    // 分享地址
    // var shareRead_link = encodeURIComponent("http://www.yongche.com/mobile/weixin/3/index.php?round=2");
    var shareRead_link = encodeURIComponent(share['shareRead_link']);
    // 分享的图片
    var shareRead_pics = encodeURIComponent(share['shareRead_pics']);
    // 分享的标题
    //var shareRead_title = encodeURIComponent("我是魏浩哲,快与我同坐5折专车,Give me five!");
    var shareRead_title = encodeURIComponent(share['shareRead_title']);
    // 分享的内容
    //var shareRead_content = encodeURIComponent("给好友发5折专车券,您的好友完成首单,您同样会获得5折专车券。多邀多赠!");
    var shareRead_content = encodeURIComponent(share['shareRead_content']);
    var shareRead_sourceType = share['shareRead_sourceType'];
    ShareTools = {
        shareThisPageToFriend:function(){
            var _str = "link="+shareRead_link+"&pics="+shareRead_pics+"&title="+shareRead_title+"&content="+shareRead_content+"&sourceType="+shareRead_sourceType;
            var _tmpOpenLink = _protocolLinkFriend + _str;
            window.location.href = _tmpOpenLink;
        },
        shareThisPageToTimeline:function(){
            var _str = "link="+shareRead_link+"&pics="+shareRead_pics+"&title="+shareRead_title+"&content="+shareRead_content+"&sourceType="+shareRead_sourceType;
            var _tmpOpenLink = _protocolLinkTimeline + _str;
            window.location.href = _tmpOpenLink;
        },
        shareBase:function(){
            var _str = "link="+shareRead_link+"&pics="+shareRead_pics+"&title="+shareRead_title+"&content="+shareRead_content+"&sourceType="+shareRead_sourceType;
            var _tmpOpenLink = _protocolLinkBase + _str;
            window.location.href = _tmpOpenLink;
        }
    };
    if(share['titleBarShareButtonShow']==1){
        $("body").append('<iframe frameborder="0" style="display: none;" id="share_iframe"></iframe>');
         var _str = "link="+shareRead_link+"&pics="+shareRead_pics+"&title="+shareRead_title+"&content="+shareRead_content+"&sourceType="+shareRead_sourceType+"&from=iframe";
        var _tmpOpenLink = _protocolLinkBase + _str;
        document.getElementById("share_iframe").src = _tmpOpenLink;
    }
</script>
</body>
</html> 

转载于:https://www.cnblogs.com/xiaoleidiv/p/4587837.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值