Consult.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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\users;
  10. use app\admin\controller\Auth;
  11. use mall\response\Response;
  12. use think\facade\Request;
  13. use think\facade\View;
  14. use app\admin\service\users\Consult as ConsultService;
  15. class Consult extends Auth {
  16. /**
  17. * 列表
  18. * @return string|\think\response\Json
  19. */
  20. public function index(){
  21. if(Request::isAjax()){
  22. $list = ConsultService::getList(Request::param());
  23. return Response::returnArray("ok",0,$list['data'],$list['count']);
  24. }
  25. return View::fetch();
  26. }
  27. /**
  28. * 详情
  29. * @return string|\think\response\Json
  30. */
  31. public function detail(){
  32. try{
  33. if(Request::isAjax()){
  34. ConsultService::save(Request::param());
  35. return Response::returnArray("操作成功");
  36. }
  37. return View::fetch("",ConsultService::delete(Request::param("id",0,"intval")));
  38. }catch (\Exception $ex){
  39. if(Request::isAjax()){
  40. return Response::returnArray($ex->getMessage(),0);
  41. }
  42. $this->error($ex->getMessage());
  43. }
  44. }
  45. /**
  46. * 删除
  47. * @return \think\response\Json
  48. */
  49. public function delete(){
  50. try {
  51. ConsultService::delete(Request::param("id",0,"intval"));
  52. return Response::returnArray("删除成功");
  53. } catch (\Exception $ex) {
  54. return Response::returnArray("操作失败,请稍候在试。",0);
  55. }
  56. }
  57. }