diff --git a/app/admin/controller/decoration/MenuDecorate.php b/app/admin/controller/decoration/MenuDecorate.php index 7eec93c3..63cf4f36 100644 --- a/app/admin/controller/decoration/MenuDecorate.php +++ b/app/admin/controller/decoration/MenuDecorate.php @@ -242,4 +242,73 @@ class MenuDecorate extends AdminBase{ 'shop_street_hide' => ConfigServer::get('decoration', 'shop_street_hide', 0) ]); } + + // 工具条列表 + public function toolsList() + { + if($this->request->isAjax()){ + $get = $this->request->get(); + $list = MenuDecorateLogic::toolLists($get); + return JsonServer::success('',$list); + } + } + + // 新增工具 + public function addTools(){ + if($this->request->isAjax()){ + $post = $this->request->post(); + $post['del'] = 0; + $post['decorate_type'] = $post['type']; + (new MenuDecorateValidate())->goCheck('Add',$post); + $result = MenuDecorateLogic::add_tools($post); + if($result){ + return JsonServer::success('添加成功'); + } + return JsonServer::error('添加失败'); + } + $type = $this->request->get('type'); + $menu_type = MenuEnum::INDEX; + if(2 == $type){ + $menu_type = MenuEnum::CENTRE; + } + return view('',['menu_list'=>$menu_type]); + } + + // 编辑工具 + public function editTools(){ + if($this->request->isAjax()){ + $post = $this->request->post(); + $post['del'] = 0; + (new MenuDecorateValidate())->goCheck('edit', $post); + $result = MenuDecorateLogic::edit_tools($post); + if($result){ + return JsonServer::success('修改成功'); + } + return JsonServer::error('修改失败'); + } + $id = $this->request->get('id'); + $detail = MenuDecorateLogic::getTools($id); + $type = $this->request->get('type'); + $menu_type = MenuEnum::INDEX; + if(2 == $type){ + $menu_type = MenuEnum::CENTRE; + } + return view('',['menu_list' => $menu_type, 'detail' => $detail]); + } + + // 切换工具状态 + public function swtichToolsStatus(){ + (new MenuDecorateValidate())->goCheck('swtich'); + $post = $this->request->post(); + MenuDecorateLogic::swtichToolsStatus($post); + return JsonServer::success('操作成功'); + } + + // 删除工具 + public function delTools(){ + $id = $this->request->post('id'); + (new MenuDecorateValidate())->goCheck('del'); + MenuDecorateLogic::delTools($id); + return JsonServer::success('删除成功'); + } } \ No newline at end of file diff --git a/app/admin/logic/decoration/MenuDecorateLogic.php b/app/admin/logic/decoration/MenuDecorateLogic.php index a66e8dc4..e24ab371 100644 --- a/app/admin/logic/decoration/MenuDecorateLogic.php +++ b/app/admin/logic/decoration/MenuDecorateLogic.php @@ -324,4 +324,73 @@ class MenuDecorateLogic extends Logic { return true; } + public static function toolLists($get){ + + $where[] = ['del','=',0]; + + $lists = Db::name('menu_tools') + ->where($where) + ->paginate(['list_rows'=>$get['limit'],'page'=>$get['page']]); + + $list = $lists->items(); + $count = $lists->total(); + foreach ($list as $key => $menu){ + $list[$key]['image'] = empty($list[$key]['image']) ? '' : UrlServer::getFileUrl($list[$key]['image']); + } + + return ['count'=>$count,'lists'=>$list]; + } + + // 添加工具 + public static function add_tools($post){ + $data = [ + 'name' => $post['name'], + 'image' => clearDomain($post['image']), + 'url' => $post['url'], + 'sort' => $post['sort'], + 'is_show' => $post['is_show'], + 'create_time' => time(), + ]; + return Db::name('menu_tools')->insert($data); + } + + // 获取工具数据 + public static function getTools($id) + { + $info = Db::name('menu_tools') + ->where(['del'=>0,'id'=>$id]) + ->find(); + $info['image'] = empty($info['image']) ? '' : UrlServer::getFileUrl($info['image']); + + return $info; + } + + // 编辑工具 + public static function edit_tools($post) + { + $data = [ + 'name' => $post['name'], + 'image' => clearDomain($post['image']), + 'url' => $post['url'], + 'sort' => $post['sort'], + 'is_show' => $post['is_show'], + 'create_time' => time(), + ]; + + return Db::name('menu_tools')->where(['id'=>$post['id']])->update($data); + } + + // 切换工具状态 + public static function swtichToolsStatus($post){ + return Db::name('menu_tools') + ->where(['id' => $post['id']]) + ->update(['is_show' => $post['is_show'], 'update_time' => time()]); + } + + public static function delTools($id) + { + return Db::name('menu_tools') + ->where(['id' => $id,'del' => 0]) + ->update(['update_time' =>time() ,'del' => 1]); + } } diff --git a/app/admin/view/decoration/menu_decorate/add_tools.html b/app/admin/view/decoration/menu_decorate/add_tools.html new file mode 100644 index 00000000..edc2d988 --- /dev/null +++ b/app/admin/view/decoration/menu_decorate/add_tools.html @@ -0,0 +1,76 @@ +{layout name="layout2" /} + +