diff --git a/application/admin/view/history/index.html b/application/admin/view/history/index.html index 433f01a..e9a1500 100644 --- a/application/admin/view/history/index.html +++ b/application/admin/view/history/index.html @@ -18,6 +18,7 @@ {:__('Consecutive')} {:__('Tail Numbers')} 特码冷热 + 筛号器 diff --git a/public/assets/js/backend/history.js b/public/assets/js/backend/history.js index 6f6d684..6b81ecf 100644 --- a/public/assets/js/backend/history.js +++ b/public/assets/js/backend/history.js @@ -97,6 +97,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin $(document).off('click', '.btn-dashboard').on('click', '.btn-dashboard', function () { Controller.api.showDashboard(); }); + + // 筛号器按钮事件 + $(document).off('click', '.btn-numberfilter').on('click', '.btn-numberfilter', function () { + Controller.api.showNumberFilterDialog(); + }); }, add: function () { Controller.api.bindevent(); @@ -735,6 +740,154 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin $('#shc-result', layero).html(html); }, + /** + * 筛号器弹窗 + */ + showNumberFilterDialog: function () { + var html = '' + + '
' + + '
' + + '
' + + ' ' + + ' ' + + '
' + + ' ' + + '
' + + '
' + + ' ' + + '
' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '
' + + '
' + + '
' + + ' ' + + '
' + + ' ' + + ' ' + + ' ' + + '
' + + '
' + + '
' + + '
'; + + Layer.open({ + type: 1, + title: '筛号器', + area: ['700px', '600px'], + content: html, + shadeClose: true, + success: function (layero, index) { + // 渲染号码网格 + Controller.api.renderNumberFilterGrid(layero); + + // 尾号下拉选择 + $('#nf-tail', layero).on('change', function () { + Controller.api.applyNumberFilters(layero); + }); + + // 生肖按钮点击 + $('.nf-zodiac', layero).on('click', function () { + var $btn = $(this); + $btn.toggleClass('btn-default').toggleClass('btn-gray'); + Controller.api.applyNumberFilters(layero); + }); + + // 波色按钮点击 + $('.nf-color', layero).on('click', function () { + var $btn = $(this); + $btn.toggleClass('btn-default').toggleClass('btn-gray'); + Controller.api.applyNumberFilters(layero); + }); + + // 重置按钮 + $('.btn-nf-reset', layero).on('click', function () { + $('#nf-tail', layero).val(''); + $('.nf-zodiac', layero).removeClass('btn-gray').addClass('btn-default'); + $('.nf-color', layero).removeClass('btn-gray').addClass('btn-default'); + Controller.api.applyNumberFilters(layero); + }); + } + }); + }, + + /** + * 渲染筛号器号码网格 + */ + renderNumberFilterGrid: function (layero) { + var html = ''; + for (var num = 1; num <= 49; num++) { + var color = Controller.api.getColorByNum(num); + var animal = Controller.api.getAnimalByNum(num); + html += '
' + + '' + num + '' + + '
' + animal + '
' + + '
'; + } + $('#nf-numbers', layero).html(html); + }, + + /** + * 应用筛号器过滤条件 + */ + applyNumberFilters: function (layero) { + var tailVal = $('#nf-tail', layero).val(); + // 收集被点击(置灰)的生肖 + var excludedZodiacs = []; + $('.nf-zodiac.btn-gray', layero).each(function () { + excludedZodiacs.push($(this).data('zodiac')); + }); + // 收集被点击(置灰)的波色 + var excludedColors = []; + $('.nf-color.btn-gray', layero).each(function () { + excludedColors.push($(this).data('color')); + }); + + $('.nf-number', layero).each(function () { + var $num = $(this); + var num = parseInt($num.data('num')); + var tail = $num.data('tail'); + var animal = $num.data('animal'); + var color = $num.data('color'); + + var hidden = false; + + // 尾号筛选:选择了具体尾号则隐藏不匹配的 + if (tailVal !== '' && parseInt(tailVal) !== tail) { + hidden = true; + } + // 排除的生肖 + if (excludedZodiacs.indexOf(animal) !== -1) { + hidden = true; + } + // 排除的波色 + if (excludedColors.indexOf(color) !== -1) { + hidden = true; + } + + if (hidden) { + $num.css('opacity', '0.25').css('filter', 'grayscale(100%)'); + } else { + $num.css('opacity', '1').css('filter', 'none'); + } + }); + }, + bindevent: function () { Form.api.bindevent($("form[role=form]")); },