-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathindex.html
376 lines (322 loc) · 13.9 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>WeChat</title>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<style type="text/css">
button {
border-right: #7b9ebd 1px solid;
padding-right: 2px;
border-top: #7b9ebd 1px solid;
padding-left: 2px;
font-size: 12px;
filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#ffffff, EndColorStr=#cecfde);
border-left: #7b9ebd 1px solid;
cursor: hand;
color: black;
padding-top: 2px;
border-bottom: #7b9ebd 1px solid;
padding: 10px 20px;
margin: 5px 10px;
}
a {
text-decoration: underline;
}
</style>
</head>
<body>
<p>
分享到朋友圈、分享给朋友
</p>
<button id="btnScan">
扫一扫
</button>
<button id="btnLocation">
获取地理位置
</button>
<button id="btnOpenLocation">
打开地理位置
</button>
<button id="btnNetwork">
获取网络
</button>
<button id="btnYC">
隐藏右上角按钮
</button>
<button id="btnXS">
显示右上角按钮
</button>
<button id="btnGB">
关闭页面
</button>
<button id="btnAddCard">
添加卡券
</button>
<button id="btnCreateCard">
创建卡券
</button>
<button id="btnVibrate">
点击震动
</button>
<button id="btnCreateCardQR">
创建卡券二维码
</button>
<button id="btnChooseImg">
选择图片
</button>
<button id="btnUploadImage">上传图片</button>
<button id="btnChooseWXPay">支付</button>
<button id="cc">
<a href="d.html">跳转</a>
</button>
<button id="tt">
<a>蓝牙111111111111111</a>
</button>
<p id="result">
</p>
<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
<script src="static/script/Jquery.WeChat.2.0.0.js" type="text/javascript"></script>
<script src="static/script/vconsole.min.js" type="text/javascript"></script>
<script type="text/javascript">
var vConsole = new VConsole();
async function Init() {
var res = { "APPID": "wxc46c96addcb23ab9", "TIMESTAMP": "1448938941", "NONCESTR": "k4DIrgjFCvQ2xRRE", "SIGNATURE": "41e483e544126d13b8c52d38fa0dcbe0d2a2b27e" };
var cardid;
var wechatManage = await $.WeChart({
api: 'http://dmapi.yesno.com.cn/api/wechat/GetWxInfoAndSign',
data: {
facid: '00000',
typenum: '2',
}
});
// var wechatManage = await $.WeChart({
// appId: res && res.APPID,
// timestamp: res && res.TIMESTAMP,
// nonceStr: res && res.NONCESTR,
// signature: res && res.SIGNATURE,
// access_token: res && res.ACCESS_TOKEN
// });
wechatManage.InitWeChat({
menu_share_timeline: true,
menu_share_appMessage: true,
menu_share_openWithSafari: true,
menu_share_qq: true,
menu_share_weiboApp: true,
menu_share_QZone: true
});
wechatManage.Forword({
forword_title: 'KAKAK',
forword_link: 'http://www.baidu.com'
}, function (res) {
$("#result").html("分享成功:" + JSON.stringify(res));
alert('分享成功')
}, function (res) {
alert('取消分享')
});
$("#btnScan").click(function () {
$.Scan(function (res) {
$("#result").html("扫描结果:" + res);
});
});
let l = {};
$("#btnLocation").click(function () {
wechatManage.GetLocation(function (res) {
$("#result").html("获取位置:" + JSON.stringify(res));
l = res;
localStorage.setItem("location", JSON.stringify(res))
});
});
$("#tt").click(function () {
$.onSearchBeacons(function (c) {
alert(c);
});
});
$("#btnOpenLocation").click(function () {
wechatManage.OpenLocation({ ...l, infoUrl: 'http://baidu.com' });
});
$("#btnNetwork").click(function () {
wechatManage.GetNetWorkType(function (res) {
$("#result").html("获取网络:" + JSON.stringify(res));
});
});
wechatManage.ForwordToFriend({
forword_title: 'KAKAK',
forword_link: 'http://www.baidu.com'
}, function (res) {
$("#result").html("分享给朋友:" + JSON.stringify(res));
}, function (res) {
$("#result").html("取消分享给朋友:" + JSON.stringify(res));
});
wechatManage.ShareQQ({
forword_title: 'KAKAK',
forword_link: 'http://www.baidu.com'
}, function (res) {
$("#result").html("分享QQ:" + JSON.stringify(res));
}, function (res) {
$("#result").html("取消分享QQ:" + JSON.stringify(res));
});
wechatManage.ShareWeibo({
forword_title: 'KAKAK',
forword_link: 'http://www.baidu.com'
}, function (res) {
$("#result").html("分享到微博:" + JSON.stringify(res));
}, function (res) {
$("#result").html("取消分享到微博:" + JSON.stringify(res));
});
wechatManage.ShareQZone({
forword_title: 'KAKAK',
forword_link: 'http://www.baidu.com'
}, function (res) {
$("#result").html("分享到QQ空间:" + JSON.stringify(res));
}, function (res) {
$("#result").html("取消分享到QQ空间:" + JSON.stringify(res));
});
$("#btnYC").click(function () {
wechatManage.HideOptionMenu();
});
$("#btnXS").click(function () {
wechatManage.ShowOptionMenu();
});
$("#btnGB").click(function () {
wechatManage.CloseWindow();
});
var c, s;
//1、创建卡券(卡券创建成功的同时获取签名)
$("#btnCreateCard").click(function () {
var data = {
"card": {
"card_type": "GROUPON",
"groupon": {
"base_info": {
"logo_url": "http://i2.s1.dpfile.com/pc/mc/6758d752ef693239c5976837311b9c53(450c280)/thumb.jpg",
"brand_name": "赤坂亭",
"code_type": "CODE_TYPE_TEXT",
"title": "200元赤坂亭现金券",
"sub_title": "周末狂欢必备",
"color": "Color010",
"notice": "使用时向服务员出示此券",
"service_phone": "020-10100011",
"description": "关于吃饭这件事,高档的食材、优雅的环境、精致的摆盘固然是锦上添花,但最要紧的还是一份对于食物的用心,吃的是一份温暖的人情味。818魔都那些走心又走胃的美食店,从食物里感受一份真诚,给你一段难忘的回忆。",
"date_info": {
"type": "DATE_TYPE_FIX_TIME_RANGE",
"begin_timestamp": 1476096689,
"end_timestamp": 1479392689
},
"sku": {
"quantity": 1
},
"get_limit": 1,
"use_custom_code": false,
"bind_openid": false,
"can_share": false,
"can_give_friend": false,
"location_id_list": [
123,
12321,
345345
],
"custom_url_name": "立即使用",
"custom_url": "http://www.dianping.com/search/keyword/1/0_%E8%B5%A4%E5%9D%82%E4%BA%AD",
"custom_url_sub_title": "赤坂亭",
"promotion_url_name": "更多优惠",
"promotion_url": "http://t.dianping.com/shanghai",
"source": "大众点评"
},
"deal_detail": "您在消费时,出示打印的团购券序列号凭证或团购券序列号短信即可。商户会验证的。无论您选择哪种方式,每个团购券序列号只能使用一次。"
}
}
};
wechatManage.CreateCard({
api: 'http://dmapi.yesno.com.cn/api/wechat/CreateWX_Card',
data: data
}, function (result, errorcode, cardid) {
if (errorcode === 0) {
c = cardid;
localStorage.setItem("cardid", cardid);
alert('ok')
} else {
alert(result.errmsg);
}
wechatManage.GetWxCardSignature({
api: 'http://dmapi.yesno.com.cn/api/wechat/GetWxInfoAndSign',
cardid: localStorage.getItem("cardid")
}, function (result, Signature_api_ticket) {
localStorage.setItem("Signature_api_ticket", Signature_api_ticket);
console.log(s);
});
});
});
$("#btnAddCard").click(function () {
wechatManage.AddCard({
cardid: localStorage.getItem("cardid"),
nonceStr: '',
timestamp: '',
signature: ''
}, function (res, cardlist) {
alert(JSON.parse(cardlist))
});
});
//创建卡券二维码(也需要cardid)
$("#btnCreateCardQR").click(function () {
var data = {
"action_name": "QR_CARD",
"expire_seconds": 1800,
"action_info": {
"card": {
"card_id": localStorage.getItem("cardid"),
"code": "",
"openid": "",
"is_unique_code": false,
"outer_id": 1
}
}
};
wechatManage.CreateCardQR({
api: 'http://dmapi.yesno.com.cn/api/wechat/CreateWX_CardQR',
data: {
'Access_Token': '',
'Data': { 'DataInfo': JSON.stringify(data) }
}
}, function (result, errorcode, qrcode_url) {
var img = '<img src="' + qrcode_url + '" >';
alert(errorcode);
$("#result").html(img);
});
});
$("#btnChooseImg").click(function () {
wechatManage.ChooseImg(function (res, localIds) {
localStorage.setItem("localIds", localIds);
$("#result").html("选择图片:" + JSON.stringify(res));
});
});
$("#btnUploadImage").click(function () {
wechatManage.UploadImage(localStorage.getItem("localIds"), function (res, serverId) {
$("#result").html("上传图片:" + JSON.stringify(res));
});
});
$("#btnChooseWXPay").click(function () {
wechatManage.ChooseWXPay({
timestamp: '', // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
nonceStr: '', // 支付签名随机串,不长于 32 位
package: '', // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=***)
signType: 'SHA1', // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
paySign: '' // 支付签名
}, function (res) {
$("#result").html("微信支付:" + JSON.stringify(res));
});
});
}
Init();
</script>
</body>
</html>