forked from lonlie/openai-chatgpt-billing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
989 lines (888 loc) · 34.4 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
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
<!DOCTYPE html>
<html>
<head>
<title>ChatGPT余额查询 OpenAI midjourney 账号购买充值代充</title>
<meta name="description" content='在线ChatGPT余额查询 OpenAI midjourney 账号购买充值代充,免登录'>
<meta name="keywords" content="openai,chatgpt,midjourney,gpt,gpt4,key,账号,充值,购买,代充,查询,余额,查余额,额度">
<meta name="anthor" content="lonlie,wx:lonliecom">
<meta name="robots" content="openai,chatgpt,midjourney,gpt,gpt4,key,账号,充值,购买,代充,查询,余额,查余额,额度">
<meta charset="UTF-8">
<style>
.github-corner:hover .octo-arm {
animation: octocat-wave 560ms ease-in-out;
}
@keyframes octocat-wave {
0%,
100% {
transform: rotate(0);
}
20%,
60% {
transform: rotate(-25deg);
}
40%,
80% {
transform: rotate(10deg);
}
}
@media (max-width:500px) {
.github-corner:hover .octo-arm {
animation: none;
}
.github-corner .octo-arm {
animation: octocat-wave 560ms ease-in-out;
}
}
#query {
background-color: #f2f2f2;
padding: 20px;
text-align: center;
}
#query h1 {
font-size: 32px;
margin-bottom: 20px;
}
#query input[type=text],
input[type=date] {
padding: 10px;
font-size: 15px;
border: 1px solid #f2f2f2;
border-radius: 5px;
margin-right: 5px;
}
#query input[type=text]:focus-visible,
input[type=date]:focus-visible,
:focus {
outline: none;
border: 1px solid #4CAF50;
}
#query #key {
width: 450px;
}
#query #beginDate,
#query #endDate {
width: 100px;
}
#query button {
padding: 10px 35px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
position: relative;
}
#query button:hover {
background-color: #3e8e41;
}
#query button:disabled {
opacity: 0.5;
cursor: not-allowed;
}
#query button.loading:before {
content: '';
position: absolute;
left: 12%;
top: 50%;
transform: translate(-50%, -50%);
width: 12px;
height: 12px;
border-radius: 50%;
border: 2px solid #fff;
border-top-color: rgba(255, 103, 104, 1);
animation: loading 1s ease-in-out infinite;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
#query table {
width: 70%;
margin: 0 auto;
border-collapse: collapse;
border: 1px solid #ddd;
margin-top: 10px;
animation: fadeIn 1s ease-in-out;
}
#query th,
#query td {
padding: 4px;
border: 1px solid #ddd;
}
#query th {
background-color: #e8e8e8;
font-size: 15px;
}
.container {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
margin-top: 10px;
}
.item {
width: 140px;
height: 50px;
margin: 10px;
padding: 10px;
text-align: center;
box-shadow: 2px 2px 5px #888888;
transition: all 0.5s ease;
}
.item:hover {
transform: scale(1.1);
}
.item-title {
font-weight: bold;
font-size: 12px;
margin: 5px 0 10px 0;
}
.item-value {
font-size: 16px;
color: #4CAF50;
font-weight: bold;
}
.query-btn {
display: block;
margin: 20px auto;
width: 100px;
height: 50px;
border: none;
background-color: #4CAF50;
color: #fff;
font-size: 18px;
border-radius: 5px;
cursor: pointer;
transition: all 0.5s ease;
}
.query-btn:hover {
background-color: #3e8e41;
}
@keyframes loading {
from {
transform: translate(-50%, -50%) rotate(0deg);
}
to {
transform: translate(-50%, -50%) rotate(360deg);
}
}
#products {
margin-top: 20px;
text-align: center;
}
#products table {
width: 65%;
margin: 0 auto;
border-collapse: collapse;
border: 1px solid #ddd;
margin-bottom: 100px;
}
#products .logo {
width: 50px;
height: 50px;
vertical-align: inherit;
margin-right: 5px;
}
#products th,
#products td {
padding: 10px;
border: 1px solid #ddd;
}
#products tr:hover {
background-color: #f5f5f5;
}
#products td:nth-child(1) {
text-align: left;
padding-left: 30px;
}
#products td:nth-child(2) span::before {
content: "¥";
}
#products td:nth-child(2) {
color: red;
font-weight: bold;
}
#products th {
background-color: #f2f2f2;
font-size: 18px;
}
#products ul {
padding: 0;
padding-left: 20px;
text-align: left;
margin: 0;
}
#products .import {
color: red;
}
#customer-service {
position: fixed;
right: 20px;
top: 220px;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
text-align: center;
background: white;
}
#customer-service img {
width: 200px;
height: 200px;
}
#customer-service p {
font-size: 16px;
margin-bottom: 10px;
}
#close-btn {
position: absolute;
top: 5px;
right: 5px;
font-size: 20px;
color: #aaa;
cursor: pointer;
}
#close-btn:hover {
color: #666;
}
body {
font-family: Arial, sans-serif;
margin: 0;
}
.alert {
width: 40%;
margin: 0 auto;
text-align: left;
margin-bottom: 20px;
background-color: #FFF8DC;
color: #333333;
border: 2px solid #F44336;
border-radius: 10px;
padding: 0 10px 0 10px;
animation: shake 0.5s;
margin-bottom: 20px;
}
@keyframes shake {
0% {
transform: translateX(0);
}
10%,
90% {
transform: translateX(-10px);
}
30%,
70% {
transform: translateX(10px);
}
50% {
transform: translateX(0);
}
}
.message {
position: fixed;
top: 15px;
left: 50%;
transform: translateX(-50%);
color: #333;
padding: 10px;
border: 1px solid #F44336;
border-radius: 5px;
opacity: 0;
transition: opacity 0.5s ease-in-out;
z-index: 999;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
background: white;
}
td h2 {
font-size: medium;
display: inline;
font-weight: normal;
}
.nav {
position: fixed;
left: 0px;
top: 50%;
transform: translateY(-50%);
z-index: 999;
display: flex;
flex-direction: column;
}
.nav a {
background: #1E90FF;
color: #fff;
text-align: left;
line-height: 30px;
text-decoration: none;
font-size: 16px;
margin-bottom: 5px;
padding: 10px;
border-radius: 0 8px 8px 0;
transition: all 0.3s ease;
width: 240px;
}
.nav a:hover {
background: #4169E1;
width: 260px;
}
</style>
<script>
var _hmt = _hmt || [];
(function () {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?13ff43d52a01e795ed56fea66c3b6b4f";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</head>
<body>
<a href="https://github.com/lonlie/openai-chatgpt-billing" class="github-corner" aria-label="View source on GitHub">
<svg width="80" height="80" viewBox="0 0 250 250"
style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true">
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
<path
d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm">
</path>
<path
d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
fill="currentColor" class="octo-body">
</path>
</svg>
</a>
<div class="nav">
<a href="https://gptbill.lonlie.cn/" target="_blank">余额及用量查询</a>
<a href="https://gptbill.lonlie.cn/pricinglimits.html" target="_blank">最新最全模型model价格及限速表</a>
<a href="https://gptbill.lonlie.cn/pricinglimits.html" target="_blank">tokens计算器</a>
</div>
<div id="query">
<form onsubmit="event.preventDefault(); queryBalance();">
<h2>💰ChatGPT OpenAI key 账号余额查询</h2>
<input type="text" name="key" id="key" placeholder="请输入OpenAI API key(sk-xxx)或会话密钥(sess-xxx)"
autofocus="true">
<input type="text" name="api" id="api" placeholder="中转域名(可空):https://www.xxx.com"
title="中转域名(可空):https://www.xxx.com">
<input type="text" name="publicId" id="publicId" placeholder="用户ID(可空):user-xxx"
title="用户公共ID(可空):user-xxx">
<input type="date" name="beginDate" id="beginDate" title="指定查询起始日期(可空)">
<span style="margin-left: -10px">-</span>
<input type="date" name="endDate" id="endDate" title="指定查询截止日期(可空)">
<button type="submit" id="btn_submit">查询用量与余额</button>
<p id="searchTips" style="font-size: 11px;"></p>
<div class="container" id="summary">
<div class="item">
<div class="item-title">剩余额度</div>
<div id="remaining-amount" class="item-value">-</div>
</div>
<div class="item">
<div class="item-title">总额度</div>
<div id="total-amount" class="item-value">-</div>
</div>
<div class="item">
<div class="item-title">已用额度</div>
<div id="used-amount" class="item-value">-</div>
</div>
<div class="item">
<div class="item-title">是否绑卡</div>
<div id="is-bound" class="item-value">-</div>
</div>
<div class="item">
<div class="item-title">key到期时间</div>
<div id="key-expiration" class="item-value">-</div>
</div>
</div>
</form>
</div>
<div id="products">
<div class="alert">
<p style="font-weight: bold;">⚠️⚠️⚠️使用ChatGPT的重要提醒:</p>
<p>
需要使用代理(尽量用美国节点),同时建议启用浏览器的无痕模式访问ChatGPT。API也需要代理,不要在香港服务器调用,否则封号。
</p>
</div>
<h2>🔥在售商品:ChatGPT OpenAI、Midjourney账号及充值
<br>
加右侧微信(<span class="import">lonliecom</span>),咨询代理合作销售、购买!
</h2>
<table>
<tr>
<th colspan="3">更新日期:<span class="import">2023-12-04</span></th>
</tr>
<tr>
<th>商品</th>
<th>价格</th>
<th>说明</th>
</tr>
<tr>
<td><img src="assets/chatgpt.png" class="logo">
<h2>【推荐】稳定转发 GPT4 API Key额度</h2>
</td>
<td>
<span>110($50额度)</span><br>
<span></span>1000($500额度)</span>
</td>
<td>
<ul>
<li>
$50-$499额度,价格比例1:2.2($1售价2.2元)<br>
$500以上额度,价格比例1:2($1售价2元)<br>
</li>
<li>
$50额度起购
</li>
<li>
<span class="import">支持gpt3.5、gpt4、gpt4 turbo、gpt4 vision、tts、dalle等</span>
</li>
<li>
提供key,可以自助查余额及明细
</li>
<li>
后台使用官方key转发,稳定可靠,一分钟大概60-100次可以满足
</li>
<li>
<span class="import">额度90天有效期,无封号问题</span>
</li>
</ul>
</td>
</tr>
<tr>
<td><img src="assets/chatgpt.png" class="logo">
<h2>小额直连 GPT4 API Key额度</h2>
</td>
<td>
<span>540($120独享额度)</span><br>
<span>1740($600共享额度)</span><br>
<span>2100($600独享额度)</span>
</td>
<td>
<ul>
<li>
$120独享账号额度,价格比例1:4.5($1售价4.5元)<br>
$600共享账号额度,价格比例1:2.9($1售价2.9元)<br>
共享大号额度,速度快,足量额度,可自助查询用量<br>
$600独享账号额度,价格比例1:3.5($1售价3.5元)<br>
</li>
<li>
<span class="import">支持gpt3.5、gpt4、gpt4 turbo、gpt4 vision、tts、dalle等</span>
</li>
<li>
提供key,可以代查余额或提供reader账号
</li>
<li>
<span class="import">额度当月有效,100%售后保障,封号补额度</span>
</li>
</ul>
</td>
</tr>
<tr>
<td><img src="assets/chatgpt.png" class="logo">
<h2>大额直连独享 GPT4 API Key额度</h2>
</td>
<td>
<span>2800($1000额度)</span><br>
<span>11500($5000额度)</span>
</td>
<td>
<ul>
<li>
$1000-$4999独享账号额度<br>
价格比例1:2.8($1售价2.8元)<br>
$5000独享账号额度,价格比例1:2.3($1售价2.3元)<br>
</li>
<li>
有1000 2500 5000 1w 1.5w 2w 3w 5w 10w 15w<br>多种规格独享额度
</li>
<li>
<span class="import">支持gpt3.5、gpt4、gpt4 turbo、gpt4 vision、tts、dalle等</span>
</li>
<li>
提供key,可以代查余额或提供reader账号
</li>
<li>
<span class="import">额度当月有效,100%售后保障,封号补额度</span>
</li>
</ul>
</td>
</tr>
<tr>
<td><img src="assets/chatgpt.png" class="logo">
<h2>OpenAI代付账单、充值</h2>
</td>
<td>
<span>425($50)</span>
</td>
<td>
<ul>
<li>
$500以内汇率1:8.5<br>
$500以上汇率1:8<br>
</li>
<li>
$50起付
</li>
</ul>
</td>
</tr>
<tr>
<td><img src="assets/chatgpt.png" class="logo">
<h2>ChatGPT 5普通账号 3.5</h2>
</td>
<td><span>15</span></td>
<td>
<ul>
<li>
提供账号、密码<span class="import">(部分账号支持修改密码)</span>
</li>
<li>
账号初始余额<span class="import">$5</span>
</li>
<li>
API频率限制:<br>
每分钟3次请求,每分钟40000 tokens,每天200次请求
</li>
<li>
售后24小时
</li>
</ul>
</td>
</tr>
<tr>
<td><img src="assets/chatgpt.png" class="logo">
<h2>ChatGPT Plus共享账号 4.0</h2>
</td>
<td><span>60/月</span></td>
<td>
<ul>
<li>
提供账号、密码<span class="import">(部分账号支持修改密码)</span>
</li>
<li>
<span class="import">按月续费</span>,可以只使用一个月
</li>
<li>
可以使用GPT4,目前限制每3小时提问40次
</li>
<li>
包售后30天,封号掉线按天退款(未按重要提示使用,不包售后)
</li>
</ul>
</td>
</tr>
<tr>
<td><img src="assets/chatgpt.png" class="logo">
<h2>ChatGPT Plus独享账号 4.0</h2>
</td>
<td><span>200/月</span></td>
<td>
<ul>
<li>
提供账号、密码<span class="import">(部分账号支持修改密码)</span>
</li>
<li>
<span class="import">按月续费</span>,可以只使用一个月
</li>
<li>
可以使用GPT4,目前限制每3小时提问40次
</li>
<li>
包售后30天,封号掉线按天退款(未按重要提示使用,不包售后)
</li>
</ul>
</td>
</tr>
<tr>
<td><img src="assets/chatgpt.png" class="logo">
<h2>OpenAI API 中转通道</h2>
</td>
<td>
<span>150/月</span><br>
<span>1500/年</span>
</td>
<td>
<ul>
<li>
提供OpenAI API中转通道,替代https://api.openai.com
</li>
<li>
<span class="import">支持国内服务器直接调用OpenAI接口,无需额外代理</span>
</li>
<li>
支持流式输出
</li>
</ul>
</td>
</tr>
<tr>
<td><img src="assets/chatgpt.png" class="logo">
<h2>AI智能原创文章写作SEO批量生成器</h2>
</td>
<td><span>0.05/篇</span></td>
<td>
<ul>
<li>
<a href="http://gen.zsxx.ren/"><span class="import">http://gen.zsxx.ren/</span></a>
</li>
</ul>
</td>
</tr>
<tr>
<td><img src="assets/chatgpt.png" class="logo">
<h2>GPT对话机器人整套程序</h2>
</td>
<td><span>3000</span></td>
<td>
<ul>
<li>
<a href="http://chatgpt.firstui.cn/"><span
class="import">http://chatgpt.firstui.cn/</span></a>
</li>
<li>
会员体系、支付、代理
</li>
</ul>
</td>
</tr>
<tr>
<td><img src="assets/midjourney.png" class="logo">
<h2>Midjourney 30/60账号</h2>
</td>
<td><span>260/485</span></td>
<td>
<ul>
<li>
提供账号、密码
</li>
</ul>
</td>
</tr>
</table>
</div>
<div id="customer-service">
<span id="close-btn" onclick="closeCustomerService()">×</span>
<img src="assets/wx.png" alt="在线微信客服">
<p>🤝欢迎咨询、合作、交流🤝</p>
</div>
<div class="message"></div>
<script>
document.getElementById("searchTips").innerHTML = "用量数据按日期查询后汇总,目前官方对单个key查询请求限制为5次/分钟,今日查询当月总用量预计需要<span style='color: chocolate;font-weight: bold;'>" + (Math.ceil(new Date().getDate() / 5) - 1) + "</span>分钟";
function queryBalance(event) {
var key = document.getElementById("key").value;
var publicId = document.getElementById("publicId").value;
var specificDate = document.getElementById("specificDate").value;
if (!(/(^sk(-proj)?-[a-zA-Z0-9]{48}$)|(^sess-[a-zA-Z0-9]{40}$)/.test(key))) {
showMessage("输入的key有误!", 0);
return;
}
if (publicId.trim() != "" && !(/(^user-[a-zA-Z0-9]{24}$)/.test(publicId))) {
showMessage("输入的用户公共ID有误!", 0);
return;
}
var btn = document.getElementById("btn_submit");
btn.classList.add('loading');
btn.disabled = true;
var remainingAmount = document.getElementById('remaining-amount');
var totalAmount = document.getElementById('total-amount');
var usedAmount = document.getElementById('used-amount');
var isBound = document.getElementById('is-bound');
var keyExpiration = document.getElementById('key-expiration');
var queryBtn = document.getElementById('query-btn');
remainingAmount.innerHTML = "-";
totalAmount.innerHTML = "-";
usedAmount.innerHTML = "-";
isBound.innerHTML = "-";
keyExpiration.innerHTML = "-";
var oldTable = document.getElementById('detailTable');
if (oldTable != null) {
oldTable.remove();
}
if (key.startsWith("sees-") || specificDate.trim() != "") {
ajax({
method: 'GET',
url: 'https://api.yourdomain.com/api/main/bill?key=' + key + '&ext=1652831557593' + '&publicId=' + publicId + '&beginDate=' + specificDate + '&endDate=' + specificDate
}).then(function (response) {
var data = JSON.parse(response).data;
var result = data.returnObject;
if (data.isPass) {
if (key.startsWith("sees-")) {
remainingAmount.innerHTML = "$" + result.remaining.toFixed(7);
totalAmount.innerHTML = "$" + result.total.toFixed(7);
usedAmount.innerHTML = "$" + result.usage.toFixed(7);
isBound.innerHTML = result.bind ? "是" : "否";
keyExpiration.innerHTML = (new Date(result.util * 1000)).toLocaleString();
} else {
usedAmount.innerHTML = "$" + result.usage.toFixed(7);
}
} else {
showMessage(data.desc, 1);
}
}).catch(function (error) {
showMessage("查询失败!!", 1);
}).finally(function () {
btn.classList.remove('loading');
btn.disabled = false;
});
} else {
var dateArray = generateDateArray();
let index = 0;
var usageDetail = [];
var queryCore = function () {
const item = dateArray[index];
ajax({
method: 'GET',
url: 'https://api.yourdomain.com/api/main/bill?key=' + key + '&ext=1652831557593' + '&publicId=' + publicId + '&beginDate=' + item[0].toLocaleString() + '&endDate=' + item[1].toLocaleString()
}).then(function (response) {
var data = JSON.parse(response).data;
var result = data.returnObject;
if (data.isPass) {
usageDetail.push(...result.detail);
showUsageDetail(usageDetail, index === dateArray.length);
} else {
showMessage(data.desc, 1);
}
}).catch(function (error) {
showMessage("查询失败!!", 1);
});
index++;
if (index === dateArray.length) {
clearInterval(queryInterval);
btn.classList.remove('loading');
btn.disabled = false;
}
};
queryCore();
const queryInterval = setInterval(queryCore, 60000);
}
}
function showUsageDetail(usageDetail, end) {
var oldTable = document.getElementById('detailTable');
if (oldTable != null) {
oldTable.remove();
}
const models = [...new Set(usageDetail.flatMap(i => i.data.map(entry => entry.model)))].sort();
const modelTotals = models.reduce((acc, model) => {
acc[model] = 0;
return acc;
}, {});
const table = document.createElement('table');
table.setAttribute("id", "detailTable");
const thead = document.createElement('thead');
const tbody = document.createElement('tbody');
table.appendChild(thead);
table.appendChild(tbody);
const headerRow = document.createElement('tr');
const dateHeader = document.createElement('th');
dateHeader.textContent = '日期';
headerRow.appendChild(dateHeader);
models.forEach(model => {
const modelHeader = document.createElement('th');
modelHeader.textContent = model;
headerRow.appendChild(modelHeader);
});
const subtotalHeader = document.createElement('th');
subtotalHeader.textContent = '合计';
headerRow.appendChild(subtotalHeader);
thead.appendChild(headerRow);
usageDetail.forEach(i => {
const row = document.createElement('tr');
const dateCell = document.createElement('td');
dateCell.textContent = i.date;
row.appendChild(dateCell);
let subtotal = 0;
models.forEach(model => {
const modelCell = document.createElement('td');
const modelData = i.data.find(entry => entry.model === model);
const amount = modelData ? modelData.amount : 0;
modelCell.textContent = amount.toFixed(2);
row.appendChild(modelCell);
subtotal += amount;
modelTotals[model] += amount;
});
const subtotalCell = document.createElement('td');
subtotalCell.textContent = subtotal.toFixed(2);
row.appendChild(subtotalCell);
tbody.appendChild(row);
});
const summaryRow = document.createElement('tr');
const summaryDateCell = document.createElement('td');
summaryDateCell.textContent = '汇总';
summaryRow.appendChild(summaryDateCell);
let grandTotal = 0;
models.forEach(model => {
const summaryModelCell = document.createElement('td');
summaryModelCell.textContent = modelTotals[model].toFixed(2);
summaryRow.appendChild(summaryModelCell);
grandTotal += modelTotals[model];
});
const grandTotalCell = document.createElement('td');
grandTotalCell.textContent = grandTotal.toFixed(2);
summaryRow.appendChild(grandTotalCell);
if (end) {
document.getElementById('used-amount').innerHTML = "$" + grandTotal.toFixed(2);
}
tbody.insertBefore(summaryRow, tbody.firstChild);
document.getElementById("summary").appendChild(table);
}
function generateDateArray() {
const ranges = [];
const currentDate = new Date();
const startOfMonth = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1);
let startDate = startOfMonth;
let endDate = new Date(startOfMonth);
while (startDate < currentDate) {
endDate = new Date(startDate);
endDate.setDate(startDate.getDate() + 4);
if (endDate > currentDate) {
endDate = currentDate;
}
ranges.push([
startDate,
endDate
]);
startDate = new Date(endDate);
startDate.setDate(endDate.getDate() + 1);
}
return ranges;
}
function showMessage(msg, type) {
var message = document.querySelector('.message');
message.innerHTML = (type == 0 ? "⚠️⚠️⚠️" : "🚨🚨🚨") + msg;
message.style.opacity = 1;
setTimeout(function () {
message.style.opacity = 0;
}, 3000);
}
function closeCustomerService() {
document.getElementById("customer-service").style.display = "none";
}
function ajax(options) {
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open(options.method || 'GET', options.url);
xhr.onload = function () {
if (xhr.status >= 200 && xhr.status < 300) {
resolve(xhr.response);
} else {
reject(new Error(xhr.statusText));
}
};
xhr.onerror = function () {
reject(new Error('Network Error'));
};
xhr.send(options.data);
xhr.finally = function (callback) {
xhr.onload = function () {
callback();
};
xhr.onerror = function () {
callback();
};
};
});
}
</script>
</body>
</html>