-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdalottery.html
More file actions
397 lines (345 loc) · 12.2 KB
/
dalottery.html
File metadata and controls
397 lines (345 loc) · 12.2 KB
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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>大乐透机选程序</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Arial', sans-serif;
background-color: #f0f0f0;
color: #333;
}
.container {
max-width: 800px;
margin: 20px auto;
padding: 20px;
background-color: white;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
h1 {
text-align: center;
color: #e74c3c;
margin-bottom: 30px;
}
.controls {
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 30px;
gap: 20px;
}
.control-group {
display: flex;
flex-direction: column;
align-items: center;
}
label {
margin-bottom: 5px;
font-weight: bold;
}
select {
padding: 8px 12px;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 16px;
}
button {
padding: 10px 20px;
background-color: #e74c3c;
color: white;
border: none;
border-radius: 4px;
font-size: 16px;
cursor: pointer;
transition: background-color 0.3s;
}
button:hover {
background-color: #c0392b;
}
.results {
margin-bottom: 30px;
}
.result-title {
font-size: 18px;
font-weight: bold;
margin-bottom: 10px;
color: #3498db;
}
.ticket {
background-color: #f9f9f9;
border: 1px solid #ddd;
border-radius: 8px;
padding: 15px;
margin-bottom: 15px;
display: flex;
align-items: center;
gap: 15px;
}
.ticket .note {
font-weight: bold;
min-width: 60px;
}
.numbers {
display: flex;
align-items: center;
gap: 8px;
flex: 1;
}
.number {
width: 36px;
height: 36px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
font-size: 14px;
}
.front-number {
background-color: #e74c3c;
color: white;
}
.back-number {
background-color: #3498db;
color: white;
}
.history {
margin-top: 40px;
}
.history-title {
font-size: 18px;
font-weight: bold;
margin-bottom: 10px;
color: #9b59b6;
}
.history-list {
max-height: 300px;
overflow-y: auto;
border: 1px solid #ddd;
border-radius: 8px;
padding: 15px;
}
.history-item {
background-color: #f9f9f9;
border: 1px solid #ddd;
border-radius: 8px;
padding: 10px;
margin-bottom: 10px;
}
.history-item .time {
font-size: 12px;
color: #999;
margin-bottom: 5px;
}
.胆码过滤 {
margin: 30px 0;
padding: 20px;
background-color: #f9f9f9;
border-radius: 8px;
border: 1px solid #ddd;
}
.胆码过滤 h3 {
margin-bottom: 15px;
color: #3498db;
}
.胆码-group,
.过滤-group {
margin-bottom: 15px;
}
.胆码-group label,
.过滤-group label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
.胆码-group input,
.过滤-group input {
width: 100%;
padding: 8px 12px;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 16px;
}
@media (max-width: 600px) {
.controls {
flex-direction: column;
gap: 10px;
}
.container {
margin: 10px;
padding: 15px;
}
}
</style>
</head>
<body>
<div class="container">
<h1>大乐透机选程序</h1>
<div class="controls">
<div class="control-group">
<label for="ticket-count">选择注数:</label>
<select id="ticket-count">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
</div>
<button id="generate-btn">生成号码</button>
<button id="clear-history-btn">清空历史</button>
</div>
<div class="胆码过滤">
<h3>胆码设置</h3>
<div class="胆码-group">
<label>红球定胆 (1-35, 最多5个):</label>
<input type="text" id="red-dan" placeholder="例如: 01,02,03">
</div>
<div class="胆码-group">
<label>蓝球定胆 (1-12, 最多2个):</label>
<input type="text" id="blue-dan" placeholder="例如: 01,02">
</div>
<h3>号码过滤</h3>
<div class="过滤-group">
<label>过滤红球 (1-35):</label>
<input type="text" id="red-filter" placeholder="例如: 01,02,03">
</div>
<div class="过滤-group">
<label>过滤蓝球 (1-12):</label>
<input type="text" id="blue-filter" placeholder="例如: 01,02">
</div>
</div>
<div class="results">
<div class="result-title">生成结果</div>
<div id="results-container"></div>
</div>
<div class="history">
<div class="history-title">历史记录</div>
<div id="history-container" class="history-list"></div>
</div>
</div>
<script>
// 解析输入的号码
function parseNumbers(input) {
if (!input) return [];
return input.split(',').map(num => parseInt(num.trim())).filter(num => !isNaN(num));
}
// 生成随机号码的函数
function generateNumbers() {
// 获取定胆和过滤号码
const redDan = parseNumbers(document.getElementById('red-dan').value);
const blueDan = parseNumbers(document.getElementById('blue-dan').value);
const redFilter = parseNumbers(document.getElementById('red-filter').value);
const blueFilter = parseNumbers(document.getElementById('blue-filter').value);
// 生成前区号码(1-35)
const frontNumbers = [...redDan];
while (frontNumbers.length < 5) {
const num = Math.floor(Math.random() * 35) + 1;
if (!frontNumbers.includes(num) && !redFilter.includes(num)) {
frontNumbers.push(num);
}
}
frontNumbers.sort((a, b) => a - b);
// 生成后区号码(1-12)
const backNumbers = [...blueDan];
while (backNumbers.length < 2) {
const num = Math.floor(Math.random() * 12) + 1;
if (!backNumbers.includes(num) && !blueFilter.includes(num)) {
backNumbers.push(num);
}
}
backNumbers.sort((a, b) => a - b);
return { frontNumbers, backNumbers };
}
// 显示生成的号码
function displayResults(tickets) {
const container = document.getElementById('results-container');
container.innerHTML = '';
tickets.forEach((ticket, index) => {
const ticketElement = document.createElement('div');
ticketElement.className = 'ticket';
ticketElement.innerHTML = `
<div class="note">第 ${index + 1} 注</div>
<div class="numbers">
${ticket.frontNumbers.map(num => `<span class="number front-number">${num.toString().padStart(2, '0')}</span>`).join('')}
${ticket.backNumbers.map(num => `<span class="number back-number">${num.toString().padStart(2, '0')}</span>`).join('')}
</div>
`;
container.appendChild(ticketElement);
});
}
// 添加到历史记录
function addToHistory(tickets) {
const history = JSON.parse(localStorage.getItem('dalottery_history') || '[]');
const newRecord = {
id: Date.now(),
time: new Date().toLocaleString(),
tickets: tickets
};
history.unshift(newRecord);
// 只保留最近10条记录
if (history.length > 10) {
history.splice(10);
}
localStorage.setItem('dalottery_history', JSON.stringify(history));
displayHistory();
}
// 显示历史记录
function displayHistory() {
const container = document.getElementById('history-container');
const history = JSON.parse(localStorage.getItem('dalottery_history') || '[]');
if (history.length === 0) {
container.innerHTML = '<p>暂无历史记录</p>';
return;
}
container.innerHTML = '';
history.forEach(record => {
const itemElement = document.createElement('div');
itemElement.className = 'history-item';
const ticketsHtml = record.tickets.map((ticket, index) => `
<div>第 ${index + 1} 注:
${ticket.frontNumbers.map(num => num.toString().padStart(2, '0')).join(' ')} +
${ticket.backNumbers.map(num => num.toString().padStart(2, '0')).join(' ')}
</div>
`).join('');
itemElement.innerHTML = `
<div class="time">${record.time}</div>
${ticketsHtml}
`;
container.appendChild(itemElement);
});
}
// 清空历史记录
function clearHistory() {
localStorage.removeItem('dalottery_history');
displayHistory();
}
// 生成按钮点击事件
document.getElementById('generate-btn').addEventListener('click', () => {
const count = parseInt(document.getElementById('ticket-count').value);
const tickets = [];
for (let i = 0; i < count; i++) {
tickets.push(generateNumbers());
}
displayResults(tickets);
addToHistory(tickets);
});
// 清空历史按钮点击事件
document.getElementById('clear-history-btn').addEventListener('click', clearHistory);
// 页面加载时显示历史记录
window.onload = displayHistory;
</script>
</body>
</html>