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);
|
$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;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user