The code is very simple, I won’t go into too much nonsense here and just provide the source code:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() "://" request.getServerName() ":" request.getServerPort() path "/";
%>
喝喝
<script><br>
var imgUrl = 'http://qqfood.tc.qq.com/meishio/16/4585bf7c-be04-420f-ac8a-2dba61a7561f/0';<br>
var lineLink = 'http://life.qq.com/weixin/r/lottery/13826036970196242008#wechat_redirect';<br>
var descContent = "万达狂欢节, 夺宝幸运星大抽奖活动开始啦!";<br>
var shareTitle = '万达狂欢节';<br>
var appid = 'wxc9937e3a66af6dc8';<br>
function shareFriend() {<br>
WeixinJSBridge.invoke('sendAppMessage',{<br>
"appid": appid,<br>
"img_url": imgUrl,<br>
"img_width": "640",<br>
"img_height": "640",<br>
"link": lineLink,<br>
"desc": descContent,<br>
"title": shareTitle<br>
}, function(res) {<br>
_report('send_msg', res.err_msg);<br>
})<br>
}<br>
function shareTimeline() {<br>
WeixinJSBridge.invoke('shareTimeline',{<br>
"img_url": imgUrl,<br>
"img_width": "640",<br>
"img_height": "640",<br>
"link": lineLink,<br>
"desc": descContent,<br>
"title": shareTitle<br> }, function(res) {<br>
_report('timeline', res.err_msg);<br>
});
}<br>
function shareWeibo() {<br>
WeixinJSBridge.invoke('shareWeibo',{<br>
“content”: descContent,<br>
“url”: lineLink,<br>
}, function(res) {<br>
_Report ('weibo', res.err_msg); <br>
});
}<br>
// When WeChat's built-in browser completes internal initialization, the WeixinJSBridgeReady event will be triggered. <br>
document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {<br>
// Send to friends <br>
WeixinJSBridge.on('menu:share:appmessage', function(argv){<br>
shareFriend();<br>
});<br>
// Share to Moments<br>
WeixinJSBridge.on('menu:share:timeline', function(argv){<br>
shareTimeline();<br>
});<br>
// Share to Weibo <br>
WeixinJSBridge.on('menu:share:weibo', function(argv){<br>
shareWeibo();<br>
});<br>
}, false);<br>
</script>