Page.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | A3Mall
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2020 http://www.a3-mall.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: xzncit <158373108@qq.com>
  8. // +----------------------------------------------------------------------
  9. namespace app\admin\controller\platform;
  10. use app\admin\controller\Auth;
  11. use app\admin\service\platform\Category as CategoryService;
  12. use mall\utils\Tool;
  13. use mall\response\Response;
  14. use think\facade\Request;
  15. use think\facade\View;
  16. class Page extends Auth {
  17. /**
  18. * 列表
  19. * @return string|\think\response\Json
  20. * @throws \think\db\exception\DataNotFoundException
  21. * @throws \think\db\exception\DbException
  22. * @throws \think\db\exception\ModelNotFoundException
  23. */
  24. public function index(){
  25. if(Request::isAjax()) {
  26. $list = CategoryService::getList(Request::param(),["pid"=>0,"module"=>"page"]);
  27. return Response::returnArray("ok",0,$list['data'],$list['count']);
  28. }
  29. return View::fetch();
  30. }
  31. /**
  32. * 编辑
  33. * @return string|\think\response\Json
  34. */
  35. public function editor(){
  36. try {
  37. if(Request::isAjax()){
  38. $data = Request::post();
  39. $data["module"] = "page";
  40. $data["content"] = Tool::editor($data["content"]);
  41. CategoryService::save($data);
  42. return Response::returnArray("操作成功!");
  43. }
  44. return View::fetch("",CategoryService::detail(Request::param("id","0","intval"),["status"=>0,"module"=>"page"]));
  45. }catch (\Exception $ex){
  46. return Response::returnArray($ex->getMessage(),0);
  47. }
  48. }
  49. /**
  50. * 删除
  51. * @return \think\response\Json
  52. */
  53. public function delete(){
  54. try{
  55. CategoryService::save(Request::param("id"));
  56. return Response::returnArray("删除成功");
  57. }catch (\Exception $ex){
  58. return Response::returnArray("操作失败,请稍候在试。",0);
  59. }
  60. }
  61. /**
  62. * 编辑字段
  63. * @return \think\response\Json
  64. */
  65. public function field(){
  66. try {
  67. CategoryService::setFields();
  68. return Response::returnArray("操作成功");
  69. } catch (\Exception $ex) {
  70. return Response::returnArray($ex->getMessage(),0);
  71. }
  72. }
  73. }