-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.html
executable file
·85 lines (79 loc) · 2.94 KB
/
index.html
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
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>大东方问卷调查</title>
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="renderer" content="webkit">
<link href="http://cdn.amazeui.org/amazeui/2.3.0/css/amazeui.min.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
</head>
<body>
WXSHARE
<script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js" type="text/javascript"></script>
<script src="http://cdn.amazeui.org/amazeui/2.3.0/js/amazeui.min.js" type="text/javascript"></script>
<script src="http://mhcdn.oss-cn-hangzhou.aliyuncs.com/js/WeixinApi.js" type="text/javascript"></script>
<script>
var signPackage;
$.ajax({
async: false,
type: "get",
url: "/Rest/Weixin/getJsSign?url=" + encodeURIComponent(location.href),
dataType: "json",
cache: false,
success: function (msg) {
var rtobj = (msg instanceof Object) ? msg : JSON.parse(msg);
signPackage = rtobj.data;
}
});
wx.config({
debug: true,
appId: signPackage.appid,
timestamp: signPackage.timestamp + "",
nonceStr: signPackage.noncestr,
signature: signPackage.signature,
jsApiList: [
'checkJsApi',
'onMenuShareTimeline',
'onMenuShareAppMessage'
]
});
wx.ready(function () {
// 初始化wx对象
WeixinApi.ready(wx);
// 微信分享的数据
var wxData = {
"imgUrl": "https://www.baidu.com/img/bdlogo.png",// 分享图标
"link": "http://www.iceinto.cn", //分享链接
"desc": "家有WX小鬼", //分享描述
"title": "家有WX小鬼" // 分享标题
};
// 分享的回调函数
var wxCallbacks = {
success: function () {
// 用户确认分享后执行的回调函数
alert("success");
},
cancel: function () {
// 用户取消分享后执行的回调函数
alert("cancel");
},
fail: function () {
//接口调用失败时执行的回调函数
},
complete: function () {
// 接口调用完成时执行的回调函数,无论成功或失败都会执行。
},
trigger: function () {
//监听Menu中的按钮点击时触发的方法,该方法仅支持Menu中的相关接口。
}
};
// 用户点开右上角popup菜单后,点击分享给好友,会执行下面这个代码
WeixinApi.shareToFriend(wxData, wxCallbacks);
// 点击分享到朋友圈,会执行下面这个代码
WeixinApi.shareToTimeline(wxData, wxCallbacks);
});
</script>
</body>
</html>