Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5e8d1e4895 | |||
| 3d22f3b2c4 |
@@ -29,4 +29,17 @@ class Num extends Backend
|
|||||||
}
|
}
|
||||||
$this->success($map);
|
$this->success($map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回数字与生肖的映射关系
|
||||||
|
*/
|
||||||
|
public function getAnimalMap()
|
||||||
|
{
|
||||||
|
$list = $this->model->field('num,animal')->select();
|
||||||
|
$map = [];
|
||||||
|
foreach ($list as $item) {
|
||||||
|
$map[$item['num']] = $item['animal'];
|
||||||
|
}
|
||||||
|
$this->success($map);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||||||
|
|
||||||
var table = $("#table");
|
var table = $("#table");
|
||||||
|
|
||||||
// 从后端获取颜色映射
|
// 从后端获取颜色和生肖映射
|
||||||
Controller.api.loadColorMap(function () {
|
Controller.api.loadColorMap(function () {
|
||||||
|
Controller.api.loadAnimalMap(function () {
|
||||||
table.bootstrapTable({
|
table.bootstrapTable({
|
||||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||||
pk: 'expect',
|
pk: 'expect',
|
||||||
@@ -40,6 +41,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||||||
|
|
||||||
Table.api.bindevent(table);
|
Table.api.bindevent(table);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// 遗漏号码按钮事件
|
// 遗漏号码按钮事件
|
||||||
$(document).off('click', '.btn-missingnum').on('click', '.btn-missingnum', function () {
|
$(document).off('click', '.btn-missingnum').on('click', '.btn-missingnum', function () {
|
||||||
@@ -55,6 +57,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||||||
api: {
|
api: {
|
||||||
colorMap: {},
|
colorMap: {},
|
||||||
colorMapLoaded: false,
|
colorMapLoaded: false,
|
||||||
|
animalMap: {},
|
||||||
|
animalMapLoaded: false,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从后端加载颜色映射并缓存
|
* 从后端加载颜色映射并缓存
|
||||||
@@ -78,6 +82,35 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从后端加载生肖映射并缓存
|
||||||
|
*/
|
||||||
|
loadAnimalMap: function (callback) {
|
||||||
|
if (Controller.api.animalMapLoaded) {
|
||||||
|
callback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
url: 'num/getAnimalMap',
|
||||||
|
type: 'GET',
|
||||||
|
dataType: 'json',
|
||||||
|
success: function (ret) {
|
||||||
|
if (ret.code == 1) {
|
||||||
|
Controller.api.animalMap = ret.msg;
|
||||||
|
}
|
||||||
|
Controller.api.animalMapLoaded = true;
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据数字从映射表中获取生肖
|
||||||
|
*/
|
||||||
|
getAnimalByNum: function (num) {
|
||||||
|
return Controller.api.animalMap[num] || '';
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据数字从映射表中获取颜色
|
* 根据数字从映射表中获取颜色
|
||||||
*/
|
*/
|
||||||
@@ -96,7 +129,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||||||
if (value === null || value === undefined || value === '') return '';
|
if (value === null || value === undefined || value === '') return '';
|
||||||
var num = parseInt(value);
|
var num = parseInt(value);
|
||||||
var color = Controller.api.getColorByNum(num);
|
var color = Controller.api.getColorByNum(num);
|
||||||
return '<span class="num-ball" style="display:inline-block;width:32px;height:32px;line-height:32px;text-align:center;border-radius:50%;color:#fff;background-color:' + color + ';font-weight:bold;">' + value + '</span>';
|
var animal = Controller.api.getAnimalByNum(num);
|
||||||
|
var html = '<div style="text-align:center;">' +
|
||||||
|
'<span class="num-ball" style="display:inline-block;width:32px;height:32px;line-height:32px;text-align:center;border-radius:50%;color:#fff;background-color:' + color + ';font-weight:bold;">' + value + '</span>';
|
||||||
|
if (animal) {
|
||||||
|
html += '<div style="font-size:10px;color:#666;line-height:1.2;">' + animal + '</div>';
|
||||||
|
}
|
||||||
|
html += '</div>';
|
||||||
|
return html;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -197,6 +237,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||||||
var container = $('<div style="display:flex;flex-wrap:wrap;gap:12px;"></div>');
|
var container = $('<div style="display:flex;flex-wrap:wrap;gap:12px;"></div>');
|
||||||
for (var i = 0; i < data.length; i++) {
|
for (var i = 0; i < data.length; i++) {
|
||||||
var color = Controller.api.getColorByNum(data[i].num);
|
var color = Controller.api.getColorByNum(data[i].num);
|
||||||
|
var animal = Controller.api.getAnimalByNum(data[i].num);
|
||||||
var $item = $('<div style="text-align:center;"></div>');
|
var $item = $('<div style="text-align:center;"></div>');
|
||||||
var $ball = $('<span class="num-ball"></span>').css({
|
var $ball = $('<span class="num-ball"></span>').css({
|
||||||
'display': 'inline-block',
|
'display': 'inline-block',
|
||||||
@@ -210,10 +251,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||||||
'font-weight': 'bold',
|
'font-weight': 'bold',
|
||||||
'font-size': '18px'
|
'font-size': '18px'
|
||||||
}).text(data[i].num);
|
}).text(data[i].num);
|
||||||
var $label = $('<div style="margin-top:5px;font-size:12px;color:#666;"></div>').text(
|
var $content = $('<div></div>').append($ball);
|
||||||
|
if (animal) {
|
||||||
|
$content.append($('<div style="margin-top:3px;font-size:11px;color:#666;line-height:1.2;"></div>').text(animal));
|
||||||
|
}
|
||||||
|
$content.append($('<div style="margin-top:3px;font-size:12px;color:#666;"></div>').text(
|
||||||
__('Missing') + ' ' + data[i].omit + ' ' + __('periods')
|
__('Missing') + ' ' + data[i].omit + ' ' + __('periods')
|
||||||
);
|
));
|
||||||
$item.append($ball).append($label);
|
$item.append($content);
|
||||||
container.append($item);
|
container.append($item);
|
||||||
}
|
}
|
||||||
$('#missing-result', layero).html('').append(container);
|
$('#missing-result', layero).html('').append(container);
|
||||||
|
|||||||
Reference in New Issue
Block a user