fix(history): 重构特码冷热功能 — 改为弹窗列表展示每期相对于前N期的冷热状态
改为批量查询模式:每期特码相对于它前面N期的出现频率判定冷热 弹窗内以表格形式展示所有期号、特码球、冷热标签、次数、排名 支持调整向前期数(10-100),打开弹窗自动查询
This commit is contained in:
@@ -590,67 +590,48 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
},
|
||||
|
||||
/**
|
||||
* 特码冷热查询(指定期号向前y期判定)
|
||||
* 特码冷热列表(每期相对于前N期的冷热状态)
|
||||
*/
|
||||
showSpecialHotColdDialog: function () {
|
||||
var html = '<div style="padding:20px;">' +
|
||||
'<div class="form-group">' +
|
||||
' <label>期号:</label>' +
|
||||
' <select id="shc-expect" class="form-control" style="width:200px;display:inline-block;"></select>' +
|
||||
'</div>' +
|
||||
'<div class="form-group">' +
|
||||
'<div class="form-group" style="border-bottom:1px solid #eee;padding-bottom:10px;margin-bottom:10px;">' +
|
||||
' <label>向前期数:</label>' +
|
||||
' <input type="number" id="shc-lookback" class="form-control" value="30" min="10" max="100" style="width:120px;display:inline-block;">' +
|
||||
' <button class="btn btn-primary" id="btn-shc-query" style="margin-left:10px;"><i class="fa fa-search"></i> ' + __('Query') + '</button>' +
|
||||
'</div>' +
|
||||
'<div id="shc-result" style="margin-top:15px;"></div>' +
|
||||
'<div id="shc-result" style="margin-top:10px;max-height:500px;overflow-y:auto;"></div>' +
|
||||
'</div>';
|
||||
|
||||
Layer.open({
|
||||
type: 1,
|
||||
title: '特码冷热查询',
|
||||
area: ['650px', '550px'],
|
||||
title: '特码冷热列表',
|
||||
area: ['650px', '600px'],
|
||||
content: html,
|
||||
shadeClose: true,
|
||||
success: function (layero, index) {
|
||||
// 加载最近50期期号供选择
|
||||
$.ajax({
|
||||
url: 'history/specialTrend',
|
||||
type: 'GET',
|
||||
data: {periods: 50},
|
||||
dataType: 'json',
|
||||
success: function (ret) {
|
||||
if (ret.code == 1 && ret.data.expects) {
|
||||
var options = '';
|
||||
for (var i = 0; i < ret.data.expects.length; i++) {
|
||||
options += '<option value="' + ret.data.expects[i] + '">' + ret.data.expects[i] + '</option>';
|
||||
}
|
||||
$('#shc-expect', layero).html(options);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('#btn-shc-query', layero).on('click', function () {
|
||||
var expect = $('#shc-expect', layero).val();
|
||||
var lookback = parseInt($('#shc-lookback', layero).val()) || 30;
|
||||
Controller.api.querySpecialHotCold(expect, lookback, layero);
|
||||
Controller.api.querySpecialHotCold(lookback, layero);
|
||||
});
|
||||
// 打开时自动查询
|
||||
var lookback = parseInt($('#shc-lookback', layero).val()) || 30;
|
||||
Controller.api.querySpecialHotCold(lookback, layero);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
querySpecialHotCold: function (expect, lookback, layero) {
|
||||
querySpecialHotCold: function (lookback, layero) {
|
||||
var $btn = $('#btn-shc-query', layero);
|
||||
$btn.prop('disabled', true);
|
||||
$('#shc-result', layero).html('<div class="text-center"><i class="fa fa-spinner fa-spin"></i> ' + __('Loading') + '</div>');
|
||||
$.ajax({
|
||||
url: 'history/specialHotColdAction',
|
||||
type: 'GET',
|
||||
data: {expect: expect, lookback: lookback},
|
||||
data: {lookback: lookback},
|
||||
dataType: 'json',
|
||||
success: function (ret) {
|
||||
if (ret.code == 1) {
|
||||
Controller.api.renderSpecialHotCold(ret.data, layero);
|
||||
Controller.api.renderSpecialHotCold(ret.data, lookback, layero);
|
||||
} else {
|
||||
$('#shc-result', layero).html('<div class="alert alert-danger">' + (ret.msg || __('Query failed')) + '</div>');
|
||||
}
|
||||
@@ -664,68 +645,56 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
});
|
||||
},
|
||||
|
||||
renderSpecialHotCold: function (data, layero) {
|
||||
renderSpecialHotCold: function (data, lookback, layero) {
|
||||
var getColor = function (num) {
|
||||
return Controller.api.getColorByNum(num);
|
||||
};
|
||||
|
||||
var statusConfig = {
|
||||
'hot': {label: '🔥 热号', color: '#e74c3c', bg: '#fce4ec', desc: '出现频率高于平均值的1.5倍'},
|
||||
'cold': {label: '❄️ 冷号', color: '#3498db', bg: '#e3f2fd', desc: '出现频率低于平均值的0.5倍'},
|
||||
'normal': {label: '➡️ 温号', color: '#f39c12', bg: '#fff8e1', desc: '出现频率在正常范围内'}
|
||||
var statusTag = function (status) {
|
||||
var map = {
|
||||
'hot': '<span style="color:#e74c3c;font-weight:bold;">🔥 热号</span>',
|
||||
'cold': '<span style="color:#3498db;font-weight:bold;">❄ 冷号</span>',
|
||||
'normal': '<span style="color:#f39c12;font-weight:bold;">➜ 温号</span>',
|
||||
'unknown': '<span style="color:#999;">数据不足</span>'
|
||||
};
|
||||
return map[status] || '';
|
||||
};
|
||||
|
||||
var cfg = statusConfig[data.status] || statusConfig['normal'];
|
||||
|
||||
var html = '<div style="padding:15px;">';
|
||||
|
||||
// 主信息卡片
|
||||
html += '<div style="padding:20px;border-radius:8px;background:' + cfg.bg + ';margin-bottom:15px;">';
|
||||
html += '<div style="display:flex;align-items:center;justify-content:space-between;">';
|
||||
html += '<div>' +
|
||||
'<div style="font-size:14px;color:#666;">期号 <b>' + data.expect + '</b> 的特码</div>' +
|
||||
'<div style="margin-top:8px;">' +
|
||||
'<span style="display:inline-block;width:48px;height:48px;line-height:48px;text-align:center;border-radius:50%;color:#fff;background-color:' + getColor(data.specialNum) + ';font-size:20px;font-weight:bold;">' + data.specialNum + '</span>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
html += '<div style="text-align:right;">' +
|
||||
'<div style="font-size:24px;font-weight:bold;color:' + cfg.color + ';">' + cfg.label + '</div>' +
|
||||
'<div style="font-size:12px;color:#999;margin-top:4px;">' + cfg.desc + '</div>' +
|
||||
'</div>';
|
||||
html += '</div></div>';
|
||||
|
||||
// 统计数据
|
||||
html += '<div style="display:flex;gap:10px;margin-bottom:15px;">';
|
||||
html += '<div style="flex:1;text-align:center;padding:10px;background:#f5f5f5;border-radius:6px;">' +
|
||||
'<div style="font-size:22px;font-weight:bold;">' + data.count + '</div>' +
|
||||
'<div style="font-size:12px;color:#666;">近' + data.lookback + '期出现次数</div></div>';
|
||||
html += '<div style="flex:1;text-align:center;padding:10px;background:#f5f5f5;border-radius:6px;">' +
|
||||
'<div style="font-size:22px;font-weight:bold;">' + data.avgCount + '</div>' +
|
||||
'<div style="font-size:12px;color:#666;">平均出现次数</div></div>';
|
||||
html += '<div style="flex:1;text-align:center;padding:10px;background:#f5f5f5;border-radius:6px;">' +
|
||||
'<div style="font-size:22px;font-weight:bold;">第' + data.rank + '名</div>' +
|
||||
'<div style="font-size:12px;color:#666;">频率排名 (共' + data.totalPeriods + '期)</div></div>';
|
||||
html += '</div>';
|
||||
|
||||
// 热号/冷号参考
|
||||
if (data.hotNums && data.hotNums.length > 0) {
|
||||
html += '<div style="margin-bottom:10px;"><b style="color:#e74c3c;">🔥 热号 Top5</b><div style="display:flex;gap:6px;margin-top:5px;">';
|
||||
for (var i = 0; i < data.hotNums.length; i++) {
|
||||
var item = data.hotNums[i];
|
||||
html += '<span style="display:inline-block;width:32px;height:32px;line-height:32px;text-align:center;border-radius:50%;color:#fff;background-color:' + getColor(item.num) + ';font-weight:bold;font-size:14px;" title="' + item.count + '次">' + item.num + '</span>';
|
||||
}
|
||||
html += '</div></div>';
|
||||
}
|
||||
if (data.coldNums && data.coldNums.length > 0) {
|
||||
html += '<div><b style="color:#3498db;">❄️ 冷号 Top5</b><div style="display:flex;gap:6px;margin-top:5px;">';
|
||||
for (var i = 0; i < data.coldNums.length; i++) {
|
||||
var item = data.coldNums[i];
|
||||
html += '<span style="display:inline-block;width:32px;height:32px;line-height:32px;text-align:center;border-radius:50%;color:#fff;background-color:' + getColor(item.num) + ';font-weight:bold;font-size:14px;" title="' + item.count + '次">' + item.num + '</span>';
|
||||
}
|
||||
html += '</div></div>';
|
||||
if (!data || data.length === 0) {
|
||||
$('#shc-result', layero).html('<div class="alert alert-info">暂无数据</div>');
|
||||
return;
|
||||
}
|
||||
|
||||
html += '</div>';
|
||||
var html = '<div style="padding:0 5px;">';
|
||||
html += '<table class="table table-striped table-bordered table-hover" style="font-size:13px;">' +
|
||||
'<thead><tr>' +
|
||||
'<th style="text-align:center;width:120px;">期号</th>' +
|
||||
'<th style="text-align:center;width:60px;">特码</th>' +
|
||||
'<th style="text-align:center;width:80px;">冷热</th>' +
|
||||
'<th style="text-align:center;width:60px;">次数</th>' +
|
||||
'<th style="text-align:center;width:60px;">平均</th>' +
|
||||
'<th style="text-align:center;width:60px;">排名</th>' +
|
||||
'</tr></thead><tbody>';
|
||||
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var item = data[i];
|
||||
var rowClass = '';
|
||||
if (item.status === 'hot') rowClass = 'style="background:#fff5f5;"';
|
||||
else if (item.status === 'cold') rowClass = 'style="background:#f5f8ff;"';
|
||||
|
||||
html += '<tr ' + rowClass + '>' +
|
||||
'<td style="text-align:center;">' + item.expect + '</td>' +
|
||||
'<td style="text-align:center;">' +
|
||||
'<span style="display:inline-block;width:30px;height:30px;line-height:30px;text-align:center;border-radius:50%;color:#fff;background-color:' + getColor(item.specialNum) + ';font-weight:bold;font-size:14px;">' + item.specialNum + '</span>' +
|
||||
'</td>' +
|
||||
'<td style="text-align:center;">' + statusTag(item.status) + '</td>' +
|
||||
'<td style="text-align:center;">' + item.count + '</td>' +
|
||||
'<td style="text-align:center;">' + item.avgCount + '</td>' +
|
||||
'<td style="text-align:center;">' + item.rank + '</td>' +
|
||||
'</tr>';
|
||||
}
|
||||
|
||||
html += '</tbody></table></div>';
|
||||
$('#shc-result', layero).html(html);
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user