-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshare.html
559 lines (541 loc) · 24.3 KB
/
share.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>阳光大数据</title>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no, shrink-to-fit=no">
<link rel="stylesheet" href="./share.css">
</head>
<body id = 'node'>
<div id = "loading">
<div class="loading-box">
<div class="loading">
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
</div>
<p>正在获取阳光大数据...</p>
</div>
</div>
<div id = "searchBox">
<div class="search-box">
<h4 class="black">LEAD</h4>
<div class="search-input search-item">
<input type="text" class="black" placeholder="填写您的阳光帐号" id="searchValue">
</div>
<div class="search-button search-item clearfix">
<div class="button black fl" onclick="searchName()" id="searchButton">搜索</div>
<div class="button black fr" onclick="closeSearch()">取消</div>
</div>
<img src="./image/search-img.jpg" alt="">
</div>
</div>
<div id = 'noSearchBox'>
<div class="search-box noSearch-box">
<img src="./image/noSearch.jpg" alt="">
<p class="black">皮卡丘万分抱歉</p>
<p class="black">未能帮你找相应的用户数据</p>
<div class="item makeTable">
<div class="button black" onclick="openSearch(1);">
<p>制作我的</p>
<p>阳光大数据</p>
</div>
</div>
</div>
</div>
<!--<div id = 'showPay'>-->
<!--<div class="search-box noSearch-box">-->
<!--<img src="./image/showpay.jpg" alt="">-->
<!--<div class="item">-->
<!--<div class="button black">-->
<!--<p>长按二维码进行打赏</p>-->
<!--</div>-->
<!--<div class="button black">-->
<!--<p>关闭</p>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
<div id ="main">
<div id = "showShare">
<div class="item">
<div class="logo">
<img src="./image/lead-logo.png" alt="">
</div>
<h2 class="title-bj yellow-title" id="user">阳光公益报告</h2>
<div class="user-headpoirt" id ='userName'>
<img src="" alt="">
<p class="yellow p-text"></p>
</div>
<div class="html-padding" id = 'joinFirstInfo'>
<!--<p class="write p-html tl">Hi,亲爱的阳光er,</p>-->
<!--<p class="write p-html tl">欢迎进入阳光回忆之旅!</p>-->
<!--<p class="yellow p-html tl">2013年9月1日</p>-->
<!--<p class="write p-html tl">你注册了论坛,加入了阳光大家庭!</p>-->
<!--<p class="yellow p-html tr">2013年3月7日</p>-->
<!--<p class="write p-html tr">你参加了阳光的信任培训。</p>-->
<!--<p class="yellow p-html tr">孙铭、kkiwi、赠可以、heas</p>-->
<!--<p class="write p-html tr">等阳光er是你的同期生。</p>-->
</div>
</div>
<div class="item" id="firstInfo">
<!--<h2 class="title-bj yellow-title">公益活动报告</h2>-->
<!--<div class="html-padding">-->
<!--<p class="yellow p-html tr">崔各庄小学国学班</p>-->
<!--<p class="write p-html tr">是你服务的第一个项目点</p>-->
<!--</div>-->
<!--<div class="html-padding">-->
<!--<p class="yellow p-html tr">2013年9月1日</p>-->
<!--<p class="write p-html tr">你第一次登上讲台,成为主讲。</p>-->
<!--</div>-->
</div>
<div class="item" id="countNumber">
<!--<h2 class="title-bj yellow-title">截止目前</h2>-->
<!--<p class="write p-text">您参与的阳光公益活动</p>-->
<!--<p class="yellow p-text">400次</p>-->
<!--<ul class="list html-padding">-->
<!--<li class="yellow">-->
<!--<p class="p-html-title">周末课堂</p>-->
<!--<img src="" alt="">-->
<!--<p>236次</p>-->
<!--</li>-->
<!--<li class="yellow">-->
<!--<p class="p-html-title">周末课堂</p>-->
<!--<img src="" alt="">-->
<!--<p>236次</p>-->
<!--</li>-->
<!--<li class="yellow">-->
<!--<p class="p-html-title">周末课堂</p>-->
<!--<img src="" alt="">-->
<!--<p>236次</p>-->
<!--</li>-->
<!--<li class="yellow">-->
<!--<p class="p-html-title">周末课堂</p>-->
<!--<img src="" alt="">-->
<!--<p>236次</p>-->
<!--</li>-->
<!--<li class="yellow">-->
<!--<p class="p-html-title">周末课堂</p>-->
<!--<img src="" alt="">-->
<!--<p>236次</p>-->
<!--</li>-->
<!--</ul>-->
</div>
<div class="item" id ='constTime'>
<!--<h2 class="title-bj yellow-title">截止目前</h2>-->
<!--<p class="write p-text">您已为阳光公益支教活动服务</p>-->
<!--<p class="yellow p-text">818小时</p>-->
<!--<div class="html-padding">-->
<!--<p class="write p-html tl">服务过的项目点包括</p>-->
<!--<p class="yellow p-html tl">崔各庄小学、平西符宏立学校、木兰社区、爱加倍社区、费家村社区</p>-->
<!--<p class="write p-html tl">等<span class="yellow">17</span>个项目点</p>-->
<!--</div>-->
<!--<div class="html-padding">-->
<!--<p class="write p-html tr">开发原型教案</p>-->
<!--<p class="yellow p-html tr">46个</p>-->
<!--</div>-->
<!--<div class="html-padding">-->
<!--<p class="write p-html tl">服务流动儿童</p>-->
<!--<p class="yellow p-html tl">230+</p>-->
<!--</div>-->
</div>
<div class="item" id="alertJoin">
<!--<h2 class="title-bj yellow-title">2009-2018</h2>-->
<!--<p class="write p-text">阳光 <span class="yellow">玖</span>年了</p>-->
<!--<p class="write p-text">感谢你的辛勤付出</p>-->
<!--<p class="write p-text">愿新的一年</p>-->
<!--<p class="write p-text">你与阳光,共赴新的精彩</p>-->
</div>
<div class="item erweima">
<img src="./image/erweima.jpeg" alt="">
<p class="yellow">分享阳光成就梦想</p>
</div>
</div>
<div id = "shareImg">
<!--<img src="" alt="">-->
</div>
<div class="item makeTable">
<div class="button black" onclick="openSearch(2);">
<p>制作我的</p>
<p>阳光大数据</p>
</div>
</div>
<div class="item makeTable lastMakeTable">
<!--<div class="button black" onclick="changeImg();">-->
<!--<p>一键转化图片</p>-->
<!--</div>-->
<div class="item erweima">
<img class="payImg" src="./image/showpay.jpg" alt="">
<p class="yellow">支持公益</p>
<p class="yellow">长按二维码打个赏吧</p>
</div>
<!--<div class="button black" id="save">-->
<!--<!–<img src="" alt="">–>-->
<!--<a href="javascript:void(0)" download="tupian">长按键保存</a>-->
<!--</div>-->
</div>
</div>
<!--<audio src="./sound/bj.mp3" preload autoplay style="display: none">-->
<!--您的浏览器不支持 audio 标签。-->
<!--</audio>-->
<script type="text/javascript" src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<!--<script type="text/javascript" src="//res.wx.qq.com/open/js/jweixin-1.3.0.js"></script>-->
<script src="//apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script src = './js/html2canvas.min.js'></script>
<script>
const countArr=[
{
title:'周末课堂',
img:'/ygkt_count.png',
status:'ygkt_count'
},
{
title:'培训交流',
img:'/ygpx_count.png',
status:'ygpx_count'
},
{
title:'阳光例会',
img:'/yglh_count.png',
status:'yglh_count'
},
{
title:'休闲活动',
img:'/ygxx_count.png',
status:'ygxx_count'
},
{
title:'其他公益',
img:'/ygwb_count.png',
status:'ygwb_count'
}
];
const yearName =['壹','贰','叁','肆','伍','陆','柒','捌','玖','拾'];
let g_url = "";
let g_title = '';
const g_imgurl = 'https://squirrelrao.com/ygShare/image/logo.jpg';
let g_name = '';
window.onload = function () {
console.log('加载');
let url = window.location.href;
g_url = url;
g_title = '阳光大数据';
getWxSignature();
if(url.indexOf("#")>-1){
let urlHash = window.location.hash.slice(1);
getHttp(urlHash);
}else{
$("#loading").hide();
$("#searchBox").show();
stopScroll()
}
};
//获取数据
function getHttp(name) {
$.get('https://squirrelrao.com/v1/px_ygclub_report?username='+name,(Data)=>{
const data = Data.result || {};
console.log(data);
if(data.user){
g_url = window.location.href;
let hasArealday = strDate(data.detail.time.yghd_endtime) - strDate(data.detail.time.yghd_starttime);
hasArealday = hasArealday/(60*60*24);
g_title = data.user.username + '在阳光玩耍了'+ hasArealday+'天,公益支教超过'+data.detail.time.ygkt_hour+'小时';
console.log(g_title);
g_name = '#'+data.user.username;
$('html,body').animate({scrollTop:0},'slow');
$("#save").hide();
const html = '';
$("#userName").html('<img src="'+data.user.avatar+'" alt="" id="userHeadpoirt">'+
'<p class="yellow p-text">'+data.user.username+'</p>');
let joinFirstInfo = '';
joinFirstInfo += '<p class="write p-html tl">Hi,亲爱的阳光er,</p>';
joinFirstInfo += '<p class="write p-html tl">欢迎进入阳光回忆之旅!</p>';
if(data.user.regdate_timestamp){
joinFirstInfo += '<p class="yellow p-html tl">'+format(data.user.regdate_timestamp)+'</p>';
joinFirstInfo += '<p class="write p-html tl">你注册了论坛,加入了阳光大家庭!</p>';
}
let yghd_starttime = data.detail.time.yghd_starttime || '';
if(yghd_starttime){
yghd_starttime = strJion(yghd_starttime);
joinFirstInfo += '<p class="yellow p-html tr">'+yghd_starttime+'</p>';
joinFirstInfo += '<p class="write p-html tr">你参加了阳光的新人培训。</p>';
}
if(data.detail.tongqisheng.length>0){
let tongqisheng = data.detail.tongqisheng.join('、');
joinFirstInfo += '<p class="yellow p-html tr">'+tongqisheng+'</p>';
joinFirstInfo += '<p class="write p-html tr">等阳光er是你的同期生。</p>';
}
//加入阳光的时间
$('#joinFirstInfo').html(joinFirstInfo);
if(data.detail.first_info || data.detail.zhujiang_info){
let firstInfo ='<h2 class="title-bj yellow-title">公益活动报告</h2>';
if(data.detail.first_info){
firstInfo+='<div class="html-padding">';
firstInfo+='<div class="html-padding-img l-p"><img src="./image/firInfo-first.png" alt=""></div>';
firstInfo+='<p class="yellow p-html tr">'+data.detail.first_info.school_name+'</p>';
firstInfo+='<p class="yellow p-html tr">'+strJion(data.detail.first_info.school_date)+'</p>';
firstInfo+='<p class="write p-html tr">是你服务的第一个项目点</p>';
firstInfo+='</div>';
}
if(data.detail.zhujiang_info.zhujiang_count>0){
firstInfo+='<div class="html-padding">';
firstInfo+='<div class="html-padding-img r-p"><img src="./image/firstInfo-last.png" alt=""></div>';
firstInfo+='<p class="yellow p-html tl">'+strJion(data.detail.zhujiang_info.first_zhujiang_date)+'</p>';
firstInfo+='<p class="write p-html tl">在'+data.detail.zhujiang_info.first_zhujiang_school+'</p>';
firstInfo+='<p class="write p-html tl">你第一次登上讲台,成为主讲。</p>';
firstInfo+='</div>';
}
$("#firstInfo").html(firstInfo);
}
if(data.detail.count){
let countNumber = '';
countNumber += '<h2 class="title-bj write-title">截止目前</h2>';
countNumber += '<p class="write p-text">您参与的阳光公益活动</p>';
countNumber += '<p class="yellow p-text">'+data.detail.count.yghd_count+'次</p>';
countNumber += '<ul class="list html-padding">';
for( let i = 0 ; i < countArr.length ; i ++){
countNumber += '<li class="yellow">';
countNumber += '<p class="p-html-title">'+countArr[i].title+'</p>';
countNumber += '<div class="listImg">';
countNumber += '<img src="./image'+countArr[i].img+'" alt="">';
countNumber += '</div>';
countNumber += '<p>'+data.detail.count[countArr[i].status]+'次</p>';
countNumber += '</li>';
}
countNumber += '</ul>';
$("#countNumber").html(countNumber);
}
let constTime = '';
constTime +='<h2 class="title-bj write-title">截止目前</h2>';
constTime +='<p class="write p-text">您已为阳光公益支教活动服务</p>';
constTime +='<p class="yellow p-text">'+data.detail.time.ygkt_hour+'小时</p>';
if(data.detail.school.school_list.length>0){
constTime +='<div class="html-padding">';
constTime +='<p class="write p-html tl">服务过的项目点包括</p>';
constTime +='<p class="yellow p-html tl">'+data.detail.school.school_list.join("、")+'</p>';
constTime +='<p class="write p-html tr">等<span class="yellow">'+data.detail.school.school_count+'</span>个项目点</p>';
constTime +='</div>';
}
if(data.detail.zhujiang_info.teach_plan_count){
constTime +='<div class="html-padding">';
constTime +='<div class="html-padding-img r-p"><img src="./image/const-zhujiang_count.png" alt=""></div>';
constTime +='<p class="write p-html tl">参与教案设计次数</p>';
constTime +='<p class="yellow p-html tl">'+data.detail.zhujiang_info.teach_plan_count+'次</p>';
constTime +='</div>';
}
if(data.detail.zhujiang_info.jiaoan_count){
constTime +='<div class="html-padding">';
constTime +='<div class="html-padding-img l-p"><img src="./image/const-jiaoan_count.png" alt=""></div>';
constTime +='<p class="write p-html tr">开发的教案数</p>';
constTime +='<p class="yellow p-html tr">'+data.detail.zhujiang_info.jiaoan_count+'个</p>';
constTime +='</div>';
}
if(data.detail.count.kids_count){
constTime +='<div class="html-padding">';
constTime +='<div class="html-padding-img r-p"><img src="./image/const-kids_count.png" alt=""></div>';
constTime +='<p class="write p-html tl">服务流动儿童</p>';
constTime +='<p class="yellow p-html tl">'+data.detail.count.kids_count+'+</p>';
constTime +='</div>';
}
if(data.detail.zhujiang_info.zhujiang_count){
constTime +='<div class="html-padding">';
constTime +='<div class="html-padding-img l-p"><img src="./image/const-zhujiang_count.png" alt=""></div>';
constTime +='<p class="write p-html tr">主讲次数</p>';
constTime +='<p class="yellow p-html tr">'+data.detail.zhujiang_info.zhujiang_count+'次</p>';
constTime +='</div>';
}
$("#constTime").html(constTime);
let alertJoin = '';
const lastTime = formatYear(data.detail.time.yghd_endtime);
const firstTime = formatYear(data.detail.time.yghd_starttime);
alertJoin += '<h2 class="title-bj yellow-title">'+firstTime+'-'+lastTime+'</h2>';
const nowTime = lastTime - firstTime;
let timeHTml = yearName[0];
if(nowTime<10){
timeHTml = yearName[nowTime];
}else if(nowTime ===10){
timeHTml = yearName[9];
}else if(nowTime >10 && nowTime <20){
const ten = Math.floor(nowTime/10);
timeHTml = yearName[9];
const ge = nowTime - ten*10;
timeHTml += yearName[ge-1];
}else if (nowTime>=20){
const ten = Math.floor(nowTime/10);
timeHTml = yearName[ten] + '拾';
const ge = nowTime - ten*10;
timeHTml += yearName[ge-1] || '';
}
alertJoin += '<p class="write p-text">阳光 <span class="yellow">'+timeHTml+'</span>年了</p>';
alertJoin += '<p class="write p-text">感谢你的辛勤付出</p>';
alertJoin += '<p class="write p-text">愿新的一年</p>';
alertJoin += '<p class="write p-text">你与阳光,共赴新的精彩</p>';
$("#alertJoin").html(alertJoin);
canScroll();
getWxconfig();
}else{
$('#noSearchBox').show();
stopScroll();
}
$("#loading").hide();
});
}
//获取微信签名信息
function getWxSignature(){
var url = window.location.href.split("#")[0];
// var url = "https://squirrelrao.com/ygShare/share.html";
$.get('https://squirrelrao.com/v1/get_token?url='+url,function(data,status){
console.log(status+"-"+data);
initWxConfig(data);
});
}
function shareOk() {
window.location.href = 'https://squirrelrao.com/ygShare/share.html'+g_name;
}
function getWxconfig(){
wx.ready(function(){
console.log("wx ready");
//share moments
wx.onMenuShareTimeline({
title: g_title, // 分享标题
link: g_url, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
imgUrl: g_imgurl, // 分享图标
success: function () {
// 用户确认分享后执行的回调函数
shareOk();
},
cancel: function () {
// 用户取消分享后执行的回调函数
}
});
wx.onMenuShareAppMessage({
title: g_title, // 分享标题
link: g_url, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
imgUrl:g_imgurl, // 分享图标
success: function () {
// 用户确认分享后执行的回调函数
shareOk();
},
cancel: function () {
// 用户取消分享后执行的回调函数
}
})
});
wx.error(function(res){
console.log("wx error");
console.log(res);
});
}
function initWxConfig(data){
console.log(data);
wx.config({
debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
appId: data["appid"], // 必填,公众号的唯一标识
timestamp: data["timestamp"], // 必填,生成签名的时间戳
nonceStr: data["nonce"], // 必填,生成签名的随机串
signature: data["signature"],// 必填,签名,见附录1
jsApiList: ["onMenuShareTimeline","onMenuShareAppMessage"] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
});
getWxconfig();
}
//现实搜索
function openSearch(type) {
if(type === 1){
$('#noSearchBox').hide();
$('#searchBox').show();
stopScroll();
}else if (type === 2){
$('#searchBox').show();
stopScroll();
}
}
//搜索人员
function searchName() {
const val = $('#searchValue').val();
if(val){
let url = window.location.href;
if(url.indexOf("#")>-1){
url = url.slice(0,url.indexOf("#"));
}
window.location = url +'#'+val;
$("#searchBox").hide();
getHttp(val);
}
}
//关闭取消
function closeSearch() {
$('#searchBox').hide();
canScroll();
}
function changeImg() {
console.log("转化图片");
html2canvas(document.querySelector("#showShare"),{
useCORS: true,
height: $("#showShare").outerHeight()
}).then(canvas => {
canvas.setAttribute('id','canvas');
document.body.appendChild(canvas);
getImg();
});
}
function getImg() {
var canvas = $("#canvas")[0],
url = canvas.toDataURL();
url = url.replace("image/png", "image/octet-stream");
saveImg(canvas);
document.body.removeChild($("#canvas")[0]);
}
function format(shijianchuo){
//shijianchuo是整数,否则要parseInt转换
shijianchuo = shijianchuo * 1000;
var time = new Date(shijianchuo);
var y = time.getFullYear();
var m = time.getMonth()+1;
var d = time.getDate();
return y+'年'+m+'月'+d+'日';
}
function strJion(str) {
str = str.split('-');
return +str[0]+'年'+ +str[1]+'月'+ +str[2]+'日'
}
function formatYear(str){
str = str.split('-');
return +str[0];
}
function stopScroll() {
$("body").addClass('overflow');
}
function canScroll() {
$("body").removeClass('overflow')
}
function saveImg(canvas){
var filename = '阳光'+ $("#userName >p").html() + '.png';
saveFile(canvas.toDataURL(),filename);
var image = new Image();
image.src = canvas.toDataURL();
$("#shareImg").html(image);
$("#shareImg").show();
}
function saveFile(data, filename){
const save_link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a');
save_link['href'] = data;
save_link['download'] = filename;
const event = document.createEvent('MouseEvents');
event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
save_link.dispatchEvent(event);
};
function showPay() {
$("#showPay").show();
stopScroll();
}
function strDate(str) {
str = str.replace(/-/g,'/'); // 将-替换成/,因为下面这个构造函数只支持/分隔的日期字符串
var date = new Date(str);
var time = date.getTime()/1000;
return time
}
</script>
</body>
</html>