shop_id; class Closure extends ShopBase { public function lists() { if ($this->request->isAjax()) { $get = $this->request->get(); $lists = ClosureLogic::lists($get,$this->shop_id); return JsonServer::success("获取成功", $lists); } return view('', [ 'category' => ClosureCategoryLogic::getCategory($this->shop_id), 'category2' => ClosureCategoryLogic::getCategory2($this->shop_id) ]); } public function add() { if ($this->request->isAjax()) { $post = $this->request->post(); $post['shop_id'] = $this->shop_id; (new ClosureValidate())->goCheck('add',$post); $res = ClosureLogic::add($post); if ($res === false) { $error = ClosureLogic::getError() ?: '新增失败'; return JsonServer::error($error); } return JsonServer::success('新增成功'); } $title_no = date('YmdHis') . mt_rand(1000, 9999); $a = ClosureCategoryLogic::getCategory($this->shop_id); $b = ClosureCategoryLogic::getCategory2($this->shop_id); //是否已配置分类 $is_true = false; foreach ($a as $k => $v) { if($v['name'] == '默认'){ $is_true = true; } } if($is_true === false){ foreach ($b as $k => $v) { if($v['name'] == '默认'){ $is_true = true; } } } //不管当前是什么类型的app设置 $search_list = [ 'xhs' => [ "a" => ["综合",'最新','最多点赞','最多评论'], //排序依据 "b" => ["不限",'视频','图文','直播'], //笔记类型 "c" => ["不限",'一天内','一周内','半年内'], //发布时间 "d" => ["不限",'已看过','未看过','已关注'], //搜索范围 ] ]; return view('', [ 'category' => $a, 'category2' => $b, 'title_no' => $title_no, 'is_true' => $is_true, 'search_list' => $search_list ]); } /*** * @Notes: 编辑文章 * @Author: 张无忌 */ public function edit() { if ($this->request->isAjax()) { $post = $this->request->post(); $post['shop_id'] = $this->shop_id; (new ClosureValidate())->goCheck('edit',$post); $res = ClosureLogic::edit($post); if ($res === false) { $error = ClosureLogic::getError() ?: '编辑失败'; return JsonServer::error($error); } return JsonServer::success('编辑成功'); } $id = $this->request->get('id'); $data = ClosureLogic::detail($id); //不管当前是什么类型的app设置 $search_list = [ 'xhs' => [ "a" => ["综合",'最新','最多点赞','最多评论'], //排序依据 "b" => ["不限",'视频','图文','直播'], //笔记类型 "c" => ["不限",'一天内','一周内','半年内'], //发布时间 "d" => ["不限",'已看过','未看过','已关注'], //搜索范围 ] ]; return view('', [ 'detail' => $data, 'extend' => $data['form_data'], 'category' => ClosureCategoryLogic::getCategory($this->shop_id), 'category2' => ClosureCategoryLogic::getCategory2($this->shop_id), 'search_list' => $search_list ]); } /** * @Notes: 删除文章 * @Author: 张无忌 */ public function del() { if ($this->request->isAjax()) { (new ClosureValidate())->goCheck('id'); $id = $this->request->post('id'); $res = ClosureLogic::del($id); if ($res === false) { $error = ClosureLogic::getError() ?: '删除失败'; return JsonServer::error($error); } return JsonServer::success('删除成功'); } return JsonServer::success('异常'); } /** * @Notes: 隐藏文章 * @Author: 张无忌 */ public function hide() { if ($this->request->isAjax()) { (new ClosureValidate())->goCheck('id'); $id = $this->request->post('id'); $res = ClosureLogic::hide($id); if ($res === false) { $error = ClosureLogic::getError() ?: '操作失败'; return JsonServer::error($error); } return JsonServer::success('操作成功'); } return JsonServer::success('异常'); } }