<div class="share" id="share">
<div class="share-box" id="share-box">
<a class="share-btn gwds_weixin" data-w="gwds_weixin" title="微信"> </a>
<a class="share-btn gwds_tsina" data-w="gwds_tsina" title="新浪微博"> </a>
<a data-w="gwds_qzone" class="share-btn gwds_qzone" title="QQ空间"> </a>
<a data-w="gwds_douban" class="share-btn gwds_douban" title="豆瓣网"> </a>
</div>
</div>
<script>
var title = "${data.title!''}";
var url = encodeURIComponent(window.location.href);
var list = {
'gwds_weixin': '/f/front/qrcode?url=' + url,
'gwds_tsina': 'http://service.weibo.com/share/share.php?url=' + url + "&title=" + title,
'gwds_qzone': 'https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=' + url + "&title=" + title,
'gwds_douban': 'https://www.douban.com/share/service?appkey=3&sharesource=weibo&title=' + title + '&url=' + url
}
$('.share-btn').on('click', function(){
var key = $(this).data('w');
window.open(list[key]);
return false
});
</script>
微信分享 需要生成二维码 使用微信打开分享
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ page session="false"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<link rel="icon" href="assets/img/v2/favicon.ico">
<title>xxx</title>
<style>
.code-box{
width: 262px; margin: 50px auto; border: 1px solid #ddd; padding: 10px
}
.code-box h5{margin: 0;}
.code-box p{font-size: 13px; line-height: 22px; margin: 0; color: #555;}
#div_div{width: 200px; height: 200px; margin: 20px auto}
</style>
</head>
<body>
<div class="code-box">
<h5>分享到微信</h5>
<div id="div_div">
<div id="qrcode"></div>
</div>
<p>用微信“扫一扫”,点击右上角分享按钮,<br>即可将网页分享给您的微信好友或朋友圈。</p>
</div>
<script src="/assets/js/jquery.min.js"></script>
<script src="/assets/js/qrcode.js" type="text/javascript"></script>
<script type="text/javascript">
var url='${pd.url}';
var qrcode = new QRCode("qrcode", {
text: url,
width: 200,
height: 200,
colorDark : "#000000",
colorLight : "#ffffff"
});
</script>
</body>
</html>