datxy commited on
Commit
1c53bf0
·
verified ·
1 Parent(s): 817aff7

Create rmb.html

Browse files
Files changed (1) hide show
  1. rmb.html +181 -0
rmb.html ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>─=≡Σ((( つ•̀ω•́)つ</title>
7
+
8
+ <style>
9
+ body {
10
+ font-family: Arial, sans-serif;
11
+ margin: 0;
12
+ padding: 0;
13
+ margin-top: 5px;
14
+ background-color: #f4f4f4;
15
+ }
16
+
17
+ .container {
18
+ display: flex;
19
+ flex-wrap: wrap;
20
+ gap: 10px;
21
+ justify-content: space-between;
22
+ align-items: center;
23
+ width: 98%;
24
+ margin: auto;
25
+ padding: 5px;
26
+ background-color: #ffffff;
27
+ border-radius: 10px;
28
+ box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
29
+ }
30
+
31
+ .input-with-background, .input-with-background2 {
32
+ position: relative;
33
+ flex: 1;
34
+ min-width: 100px; /* 设置最小宽度以确保输入框不会过小 */
35
+ }
36
+
37
+ .input-with-background input, .input-with-background2 input {
38
+ width: 100%; /* 输入框宽度 */
39
+ height: 20px; /* 输入框高度 */
40
+ font-size: 12px; /* 字体缩小 */
41
+ padding-right: 40px; /* 留出空间给背景文字 */
42
+ border: 1px solid #ccc;
43
+ border-radius: 5px;
44
+ box-sizing: border-box;
45
+ padding-left: 10px; /* 左边内边距 */
46
+ }
47
+
48
+ .input-with-background::after, .input-with-background2::after {
49
+ position: absolute;
50
+ top: 50%;
51
+ right: 10px;
52
+ transform: translateY(-50%);
53
+ color: #888;
54
+ pointer-events: none;
55
+ white-space: nowrap;
56
+ font-size: 12px; /* 背景文字字体缩小 */
57
+ }
58
+
59
+ .input-with-background::after {
60
+ content: '% (年利率)'; /* 年利率背景文字 */
61
+ }
62
+
63
+ .input-with-background2::after {
64
+ content: '元'; /* 金额背景文字 */
65
+ }
66
+ </style>
67
+ </head>
68
+ <body>
69
+ <div class="container">
70
+ <div class="input-with-background2">
71
+ <input type="number" id="principal" value="50000" step="10000" placeholder="请输入金额">
72
+ </div>
73
+ <div class="input-with-background">
74
+ <input type="number" id="rate" placeholder="请输入年利率" value="1" required>
75
+ </div>
76
+ <div class="input-with-background2">
77
+ <input id="totalAmount" value="收益: 0" readonly>
78
+ </div>
79
+ <div class="input-with-background2">
80
+ <input id="perHourEarnings" placeholder="每小时" readonly>
81
+ </div>
82
+ <div class="input-with-background2">
83
+ <input id="perDayEarnings" placeholder="每天" readonly>
84
+ </div>
85
+ <div class="input-with-background2">
86
+ <input id="perMonthEarnings" placeholder="每月" readonly>
87
+ </div>
88
+ <div class="input-with-background2">
89
+ <input id="perYearEarnings" placeholder="每年" readonly>
90
+ </div>
91
+ </div>
92
+ <audio id="coinSound" src="/page/wav/rmb.wav"></audio>
93
+ <audio id="bigWinSound" src="/page/wav/rmb2.wav"></audio>
94
+
95
+ <script>
96
+ let intervalId = null;
97
+ let lastAmountForSound = 0; // 用于追踪何时播放音效的金额标记
98
+ let totalAmount = 0; // 初始化总收益
99
+
100
+ function startCalculation() {
101
+ clearInterval(intervalId); // 无需检查null,直接清除即可
102
+ const principal = parseFloat(document.getElementById("principal").value);
103
+ const rate = parseFloat(document.getElementById("rate").value);
104
+ totalAmount = principal;
105
+ lastAmountForSound = totalAmount; // 重置,确保从当前本金开始计算增加额度
106
+ const perSecondInterest = (principal * (rate / 100) / 365 / 24 / 60 / 60);
107
+
108
+ intervalId = setInterval(() => {
109
+ totalAmount += perSecondInterest;
110
+ document.getElementById("totalAmount").value = ` ${totalAmount.toFixed(6)}`;
111
+ updateEarnings(perSecondInterest);
112
+
113
+ let increaseAmount = totalAmount - lastAmountForSound;
114
+ // 根据增加额度决定播放哪个音效
115
+ if (increaseAmount >= 10) { // 优先检查大额度增加
116
+ playSound("bigWinSound");
117
+ lastAmountForSound = totalAmount;
118
+ } else if (increaseAmount >= 1) {
119
+ playSound("coinSound");
120
+ lastAmountForSound = totalAmount;
121
+ }
122
+ }, 1000);
123
+ }
124
+
125
+ function updateEarnings(perSecondInterest) {
126
+ const perMinute = perSecondInterest * 60;
127
+ const perHour = perMinute * 60;
128
+ const perDay = perHour * 24;
129
+ const perMonth = perDay * 30;
130
+ const perYear = perDay * 365;
131
+
132
+ document.getElementById("perHourEarnings").value = `每小时: ${perHour.toFixed(2)}`;
133
+ document.getElementById("perDayEarnings").value = `每天: ${perDay.toFixed(2)}`;
134
+ document.getElementById("perMonthEarnings").value = `每月: ${perMonth.toFixed(2)}`;
135
+ document.getElementById("perYearEarnings").value = `每年: ${perYear.toFixed(2)}`;
136
+ }
137
+
138
+ function playSound(soundId) {
139
+ const sound = document.getElementById(soundId);
140
+ if (sound) {
141
+ sound.pause(); // 停止当前播放
142
+ sound.currentTime = 0; // 重置音频文件到开始
143
+ sound.play().catch(error => console.error("Audio play failed", error));
144
+ }
145
+ }
146
+
147
+ function stopCalculation() {
148
+ clearInterval(intervalId); // 清除计时器
149
+ intervalId = null; // 显式地将intervalId设置为null
150
+ }
151
+
152
+ document.getElementById("principal").addEventListener("input", () => {
153
+ stopCalculation();
154
+ startCalculation();
155
+ });
156
+
157
+ document.getElementById("rate").addEventListener("input", () => {
158
+ stopCalculation();
159
+ startCalculation();
160
+ });
161
+
162
+ window.onload = startCalculation;
163
+ </script>
164
+
165
+ <script>
166
+ document.addEventListener('DOMContentLoaded', function () {
167
+ const monthsInput = document.getElementById('months');
168
+ const rateInput = document.getElementById('rate');
169
+ monthsInput.addEventListener('change', function () {
170
+ const selectedMonths = monthsInput.value;
171
+ const selectedRate = monthsToRate[selectedMonths];
172
+ if (selectedRate) {
173
+ rateInput.value = selectedRate;
174
+ }
175
+ });
176
+ });
177
+ </script>
178
+ <script charset="UTF-8" id="LA_COLLECT" src="//sdk.51.la/js-sdk-pro.min.js"></script>
179
+ <script>LA.init({ id: "JRHGRBPWC7lJIaXq", ck: "JRHGRBPWC7lJIaXq" })</script>
180
+ </body>
181
+ </html>