弹框
<div class="zyl_zpjLi_3 clearfix" id="zyl_Li3">
<span class="share_posibtn">
<a href="javascript:void(0);" template-id="${data.id}">分享</a>
<div class="share_bbox" style="display: none;">
<!-- <h2 class="share_mobh2 clearfix">
<i class="fr"></i>
</h2> -->
<div class="share_mobimg">
<img id="weixinChart${data.id}" src="" alt="">
</div>
<p class="share_mobp">微信扫一扫查看本模板效果</p>
</div>
</span>
<span style="margin-left:86px;"><a href="javascript:;" onclick="deleteInvitationTemplate(this,'${data.id}','${data.userId}');">删除</a></span>
</div>
*悬浮弹框显示二维码
*/
$('.share_posibtn a').hover(function(){
$('.share_bbox').hide();
var temidid = $(this).attr('template-id');
var url = '/invitation/qrCode';
if(!temidid){
alert('系统故障,请稍后重试');
return false;
}
var WIDTH = 120;
var pcid = "#weixinChart"+temidid;
$(pcid)[0].src = url + '?templetId=' + temidid + '&width=' + WIDTH + '&height=' + WIDTH;
$(this).siblings('.share_bbox').show();
},function(){
$('.share_bbox').hide();
});
/**
* 生成二维码图片
*
* @param resp
* @param width
* @param height
*/
@RequestMapping("/qrCode")
public void makeQrCode(HttpServletResponse resp, Integer width, Integer height) {
resp.setHeader("Cache-Control", "no-store");
resp.setHeader("Pragma", "no-cache");
resp.setDateHeader("Expires", 0);
resp.setContentType("image/png");
int iWidth = (width == null ? 200 : width);
int iHeight = (height == null ? 200 : height);
Map<EncodeHintType, Object> hints = new HashMap<>();
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
hints.put(EncodeHintType.MARGIN, 0);
SessionUser user = getSessionUser();
String templetId = request.getParameter("templetId");
int userId = 0;
String url = "";
// 如果为空的话,就取默认模板
if (null == user) {
url = weixinUtils.getMoCiApi()+"/invitation/h5?templetId=1&userId=0";
} else {
userId = user.getUserId();
url = weixinUtils.getMoCiApi()+"/invitation/h5?templetId="
+ templetId + "&userId=" + userId;
}
BitMatrix bitMatrix = null;
try {
bitMatrix = new MultiFormatWriter().encode(url,
BarcodeFormat.QR_CODE, iWidth, iHeight, hints);
MatrixToImageWriter.writeToStream(bitMatrix, "png",
resp.getOutputStream());
} catch (Exception e) {
logger.error("生成二维码出错:" + e.getMessage());
}
}