Browse Source

积分日志、优化后台搜索框

master
wanghongjun 1 year ago
parent
commit
95737594df
  1. 17
      app/admin/controller/liveroom/Task.php
  2. 37
      app/admin/controller/user/Userpointslog.php
  3. 36
      app/admin/model/UserPointsLog.php
  4. 10
      app/admin/view/user/userpointslog/index.html
  5. 4
      public/static/admin/js/liveroom/index.js
  6. 10
      public/static/admin/js/user/admin.js
  7. 2
      public/static/admin/js/user/ip.js
  8. 2
      public/static/admin/js/user/ipuser.js
  9. 40
      public/static/admin/js/user/userpointslog.js

17
app/admin/controller/liveroom/Task.php

@ -19,6 +19,22 @@ class Task extends AdminController
$this->model = new TaskModel();
}
protected static function indexWhere(&$where)
{
if ($where) {
foreach ($where as $key => $w) {
if ($w[0] == 'add_uid') {
$uid = User::where('nick_name', $w[1], $w[2])->column('uid');
$where[$key] = ['add_uid', 'in', $uid ?: [0]];
}
if ($w[0] == 'assign_uid') {
$uid = User::where('nick_name', $w[1], $w[2])->column('uid');
$where[$key] = ['assign_uid', 'in', $uid ?: [0]];
}
}
}
}
public function index()
{
if ($this->request->isAjax()) {
@ -26,6 +42,7 @@ class Task extends AdminController
return $this->selectList();
}
list($page, $limit, $where) = $this->buildTableParames();
$this->indexWhere($where);
$count = $this->model
->where($where)
->count();

37
app/admin/controller/user/Userpointslog.php

@ -0,0 +1,37 @@
<?php
namespace app\admin\controller\user;
use app\common\controller\AdminController;
use app\admin\model\UserPointsLog as UserPointsLogModel;
use think\App;
class Userpointslog extends AdminController
{
public function __construct(App $app)
{
parent::__construct($app);
$this->model = new UserPointsLogModel();
}
public function index()
{
if ($this->request->isAjax()) {
if (input('selectFields')) {
return $this->selectList();
}
list($page, $limit, $where) = $this->buildTableParames();
$param = ['page' => $page, 'limit' => $limit];
$pageList = UserPointsLogModel::getPageList($param, $where, '');
$data = [
'code' => 0,
'msg' => '',
'count' => $pageList['count'],
'data' => $pageList['data']
];
return json($data);
}
return $this->fetch();
}
}

36
app/admin/model/UserPointsLog.php

@ -0,0 +1,36 @@
<?php
namespace app\admin\model;
use app\common\model\TimeModel;
class UserPointsLog extends TimeModel
{
protected static function indexWhere(&$where)
{
if ($where) {
foreach ($where as $key => $w) {
if ($w[0] == 'username') {
$uid = User::where('nick_name', $w[1], $w[2])->column('uid');
$where[$key] = ['uid', 'in', $uid ?: [0]];
}
}
}
}
public static function getPageList(array $param = [], array $where = [], $field = '*'): array
{
$page = $param['page'] ?? 1;
$limit = $param['limit'] ?? 10;
self::indexWhere($where);
$order = 'id desc';
$count = self::where($where)->count();
$list = self::where($where)->field($field)->order($order)->page($page, $limit)->select()->toArray();
foreach ($list as &$item) {
$item['username'] = User::getUserValue($item['uid']);
$item['avatar'] = User::getUserValue($item['uid'], 'avatar');
}
return ['data' => $list, 'count' => $count];
}
}

10
app/admin/view/user/userpointslog/index.html

@ -0,0 +1,10 @@
<div class="layuimini-container">
<div class="layuimini-main">
<table id="currentTable" class="layui-table layui-hide"
data-auth-add="{:auth('user.userpointslog/add')}"
data-auth-edit="{:auth('user.userpointslog/edit')}"
data-auth-delete="{:auth('user.userpointslog/delete')}"
lay-filter="currentTable">
</table>
</div>
</div>

4
public/static/admin/js/liveroom/index.js

@ -25,8 +25,8 @@ define(["jquery", "easy-admin"], function ($, ea) {
{type: "checkbox"},
{field: 'id', width: 80, title: '编号'},
{field: 'room_id', minWidth: 80, title: '房间号'},
{field: 'anchor_information', minWidth: 80, title: '主播信息'},
{field: 'link', minWidth: 80, title: '直播间链接'},
{field: 'anchor_information', minWidth: 80, title: '主播信息', search: false},
{field: 'link', minWidth: 80, title: '直播间链接', search: false},
{field: 'status', title: '状态', width: 100, search: 'select', selectList: {0: '禁用', 1: '启用'}, templet: ea.table.switch},
{field: 'create_time', minWidth: 80, title: '创建时间', search: 'range'},
{

10
public/static/admin/js/user/admin.js

@ -24,7 +24,13 @@ define(["jquery", "easy-admin"], function ($, ea) {
{field: 'nick_name', minWidth: 80, title: '用户昵称'},
{field: 'avatar', minWidth: 80, title: '头像', search: false, templet: ea.table.image},
{field: 'mobile', minWidth: 80, title: '手机号'},
{field: 'last_login_time', minWidth: 80, title: '最后登录时间'},
{field: 'balance', minWidth: 80, title: '可用余额', templet: function (d) {
return '<button type="button" class="layui-btn layui-btn-xs layui-btn-normal">'+d.balance+'</button>';
}},
{field: 'points', minWidth: 80, title: '可用积分', templet: function (d) {
return '<button type="button" class="layui-btn layui-btn-xs layui-btn-warm">'+d.points+'</button>';
}},
{field: 'last_login_time', minWidth: 80, title: '最后登录时间', search: 'time'},
{field: 'status', title: '状态', width: 100, search: 'select', selectList: {0: '禁用', 1: '启用'}, templet: ea.table.switch},
{field: 'create_time', minWidth: 80, title: '创建时间', search: 'range'},
{
@ -59,4 +65,4 @@ define(["jquery", "easy-admin"], function ($, ea) {
}
};
return Controller;
});
});

2
public/static/admin/js/user/ip.js

@ -39,7 +39,7 @@ define(["jquery", "easy-admin"], function ($, ea) {
{field: 'city', width: 100, title: '城市'},
{field: 'isp', minWidth: 80, title: '运营商'},
{field: 'out_ip', minWidth: 80, title: '退出IP'},
{field: 'expire_time', width: 200, title: '到期时间'},
{field: 'expire_time', width: 200, title: '到期时间', search: 'range'},
{field: 'status', title: '状态', width: 100, search: 'select', selectList: {0: '禁用', 1: '启用'}, templet: ea.table.switch},
{field: 'create_time', minWidth: 80, title: '创建时间', search: 'range'},
{

2
public/static/admin/js/user/ipuser.js

@ -32,7 +32,7 @@ define(["jquery", "easy-admin", "tableSelect"], function ($, ea) {
{field: 'ip', minWidth: 80, title: 'IP'},
{field: 'count', minWidth: 80, title: '使用次数'},
{field: 'status', title: '状态', width: 100, search: 'select', selectList: {0: '禁用', 1: '启用'}, templet: ea.table.switch},
{field: 'ip_status', title: 'IP状态', width: 80, templet: function (d) {
{field: 'ip_status', title: 'IP状态', width: 80, search: 'select', selectList: {0: '禁用', 1: '启用'}, templet: function (d) {
let html = '';
if (d.ip_status == 1) {
html = '<button type="button" class="layui-btn layui-bg-blue layui-btn-xs">启用</button>'

40
public/static/admin/js/user/userpointslog.js

@ -0,0 +1,40 @@
define(["jquery", "easy-admin"], function ($, ea) {
let init = {
table_elem: '#currentTable',
table_render_id: 'currentTableRenderId',
index_url: 'user.userpointslog/index',
};
let LogController = {
index: function () {
ea.table.render({
init: init,
toolbar: [
'refresh'
],
cols: [[
{type: "checkbox"},
{field: 'id', width: 80, title: 'ID'},
{field: 'username', width: 100, title: '用户名'},
{field: 'avatar', width: 140, title: '用户头像', search: false, templet: ea.table.image},
{field: 'value', width: 120, title: '变动积分', templet: function (d) {
if (d.value > 0) {
return '<button type="button" class="layui-btn layui-btn-xs layui-btn-danger">+'+d.value+'</button>';
} else {
return '<button type="button" class="layui-btn layui-btn-xs">'+d.value+'</button>';
}
}},
{field: 'create_time', width: 160, title: '创建时间', search: 'range'},
{field: 'describe', minWidth: 80, title: '描述/说明', search: false},
{field: 'remark', minWidth: 80, title: '备注', search: false}
]],
});
ea.listen();
}
};
return LogController;
});
Loading…
Cancel
Save