• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
阳光Angel
博客园    首页    新随笔    联系   管理    订阅  订阅
分享
<!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> 
posted on 2015-06-19 10:19  xiaoleilei  阅读(156)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3