feat(history): 新增特码冷热查询功能 — 选定某一期向前y期判定冷热号
在history页面添加「特码冷热」按钮,用户可选择指定期号并设定向前期数 系统统计该期特码在向前范围内的出现频率,与平均值对比判定冷/温/热号
This commit is contained in:
@@ -87,6 +87,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
Controller.api.showAnalysisDialog('tailNumbers');
|
||||
});
|
||||
|
||||
// 特码冷热按钮事件
|
||||
$(document).off('click', '.btn-specialhotcold').on('click', '.btn-specialhotcold', function () {
|
||||
Controller.api.showSpecialHotColdDialog();
|
||||
});
|
||||
|
||||
// 综合统计面板按钮事件
|
||||
$(document).off('click', '.btn-dashboard').on('click', '.btn-dashboard', function () {
|
||||
Controller.api.showDashboard();
|
||||
@@ -584,6 +589,146 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
$('#missing-result', layero).html('').append(container);
|
||||
},
|
||||
|
||||
/**
|
||||
* 特码冷热查询(指定期号向前y期判定)
|
||||
*/
|
||||
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">' +
|
||||
' <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>';
|
||||
|
||||
Layer.open({
|
||||
type: 1,
|
||||
title: '特码冷热查询',
|
||||
area: ['650px', '550px'],
|
||||
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);
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
querySpecialHotCold: function (expect, 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},
|
||||
dataType: 'json',
|
||||
success: function (ret) {
|
||||
if (ret.code == 1) {
|
||||
Controller.api.renderSpecialHotCold(ret.data, layero);
|
||||
} else {
|
||||
$('#shc-result', layero).html('<div class="alert alert-danger">' + (ret.msg || __('Query failed')) + '</div>');
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
$('#shc-result', layero).html('<div class="alert alert-danger">' + __('Query failed') + '</div>');
|
||||
},
|
||||
complete: function () {
|
||||
$btn.prop('disabled', false);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
renderSpecialHotCold: function (data, 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 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>';
|
||||
}
|
||||
|
||||
html += '</div>';
|
||||
$('#shc-result', layero).html(html);
|
||||
},
|
||||
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user