File size: 6,709 Bytes
1c53bf0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>─=≡Σ((( つ•̀ω•́)つ</title>

    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            margin-top: 5px;
            background-color: #f4f4f4;
        }

        .container {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            justify-content: space-between;
            align-items: center;
            width: 98%;
            margin: auto;
            padding: 5px;
            background-color: #ffffff;
            border-radius: 10px;
            box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
        }

        .input-with-background, .input-with-background2 {
            position: relative;
            flex: 1;
            min-width: 100px; /* 设置最小宽度以确保输入框不会过小 */
        }

        .input-with-background input, .input-with-background2 input {
            width: 100%; /* 输入框宽度 */
            height: 20px; /* 输入框高度 */
            font-size: 12px; /* 字体缩小 */
            padding-right: 40px; /* 留出空间给背景文字 */
            border: 1px solid #ccc;
            border-radius: 5px;
            box-sizing: border-box;
            padding-left: 10px; /* 左边内边距 */
        }

        .input-with-background::after, .input-with-background2::after {
            position: absolute;
            top: 50%;
            right: 10px;
            transform: translateY(-50%);
            color: #888;
            pointer-events: none;
            white-space: nowrap;
            font-size: 12px; /* 背景文字字体缩小 */
        }

        .input-with-background::after {
            content: '% (年利率)'; /* 年利率背景文字 */
        }

        .input-with-background2::after {
            content: '元'; /* 金额背景文字 */
        }
    </style>
</head>
<body>
<div class="container">
<div class="input-with-background2">
<input type="number" id="principal" value="50000" step="10000" placeholder="请输入金额">
</div>
<div class="input-with-background">
<input type="number" id="rate" placeholder="请输入年利率" value="1"  required>
</div>
<div class="input-with-background2">
<input id="totalAmount" value="收益: 0" readonly>
</div>
<div class="input-with-background2">
<input id="perHourEarnings" placeholder="每小时" readonly>
</div>
<div class="input-with-background2">
<input id="perDayEarnings" placeholder="每天" readonly>
</div>
<div class="input-with-background2">
<input id="perMonthEarnings" placeholder="每月" readonly>
</div>
<div class="input-with-background2">
<input id="perYearEarnings" placeholder="每年" readonly>
</div>
</div>  
    <audio id="coinSound" src="/page/wav/rmb.wav"></audio>
    <audio id="bigWinSound" src="/page/wav/rmb2.wav"></audio>

    <script>
        let intervalId = null;
        let lastAmountForSound = 0; // 用于追踪何时播放音效的金额标记
        let totalAmount = 0; // 初始化总收益

        function startCalculation() {
            clearInterval(intervalId); // 无需检查null,直接清除即可
            const principal = parseFloat(document.getElementById("principal").value);
            const rate = parseFloat(document.getElementById("rate").value);
            totalAmount = principal;
            lastAmountForSound = totalAmount; // 重置,确保从当前本金开始计算增加额度
            const perSecondInterest = (principal * (rate / 100) / 365 / 24 / 60 / 60);

            intervalId = setInterval(() => {
                totalAmount += perSecondInterest;
                document.getElementById("totalAmount").value = ` ${totalAmount.toFixed(6)}`;
                updateEarnings(perSecondInterest);

                let increaseAmount = totalAmount - lastAmountForSound;
                // 根据增加额度决定播放哪个音效
                if (increaseAmount >= 10) { // 优先检查大额度增加
                    playSound("bigWinSound");
                    lastAmountForSound = totalAmount;
                } else if (increaseAmount >= 1) {
                    playSound("coinSound");
                    lastAmountForSound = totalAmount;
                }
            }, 1000);
        }

        function updateEarnings(perSecondInterest) {
            const perMinute = perSecondInterest * 60;
            const perHour = perMinute * 60;
            const perDay = perHour * 24;
            const perMonth = perDay * 30;
            const perYear = perDay * 365;

            document.getElementById("perHourEarnings").value = `每小时: ${perHour.toFixed(2)}`;
            document.getElementById("perDayEarnings").value = `每天: ${perDay.toFixed(2)}`;
            document.getElementById("perMonthEarnings").value = `每月: ${perMonth.toFixed(2)}`;
            document.getElementById("perYearEarnings").value = `每年: ${perYear.toFixed(2)}`;
        }

        function playSound(soundId) {
            const sound = document.getElementById(soundId);
            if (sound) {
                sound.pause(); // 停止当前播放
                sound.currentTime = 0; // 重置音频文件到开始
                sound.play().catch(error => console.error("Audio play failed", error));
            }
        }

        function stopCalculation() {
            clearInterval(intervalId); // 清除计时器
            intervalId = null; // 显式地将intervalId设置为null
        }

        document.getElementById("principal").addEventListener("input", () => {
            stopCalculation();
            startCalculation();
        });

        document.getElementById("rate").addEventListener("input", () => {
            stopCalculation();
            startCalculation();
        });

        window.onload = startCalculation;
    </script>

    <script>
        document.addEventListener('DOMContentLoaded', function () {
            const monthsInput = document.getElementById('months');
            const rateInput = document.getElementById('rate');
            monthsInput.addEventListener('change', function () {
                const selectedMonths = monthsInput.value;
                const selectedRate = monthsToRate[selectedMonths];
                if (selectedRate) {
                    rateInput.value = selectedRate;
                }
            });
        });
    </script>
    <script charset="UTF-8" id="LA_COLLECT" src="//sdk.51.la/js-sdk-pro.min.js"></script>
    <script>LA.init({ id: "JRHGRBPWC7lJIaXq", ck: "JRHGRBPWC7lJIaXq" })</script>
</body>
</html>