feat: show zodiac animal below each number ball in history table
This commit is contained in:
@@ -29,4 +29,17 @@ class Num extends Backend
|
||||
}
|
||||
$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,29 +16,31 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 从后端获取颜色映射
|
||||
// 从后端获取颜色和生肖映射
|
||||
Controller.api.loadColorMap(function () {
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'expect',
|
||||
sortName: 'expect',
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{field: 'expect', title: __('Expect')},
|
||||
{field: 'num1', title: __('Num1'), formatter: Controller.api.formatter.numBall},
|
||||
{field: 'num2', title: __('Num2'), formatter: Controller.api.formatter.numBall},
|
||||
{field: 'num3', title: __('Num3'), formatter: Controller.api.formatter.numBall},
|
||||
{field: 'num4', title: __('Num4'), formatter: Controller.api.formatter.numBall},
|
||||
{field: 'num5', title: __('Num5'), formatter: Controller.api.formatter.numBall},
|
||||
{field: 'num6', title: __('Num6'), formatter: Controller.api.formatter.numBall},
|
||||
{field: 'num7', title: __('Num7'), formatter: Controller.api.formatter.numBall},
|
||||
{field: 'openTime', title: __('OpenTime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
||||
Controller.api.loadAnimalMap(function () {
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'expect',
|
||||
sortName: 'expect',
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{field: 'expect', title: __('Expect')},
|
||||
{field: 'num1', title: __('Num1'), formatter: Controller.api.formatter.numBall},
|
||||
{field: 'num2', title: __('Num2'), formatter: Controller.api.formatter.numBall},
|
||||
{field: 'num3', title: __('Num3'), formatter: Controller.api.formatter.numBall},
|
||||
{field: 'num4', title: __('Num4'), formatter: Controller.api.formatter.numBall},
|
||||
{field: 'num5', title: __('Num5'), formatter: Controller.api.formatter.numBall},
|
||||
{field: 'num6', title: __('Num6'), formatter: Controller.api.formatter.numBall},
|
||||
{field: 'num7', title: __('Num7'), formatter: Controller.api.formatter.numBall},
|
||||
{field: 'openTime', title: __('OpenTime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
||||
]
|
||||
]
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
Table.api.bindevent(table);
|
||||
Table.api.bindevent(table);
|
||||
});
|
||||
});
|
||||
|
||||
// 遗漏号码按钮事件
|
||||
@@ -55,6 +57,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
api: {
|
||||
colorMap: {},
|
||||
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 '';
|
||||
var num = parseInt(value);
|
||||
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;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user