1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**********微信分享**************/
var wxShare = function(){
var Config = {
title : $('meta[itemprop="name"]').attr('content'),
desc : $('meta[itemprop="description"]').attr('content'),
imgUrl : $('meta[itemprop="image"]').attr('content'),
surl : location.href.split('#')[0],
successFn : function(){}
}
var FunInit = function(){
if(!(/msie [6/7/8/9]/i.test(navigator.userAgent))){
var url = location.href.split('#')[0];
var parameter = window.location.search;
url = encodeURIComponent(url);
$.ajax({
type: "get",
url: "//wx.acadsoc.com.cn/share.aspx?url=" + url, //替换网址,xxx根据自己jssdk文件位置修改
dataType: "jsonp",
jsonp: "callback",
jsonpCallback: "success_jsonpCallback",
success: function (data) {
wx.config({
appId: data.appId,
timestamp: data.timestamp,
nonceStr: data.nonceStr,
signature: data.signature,
jsApiList: [
"onMenuShareTimeline", //分享给好友
"onMenuShareAppMessage", //分享到朋友圈
"onMenuShareQQ", //分享到QQ
"onMenuShareWeibo" //分享到微博
]
});
},
error: function (data) {
//alert("连接失败!");
console.log("连接失败!");
}
});
wx.ready(function () {
var shareData = {
title: Config.title,
desc: Config.desc, //这里请特别注意是要去除html
link: Config.surl,
imgUrl: Config.imgUrl,
success: function () {
//alert("分享成功");
Config.successFn();
if (typeof Clickshard != 'undefined' && Clickshard instanceof Function) {
Clickshard("试课报告", Config.desc, "右上角", "", $("title").text());
}
},
cancel: function () {
//alert("分享取消");
}
};
wx.onMenuShareAppMessage(shareData);
wx.onMenuShareTimeline(shareData);
wx.onMenuShareQQ(shareData);
wx.onMenuShareWeibo(shareData);
});
//console.log(location.href.split('#')[0]);
}
}
return {
init : function(option){
Config = $.extend(true, Config, option);
FunInit();
}
}
}();