This repository has been archived by the owner on Feb 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
911 lines (776 loc) · 21.5 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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1.0, maximum-scale=1.0" />
<title>TTang·blog</title>
<style type="text/css">
body {
margin: 0;
padding: 0;
}
p {
line-height: 1.4em;
}
img {
width: 300px;
}
header {
z-index: 100;
position: fixed;
top: 0;
width: 100%;
height: 60px;
background-color: #2196F3;
color: white;
}
.boxShadow {
box-shadow: 0px 5px 5px -4px gray;
}
.rightBoxShadow {
/*box-shadow: 0px 5px -5px 4px gray; */
}
ul {
/*border-right: solid 1px black;*/
/*overflow: hidden;*/
margin-top: 0;
margin-bottom: 0;
}
.time {
color: gray;
font-size: 0.7em;
padding-left: 30px;
}
#blogTitle li {
border-bottom: dashed 1px #90CAF9;
padding: 15px 10px 15px 10px;
transition: all 0.2s linear;
}
#blogTitle li:hover {
cursor:pointer;
background: #2196F3;
color: white;
}
#blogTitle{
border-right: solid 5px #90CAF9;
background-color: white;
z-index: 100;
height: 100%;
position: fixed;
/*position: fixed;*/
overflow-y: scroll;
width: 275px;
/*display: block;*/
left: 0px;
top: 60px;
padding-top: 15px;
/*margin: 20px 0px;*/
transition: all 0.2s linear;
}
#blogContent{
padding: 30px 20px 20px 50px;
/*padding-left: 50px;*/
margin-top: 60px;
margin-left: 350px;
margin-right: 50px;
transition: all 0.2s linear;
}
.read {
width: auto;
height: 50px;
}
#messages {
margin-top: 50px;
}
#list-icon {
padding-top: 15px;
margin-left: 15px;
text-align: center;
left: 20px;
float: left;
display: none;
}
#list-icon:hover {
cursor: pointer;
}
.icons {
height: 43px;
width: 50px;
}
.icon {
display: inline-block;
width: 2em;
height: 1.8em;
fill: #fff;
/*fill: currentColor;*/
}
.thumb-icon {
fill: #341414;
}
.thumb {
float: left;
width: 60px;
text-align: center;
height: 50px;
padding-top: 7px;
padding-bottom: 3px;
border-radius: 50%;
border: solid 1px black;
margin: 10px;
}
.thumb:hover {
cursor: pointer;
}
.thumb>span {
/*height: 40px;*/
font-size: 0.5em;
/*background-color: red;*/
}
#commit {
max-width: 100%;
min-width: 100%;
height: 80px;
}
#commitBtn {
float: right;
}
#msgs, #commitContainer {
margin: 20px 10px 20px 0;
}
#msgs {
border-bottom: solid 1px black;
}
#commitContainer {
margin-bottom: 60px;
}
.mesCell {
width: inherit;
padding: 10px 0;
min-height: 30px;
border-top: solid 1px black;
}
.cellMark {
float: left;
text-align: center;
color: #fff;
font-size: 1em;
border-radius: 20px;
padding-top: 12px;
height: 28px;
width: 40px;
background-color: #009688;
}
.cellContent {
margin-left: 60px;
min-height: 30px;
width: auto;
}
.cellTime {
margin-left: 20px;
font-size: 0.4em;
color: gray;
}
.btn {
margin: 5px 15px;
width: 100px;
height: 30px;
text-align: center;
padding-top: 10px;
background-color: #2196F3;
color: white;
border-radius: 20px;
transition: all 0.2s linear;
}
.btn:hover {
cursor: pointer;
box-shadow:0 0 1px 1px gray,
}
#about, #stay {
font-weight: 900;
font-size: 1.3em;
float: right;
/*position: fixed;*/
padding: 20px 10px 15px 10px;
color: white;
/*left: 10px;*/
}
#stay {
padding: 27px 15px 15px 10px;
font-weight: 100;
font-size: 0.6em;
}
#about:hover {
cursor: pointer;
border-bottom: solid 5px white;
}
.meImage {
width: 180px;
height: 180px;
border-radius: 50%;
border: solid 3px #2196F3 ;
}
blockquote {
margin-left: 15px;
padding: 1px 10px;
border-left: lightgray solid 5px;
color: gray;
}
#qrcodeC {
display: block;
float: right;
width:100px;
height:100px;
margin-top:-15px;
}
#qrcodeC img {
width: 100px;
}
@media screen and (max-width: 600px){
#qrcodeC {
display: none;
}
#list-icon {
display: block;
}
#blogTitle{
left: -350px;
position: absolute;
/**/
}
#blogContent{
/*padding-left: 0px;*/
margin-left: 0px;
margin-right: 0px;
padding: 10px;
/*display:none;*/
}
/*#commit {
max-width: 90%;
min-width: 90%;
}*/
}
@media screen and (max-width: 350px){
img {
width: 90%;
}
}
</style>
<style type="text/css">
.base {
height: 9em;
left: 50%;
margin: -7.5em;
padding: 3em;
position: relative;
margin-top: 20%;
width: 9em;
transform: rotateX(45deg) rotateZ(45deg);
transform-style: preserve-3d;
}
.cube,
.cube:after,
.cube:before {
content: '';
float: left;
height: 3em;
position: absolute;
width: 3em;
}
/* Top */
.cube {
background-color: #05afd1;
position: relative;
transform: translateZ(3em);
transform-style: preserve-3d;
transition: .25s;
box-shadow: 13em 13em 1.5em rgba(0, 0, 0, 0.1);
animation: anim 1s infinite;
}
.cube:after {
background-color: #049dbc;
transform: rotateX(-90deg) translateY(3em);
transform-origin: 100% 100%;
}
.cube:before {
background-color: #048ca7;
transform: rotateY(90deg) translateX(3em);
transform-origin: 100% 0;
}
.cube:nth-child(1) {
animation-delay: 0.05s;
}
.cube:nth-child(2) {
animation-delay: 0.1s;
}
.cube:nth-child(3) {
animation-delay: 0.15s;
}
.cube:nth-child(4) {
animation-delay: 0.2s;
}
.cube:nth-child(5) {
animation-delay: 0.25s;
}
.cube:nth-child(6) {
animation-delay: 0.3s;
}
.cube:nth-child(7) {
animation-delay: 0.35s;
}
.cube:nth-child(8) {
animation-delay: 0.4s;
}
.cube:nth-child(9) {
animation-delay: 0.45s;
}
@keyframes anim {
50% {
transform: translateZ(0.5em);
}
}
</style>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.0.0/styles/monokai-sublime.min.css">
<!-- <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.0.0/styles/monokai.min.css"> -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.5/marked.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.0.0/highlight.min.js"></script>
</head>
<body class="">
<svg style="position: absolute; width: 0; height: 0;" width="0" height="0" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<symbol id="icon-list" viewBox="0 0 1024 1024">
<title>list</title>
<path class="path1" d="M0 0h256v256h-256zM384 64h640v128h-640zM0 384h256v256h-256zM384 448h640v128h-640zM0 768h256v256h-256zM384 832h640v128h-640z"></path>
</symbol>
<symbol id="icon-thumb_down" viewBox="0 0 1024 1024">
<title>thumb_down</title>
<path class="path1" d="M810 128h172v512h-172v-512zM640 128q34 0 60 26t26 60v426q0 34-26 60l-280 282-46-46q-18-18-18-44v-14l42-196h-270q-34 0-60-25t-26-59l2-4h-2v-82q0-16 6-32l130-300q20-52 78-52h384z"></path>
</symbol>
<symbol id="icon-thumb_up" viewBox="0 0 1024 1024">
<title>thumb_up</title>
<path class="path1" d="M982 426l-2 4h2v82q0 16-6 32l-130 300q-20 52-78 52h-384q-34 0-60-26t-26-60v-426q0-34 26-60l280-282 46 46q18 18 18 44v14l-42 196h270q34 0 60 25t26 59zM42 896v-512h172v512h-172z"></path>
</symbol>
</defs>
</svg>
<header class="boxShadow">
<div class="icons" id="list-icon" onclick="showList()">
<svg class="icon icon-list"><use xlink:href="#icon-list"></use></svg>
</div>
<div id="about" onclick="about()">
About
</div>
<div id="stay" >
Stay hungry, Stay foolish
</div>
</header>
<div id="blogContent" onclick="hiddenList()">
</div>
<!--
<button id="onMenuShareTimeline">onMenuShareTimeline</button>
<button id="onMenuShareAppMessage">onMenuShareAppMessage</button>
-->
<ul id="blogTitle" class="rightBoxShadow">
</ul>
<!--二维码-->
<script type="text/javascript" src="http://7o4yzj.com1.z0.glb.clouddn.com/qrcode.min.js"></script>
<!--weixin-->
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript">
window.loading = "<div class='base'><div class='cube'></div><div class='cube'></div><div class='cube'></div><div class='cube'></div><div class='cube'></div><div class='cube'></div><div class='cube'></div><div class='cube'></div><div class='cube'></div></div>"
</script>
<script type="text/template" id="messagesTemplate">
<div class="read">
<div class="thumb" id="thumbup" onclick="thumbUp(this, event)">
<div>
<svg class="icon thumb-icon"><use xlink:href="#icon-thumb_up"></use></svg>
</div>
<span>3</span>
</div>
<div class="thumb" id="thumbdown" onclick="thumbDown(this, event)">
<div>
<svg class="icon thumb-icon"><use xlink:href="#icon-thumb_down"></use></svg>
</div>
<span>4</span>
</div>
<div id="qrcodeC">
<div id="qrcode"></div>
<div> [微信扫一扫]</div>
</div>
</div>
<div id="messages">
<span style="font-size:1.3em; color:#009688">纠错或建议:</span>
<span style="font-size:0.6em; color:#80CBC4">支持markdown </span>
<span style="font-size:0.6em;">
<a href="http://www.ituring.com.cn/article/775" target="_blank"> markdown?</a>
</span>
<span style="font-size:0.6em; color:#80CBC4"> 更多建议和交流,请加QQ群:521401181</span>
<div id="commitContainer">
<textarea id="commit"></textarea>
<div id="commitBtn" class="btn" onclick="submit()">提交</div>
</div>
<div id="msgs">
{{msgs}}
</div>
</div>
</script>
<script type="text/template" id="messagesCell">
<div class="mesCell">
<div class="cellMark">{{i}}</div>
<span class="cellTime">{{commentTime}}</span>
<div class="cellContent">{{message}}</div>
</div>
</script>
<script type="text/javascript">
function showList () {
if (blogTitle.style.left === "0px") {
blogTitle.style.left = "-350px";
// blogContent.style.display = "block";
blogContent.style.position = ""
}else {
blogTitle.style.left = "0px";
// blogContent.style.display = "none";
blogContent.style.position = "fixed"
}
}
function hiddenList () {
var w = window,
d = document,
e = d.documentElement,
g = d.getElementsByTagName('body')[0],
x = w.innerWidth || e.clientWidth || g.clientWidth,
y = w.innerHeight|| e.clientHeight|| g.clientHeight;
if (x <= 600) {
blogTitle.style.left = "-350px";
blogContent.style.position = ""
}
}
</script>
<script type="text/javascript">
(function () {
function makeRequest(url, callback, method, postBody) {
var url = "ttblog"+url
var method = method || "GET"
var body = postBody || ""
var bodyStr = body ? JSON.stringify(body) : "";
var httpRequest = ""
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
httpRequest = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
try {
httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
}
}
}
if (!httpRequest) {
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState === 4) {
if (httpRequest.status === 200) {
callback(httpRequest.responseText)
} else {
alert('There was a problem with the request.');
}
}
}
httpRequest.open(method, url);
httpRequest.setRequestHeader('Content-Type', 'application/json');
httpRequest.send(bodyStr);
}
window.makeRequest = makeRequest
})()
</script>
<script type="text/javascript">
function thumbUp(elem, e) {
var id = location.hash.replace("#", "");
makeRequest("/blog/"+id+"/good", function (data) {
data = JSON.parse(data)
if (data.ok === 1) {
var before = Number(elem.querySelector("span").innerHTML);
elem.querySelector("span").innerHTML = before + 1
}
})
}
function thumbDown(elem, e) {
var id = location.hash.replace("#", "");
makeRequest("/blog/"+id+"/bad", function (data) {
data = JSON.parse(data)
if (data.ok === 1) {
var before = Number(elem.querySelector("span").innerHTML);
elem.querySelector("span").innerHTML = before + 1
}
})
alert("还请留下您的建议或意见,不然就是‘耍流氓’了。");
// elem.querySelector("span").innerHTML = i
}
(function () {
function regComment (comment) {
var msgContent = comment;
var domReg = /[\s\S]*\`\`\`([\r\n]*|[\n]*)[\s\S]*(<script[\s\S]*>|<div[\s\S]*>)[\s\S]*(<\/script>|<\/div>)[\s\S]*[\r\n]*|[\n]*\`\`\`[\s\S]*/;
var scriptReg = /[\s\S]*(<script[\s\S]*>|<div[\s\S]*>)[\s\S]*/;
if (!domReg.test(msgContent) && scriptReg.test(msgContent)) {
alert("请输入使用合法的markdown代码块(```)");
return false
}
return true
}
window.submit = submit;
function submit () {
var comment = commit.value;
if (comment === "") {
alert("不能是空的");
return;
}
if (!regComment(comment)) {
return;
};
var mesValue = marked(comment);
var submitBody = {
id: location.hash.replace("#", ""),
comment: comment
}
makeRequest("/blog/comment", submitDone, "POST", submitBody);
function submitDone (data) {
data = JSON.parse(data);
if (data && data.err) {
alert(data.err);
return;
}
commit.value = "";
var time = data.time;
var mesCell = messagesCell.innerHTML;
mesCell = mesCell.replace("{{message}}", mesValue)
.replace("{{i}}", msgs.children.length + 1)
.replace("{{commentTime}}", time);
msgs.innerHTML = mesCell + msgs.innerHTML;
var codeArr = msgs.getElementsByTagName("code");
for (var i = 0; i < codeArr.length; i++) {
var codeDom = codeArr[i];
hljs.highlightBlock(codeDom);
}
}
}
})()
function highlightCode () {
var codeArr = document.getElementsByTagName("code");
for (var i = 0; i < codeArr.length; i++) {
var codeDom = codeArr[i];
hljs.highlightBlock(codeDom);
}
}
function requestTitle () {
var liCell = '<li id={{id}} onclick="requestBlog(this, event)" >{{title}}</li>'
makeRequest("/blogs", function blogs (data) {
data = JSON.parse(data);
var str = "";
for (var i = 0; i < data.length; i++) {
var item = data[i];
var cell = liCell;
cell = cell.replace("{{id}}", item._id)
.replace("{{title}}", item.title)
str += cell;
};
blogTitle.innerHTML = str
})
}
function loadPreword () {
blogContent.innerHTML = window.loading;
makeRequest("/preword", function (data) {
blogContent.innerHTML = marked(data);
highlightCode();
})
}
function requestBlog (elem, event) {
hiddenList()
var id = elem.getAttribute("id");
requestBlogA(id);
}
function requestBlogA (id) {
location.hash = id;
blogContent.innerHTML = window.loading;
makeRequest("/blog/"+id, function blog (data) {
data = JSON.parse(data);
var weixinConfig = data.weixinConfig;
var content = data.content;
var comments = data.comments;
var read = data.read;
var good = data.good;
var bad = data.bad;
console.log(weixinConfig);
wx.config({
debug: true,
appId: 'wx10ee54e66df3785d',
timestamp: weixinConfig.timestamp,
nonceStr: weixinConfig.nonceStr,
signature: weixinConfig.signature,
jsApiList: [
'checkJsApi',
'onMenuShareTimeline',
'onMenuShareAppMessage'
]
});
var time = data.time || new Date();
content = marked(content);
content = content.replace("{{time}}",
'<div class="time"><i>'+time+'</i> <i>阅读量:'+read+'</i></div>');
comments = comments || []
var messagesHtml = messagesTemplate.innerHTML; //str
var msgs = ""
for (var i = comments.length - 1 ; i >= 0; i--) {
var msgCell = messagesCell.innerHTML;
var msgContent = comments[i].comment;
var msgTime = comments[i].time;
// msgContent = regComment(msgContent);
msgCell = msgCell.replace("{{message}}", marked(msgContent))
.replace("{{i}}", i+1)
.replace("{{commentTime}}", msgTime);
msgs += msgCell;
};
messagesHtml = messagesHtml.replace("{{msgs}}", msgs);
blogContent.innerHTML = content + messagesHtml;
thumbup.querySelector("span").innerHTML = good;
thumbdown.querySelector("span").innerHTML = bad;
highlightCode();
// 二维码
var qrcode = new QRCode(document.getElementById("qrcode"), {
width : 100,
height : 100
});
function makeCode () {
var value = location.href;
qrcode.makeCode(value);
}
makeCode();
});
}
function about () {
location.hash = "about";
blogContent.innerHTML = window.loading;
makeRequest("/about", function (data) {
blogContent.innerHTML = marked(data);
highlightCode();
});
}
</script>
<script type="text/javascript">
function loadHash () {
var hash = location.hash;
hash = hash.replace("#", "");
if (hash === "about") {
about()
}else if (hash.length === 24) {
requestBlogA(hash);
}else {
// location.hash = "preword";
loadPreword();
}
}
function locationHashChanged() {
loadHash()
}
window.onhashchange = locationHashChanged;
window.onload = function () {
blogContent.innerHTML = window.loading;
requestTitle();
if (location.hash) {
loadHash();
}else {
location.hash = "preword";
}
var w = window,
d = document,
e = d.documentElement,
g = d.getElementsByTagName('body')[0],
x = w.innerWidth || e.clientWidth || g.clientWidth,
y = w.innerHeight|| e.clientHeight|| g.clientHeight;
blogTitle.style.height = (y - 75)+"px"
}
window.onresize = function(event) {
var w = window,
d = document,
e = d.documentElement,
g = d.getElementsByTagName('body')[0],
x = w.innerWidth || e.clientWidth || g.clientWidth,
y = w.innerHeight|| e.clientHeight|| g.clientHeight;
blogTitle.style.height = (y - 65)+"px"
if (x > 600) {
blogTitle.style.left = ""
blogContent.style.display = ""
}
};
</script>
<script type="text/javascript">
wx.ready(function () {
// 1 判断当前版本是否支持指定 JS 接口,支持批量判断
alert("ready")
// document.querySelector('#checkJsApi').onclick = function () {
// wx.checkJsApi({
// jsApiList: [
// 'getNetworkType',
// 'previewImage'
// ],
// success: function (res) {
// alert(JSON.stringify(res));
// },
// });
// };
// 2. 分享接口
// 2.1 监听“分享给朋友”,按钮点击、自定义分享内容及分享结果接口
// document.querySelector('#onMenuShareAppMessage').onclick = function () {
wx.onMenuShareAppMessage({
title: '互联网之子',
desc: '在长大的过程中,我才慢慢发现,我身边的所有事,别人跟我说的所有事,那些所谓本来如此,注定如此的事,它们其实没有非得如此,事情是可以改变的。更重要的是,有些事既然错了,那就该做出改变。',
link: 'http://movie.douban.com/subject/25785114/',
imgUrl: 'http://demo.open.weixin.qq.com/jssdk/images/p2166127561.jpg',
trigger: function (res) {
// 不要尝试在trigger中使用ajax异步请求修改本次分享的内容,因为客户端分享操作是一个同步操作,这时候使用ajax的回包会还没有返回
alert('用户点击发送给朋友');
},
success: function (res) {
alert('已分享');
},
cancel: function (res) {
alert('已取消');
},
fail: function (res) {
alert(JSON.stringify(res));
}
});
// alert('已注册获取“发送给朋友”状态事件');
//};
// 2.2 监听“分享到朋友圈”按钮点击、自定义分享内容及分享结果接口
// document.querySelector('#onMenuShareTimeline').onclick = function () {
wx.onMenuShareTimeline({
title: '互联网之子',
link: 'http://movie.douban.com/subject/25785114/',
imgUrl: 'http://demo.open.weixin.qq.com/jssdk/images/p2166127561.jpg',
trigger: function (res) {
// 不要尝试在trigger中使用ajax异步请求修改本次分享的内容,因为客户端分享操作是一个同步操作,这时候使用ajax的回包会还没有返回
alert('用户点击分享到朋友圈');
},
success: function (res) {
alert('已分享');
},
cancel: function (res) {
alert('已取消');
},
fail: function (res) {
alert(JSON.stringify(res));
}
});
// alert('已注册获取“分享到朋友圈”状态事件');
// };
});
wx.error(function(res){
alert("error")
// config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
});
</script>
</body>
</html>