Rumah >hujung hadapan web >tutorial js >Javascript melaksanakan kemahiran sharing_javascript WeChat

Javascript melaksanakan kemahiran sharing_javascript WeChat

WBOY
WBOYasal
2016-05-16 16:24:541226semak imbas

Kod ini sangat mudah, saya tidak akan bercakap terlalu banyak karut di sini dan hanya memberikan kod sumber:

Salin kod Kod adalah seperti berikut:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
Laluan rentetan = request.getContextPath();
String basePath = request.getScheme() "://" request.getServerName() ":" request.getServerPort() laluan "/";
%>


 
   
    喝喝
   
   
       
   
   
   

var imgUrl = 'http://qqfood.tc.qq.com/meishio/16/4585bf7c-be04-420f-ac8a-2dba61a7561f/0';
var lineLink = 'http://life.qq.com/weixin/r/lottery/13826036970196242008#wechat_redirect';
var descContent = "万达狂欢节, 夺宝幸运星大抽奖活动开始啦!";
var shareTitle = '万达狂欢节';
var appid = 'wxc9937e3a66af6dc8';
fungsi kongsiRakan() {
    WeixinJSBridge.invoke('sendAppMessage',{
                            "appid": appid,
                            "img_url": imgUrl,
                            "img_width": "640",
                            "img_height": "640",
                            "pautan": pautan talian,
                            "desc": descContent,
                            "tajuk": kongsiTajuk
                            }, fungsi(res) {
                            _report('send_msg', res.err_msg);
                            })
}
function shareTimeline() {
    WeixinJSBridge.invoke('shareTimeline',{
                            "img_url": imgUrl,
                            "img_width": "640",
                            "img_height": "640",
                            "pautan": pautan talian,
                            "desc": descContent,
                            "tajuk": kongsiTajuk
                                                                                                                                                                                                                                                                                                                   _report('garis masa', res.err_msg);
                                                                                                                                                                                                       ); }
fungsi shareWeibo() {
WeixinJSBridge.invoke('shareWeibo',{
“kandungan”: descContent,
“url”: lineLink,
                                               }, fungsi {
_Laporan ('weibo', res.err_msg);                                                                                      }); }
// Apabila penyemak imbas terbina dalam WeChat melengkapkan permulaan dalaman, acara WeixinJSBridgeReady akan dicetuskan.
document.addEventListener('WeixinJSBridgeReady', fungsi onBridgeReady() {
                   // Hantar kepada rakan
WeixinJSBridge.on('menu:share:appmessage', function(argv){
              kongsi Rakan();
            });
// Kongsi ke Detik
WeixinJSBridge.on('menu:share:timeline', function(argv){
              kongsi Garis Masa();
            });
              // Kongsi ke Weibo
WeixinJSBridge.on('menu:share:weibo', function(argv){
              kongsiWeibo();
            });
         }, palsu);