diff --git a/app/MyController.php b/app/MyController.php index e82cc2f..b839b3d 100755 --- a/app/MyController.php +++ b/app/MyController.php @@ -37,6 +37,19 @@ abstract class MyController extends BaseController return json($this->renderJson($status, $msg, $data)); } + /** + * 返回layui.table格式的数据 + */ + protected function renderTable($msg = 'success', $count = 0, $data = [], $code = 0) + { + return json([ + 'code' => $code, + 'msg' => $msg, + 'count' => $count, + 'data' => $data + ]); + } + /** * 获取post数据 (数组) */ diff --git a/app/admin/controller/Goods.php b/app/admin/controller/Goods.php index 86b135b..deb155c 100755 --- a/app/admin/controller/Goods.php +++ b/app/admin/controller/Goods.php @@ -20,25 +20,56 @@ class Goods extends Base */ public function goods(Request $request) { - $title = trim(input('get.title')); - $status = trim(input('get.status')); - $type = trim(input('get.type')); - $whe = array(); - if ($title) { - $whe[] = ['title', 'like', '%' . $title . '%']; - } - if ($status) { - $whe[] = ['status', '=', $status]; - } - if ($type) { - $whe[] = ['type', '=', $type]; - } else { - $whe[] = ['type', 'notIn', [4, 7]]; - } - $field = "*"; - $order = "id desc"; - $data = GoodsModel::getList($whe, $field, $order, $this->page); + return View::fetch("Goods/goods"); + } + + /** + * 获取盒子列表数据(前后端分离接口) + */ + public function getGoodsList(Request $request) + { + $page = $request->param('page/d', 1); + $limit = $request->param('limit/d', 20); + $title = $request->param('title/s', ''); + $status = $request->param('status/s', ''); + $type = $request->param('type/s', ''); + + // 构建查询条件 + $where = []; + if (!empty($title)) { + $where[] = ['title', 'like', "%{$title}%"]; + } + if ($status !== '') { + $where[] = ['status', '=', $status]; + } + if ($type !== '') { + $where[] = ['type', '=', $type]; + } + + $query = GoodsModel::where($where)->order('id desc'); + $count = $query->count(); + + $list = $query->page($page, $limit)->select()->toArray(); + + // 处理图片路径 + foreach ($list as &$item) { + $item['imgurl'] = imageUrl($item['imgurl']); + if (!empty($item['imgurl_detail'])) { + $item['imgurl_detail'] = imageUrl($item['imgurl_detail']); + } + // 添加格式化时间 + $item['addtime_text'] = date('Y-m-d H:i', $item['addtime']); + } + + return $this->renderTable('获取成功', $count, $list); + } + + /** + * 获取盒子类型列表(前后端分离接口) + */ + public function getGoodsTypeList() + { // 查询可用的盒子类型 $goodsTypeList = Db::name('goods_type') ->field('value,sort_order,remark,is_fenlei,fl_name') @@ -47,11 +78,7 @@ class Goods extends Base ->select() ->toArray(); - View::assign('goodsTypeList', $goodsTypeList); - View::assign('list', $data['list']); - View::assign('count', $data['count']); - View::assign('page', $data['page']); - return View::fetch("Goods/goods"); + return $this->renderTable('获取成功', count($goodsTypeList), $goodsTypeList); } /** diff --git a/app/admin/route/app.php b/app/admin/route/app.php index c0c167c..97449ee 100755 --- a/app/admin/route/app.php +++ b/app/admin/route/app.php @@ -150,6 +150,8 @@ Route::rule('card_set', 'CardGoods/card_set', 'GET|POST'); #Goods.php盒子管理 #============================ Route::rule('goods', 'Goods/goods', 'GET|POST'); +Route::rule('api/goods/list', 'Goods/getGoodsList', 'GET'); +Route::rule('api/goods/types', 'Goods/getGoodsTypeList', 'GET'); Route::rule('goods_add', 'Goods/goods_add', 'GET|POST'); Route::rule('goods_edit', 'Goods/goods_edit', 'GET|POST'); Route::rule('goods_del', 'Goods/goods_del', 'GET|POST'); diff --git a/app/admin/view/Goods/goods.html b/app/admin/view/Goods/goods.html index c869a7d..621eca0 100755 --- a/app/admin/view/Goods/goods.html +++ b/app/admin/view/Goods/goods.html @@ -1,212 +1,286 @@ {include file="Public:header2"/} -
-
-
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
- +
+
+
+
+
+
+
- - -
- -
- 添加盒子 - 自动下架日志 - 共有数据: {$count}条 +
+
+
- - - - - - - - - - - - - - - - - - - - - - - - - {volist name="list" id="vo"} - - - - - - - - - - - - - - - - - - - {/volist} - - {if condition="empty($list)"} - - - - {/if} - - -
盒子ID盒子类型盒子名称盒子价格盒子图片盒子详情图片盒子套数锁箱模式首页显示自动下架 - 擂台赏
抽全局赏数量 -
排序状态添加时间操作
- {if condition="$vo['type'] eq 1"} -
- {$vo['id']} -
- {elseif condition="$vo['type'] eq 11"} -
- {$vo['id']} -
- - {else } - - {$vo['id']} - {/if} -
- {if condition="$vo['type'] eq 1"} - - {elseif condition="$vo['type'] eq 2"} - - {elseif condition="$vo['type'] eq 3"} - - {elseif condition="$vo['type'] eq 5"} - - {elseif condition="$vo['type'] eq 6"} - - {elseif condition="$vo['type'] eq 8"} - - {elseif condition="$vo['type'] eq 9"} - - {elseif condition="$vo['type'] eq 10"} - - {elseif condition="$vo['type'] eq 11"} - - {/if} - {$vo['title']}{$vo['price']} - {if $vo['imgurl_detail']}{/if}{if $vo['stock'] gt 0}{$vo['stock']}{/if} - {if condition="$vo['lock_is'] eq 1"} - -
- - {/if} -
- {if $vo['show_is'] eq 1} - - {/if} - - {if $vo['is_auto_xiajia'] eq 1} - -
- -
- - {else} - - {/if} -
{if $vo['prize_num'] gt 0}{$vo['prize_num']}{/if}{$vo['sort']} - {if $vo['status'] eq 1} - - - {elseif $vo['status'] eq 2} - - - {elseif $vo['status'] eq 3} - - {/if} - {$vo['addtime']|date="Y-m-d H:i"} - - 编辑 - -
- 奖品 -
- 同步 -
- - 清空抽奖 - -
- - 删除 - -
暂时没有数据!
-
- {$page|raw} +
+
+
+ +
+
+
+
+ +
+
+ + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + {include file="Public:footer"/} + \ No newline at end of file diff --git a/app/admin/view/Goods/goods_add.html b/app/admin/view/Goods/goods_add.html index 2f3d0ec..34111bd 100755 --- a/app/admin/view/Goods/goods_add.html +++ b/app/admin/view/Goods/goods_add.html @@ -13,7 +13,8 @@
{volist name="goodsTypeList" id="vo"} - + {/volist}
@@ -57,9 +58,8 @@
- +
@@ -72,7 +72,8 @@
@@ -203,20 +204,24 @@
- - + +
@@ -251,14 +256,14 @@
{include file="Public:footer"/} + layui.use([' form', 'layedit', 'laydate', 'jquery'], function () { + let form = layui.form, $ = layui.jquery, + layer = layui.layer; // 自动下架开关切换事件 form.on('radio(autoXiajia)', function(data){ + if (data.value == "1") { $('.xiajia-config').show(); } else { + $('.xiajia-config').hide(); + } + }); // 其他初始化逻辑 // ... 现有代码 ... }); @@ -520,7 +514,8 @@ layer.msg(data.msg, { icon: 1, time: 1500 }, function () { var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引 parent.layer.close(index); - parent.location.reload(); + // parent.location.reload(); + parent.table.reload('goodsTable'); }); } else { layer.msg(data.msg, { icon: 2, anim: 6, time: 1500 }, function () { diff --git a/app/admin/view/User/index.html b/app/admin/view/User/index.html index df98e13..a3e40da 100755 --- a/app/admin/view/User/index.html +++ b/app/admin/view/User/index.html @@ -546,12 +546,7 @@ font-weight: bold; } - .layui-table td { - padding: 10px 15px; - /* 调整单元格内边距 */ - height: 150px !important; - } - + /* 充值按钮样式 */ .layui-table .layui-btn-xs { margin-top: 5px; @@ -609,6 +604,12 @@ padding: 0px 0; } + .layui-table td { + padding: 10px 15px; + /* 调整单元格内边距 */ + height: 150px !important; + } + .layui-table thead th { height: 30px !important;