request->isAjax()){ $get = $this->request->get(); $list = GroupbuyLogic::goodsList($get); return JsonServer::success('获取成功', $list); } return View('', [ 'config' => GroupbuyLogic::getConfig() ]); } public function add(){ if($this->request->isAjax()){ $post = $this->request->post(); $post['item'] = form_to_linear($post); try{ validate(GroupbuyValidate::class)->scene('add')->check($post); }catch(ValidateException $e) { return JsonServer::error($e->getError()); } $result = GroupbuyLogic::add($post); if($result === true) { return JsonServer::success('新增成功'); } return JsonServer::error(GroupbuyLogic::getError()); } return view(''); } public function edit(){ if($this->request->isAjax()){ $post = $this->request->post(); $post['item'] = form_to_linear($post); try{ validate(GroupbuyValidate::class)->scene('edit')->check($post); }catch(ValidateException $e) { return JsonServer::error($e->getError()); } $result = GroupbuyLogic::edit($post); if($result === true) { return JsonServer::success('编辑成功'); } return JsonServer::error(GroupbuyLogic::getError()); } $id = $this->request->get('id'); $detail = GroupbuyLogic::getEditGoods($id); return view('', [ 'detail' => $detail ]); } public function del(){ if($this->request->isAjax()){ $id = $this->request->post('id'); $result = GroupbuyLogic::del($id); if($result === true) { return JsonServer::success('删除成功'); } return JsonServer::error(GroupbuyLogic::getError()); } } public function switchStatus(){ if($this->request->isAjax()){ $post = $this->request->post(); $result = GroupbuyLogic::switchStatus($post); if($result === true) { return JsonServer::success('操作成功'); } return JsonServer::error(GroupbuyLogic::getError()); } } public function goodsLists(){ if ($this->request->isAjax()){ $get = $this->request->get(); $goods_list = GroupbuyLogic::getGoodsList($get,true); return JsonServer::success('', $goods_list); } $category_list = GroupbuyLogic::listAll(); return view('', [ 'category_list' => $category_list ]); } public function setConfig() { if ($this->request->isAjax()){ $post = $this->request->post(); GroupbuyLogic::setConfig($post); return JsonServer::success('操作成功'); } } }