forked from sofish/wechat.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
68 lines (57 loc) · 1.79 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
<!doctype html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Wechat.js</title>
<link rel="stylesheet" href="http://typo.sofi.sh/typo.css"/>
<style>
body{padding:20px;}
pre{margin:0 -20px;padding:30px 20px;font-size:14px;border:none;line-height:1;}
code{color:#1a3;border:1px dashed #1a3;padding:1px 3px;}
.reval{float:right;}
</style>
</head>
<body class="typo">
<h1>Wechat.js</h1>
<p>
当前使用的网络是:<code id="network">...</code>。
用微信扫一扫下面的 url,然后分享到朋友圈:
</p>
<p><button onclick="toggle()">隐藏/显示分享按钮</button></p>
<p><img src="http://ww4.sinaimg.cn/large/61b90cbegw1eknqctwzbhj2097097jrx.jpg" alt="sofish/wechat.js"/></p>
<p>详细使用指南请看:<a href="http://github.com/sofish/wechat.js/#readme">说明文档</a>。</p>
<script src="wechat.js"></script>
<script>
// 导入的数据
var data = {
app: '',
img: function() {
return 'http://appled.cc/candy-theme-flat/images/share.jpg'
},
link: 'http://sofish.github.io/wechat.js/',
desc: '用于处理微信分享的等小功能的 js 库',
title: 'wechat.js'
};
var callback = function(res) {
alert(JSON.stringify(res));
};
// 查看用户当前网络
// TODO: 这返回的数据好恶心
wechat('network', function(res) {
document.getElementById('network').innerHTML = (res.err_msg.split(':')[1]);
});
// 分享
wechat('friend', data, callback); // 朋友
wechat('timeline', data, callback); // 朋友圈
wechat('weibo', data, callback); // 微博
//控制右上角菜单是否显示,防止敏感信息泄露
var show = true;
function toggle(){
var action = show ? 'hideOptionMenu' : 'showOptionMenu';
wechat(action);
show = !show;
}
</script>
</body>
</html>