Template.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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\wechat;
  10. use app\admin\controller\Auth;
  11. use app\admin\service\wechat\Subscribe as SubscribeService;
  12. use app\common\model\wechat\SubscribeMessage as SubscribeMessageModel;
  13. use mall\response\Response;
  14. use think\facade\Db;
  15. use think\facade\Request;
  16. use think\facade\View;
  17. class Template extends Auth {
  18. /**
  19. * 列表
  20. * @return string|\think\response\Json
  21. * @throws \think\db\exception\DataNotFoundException
  22. * @throws \think\db\exception\DbException
  23. * @throws \think\db\exception\ModelNotFoundException
  24. */
  25. public function index(){
  26. if(Request::isAjax()){
  27. $list = SubscribeService::getList(Request::param(),["type"=>1]);
  28. return Response::returnArray("ok",0,$list['data'],$list['count']);
  29. }
  30. return View::fetch();
  31. }
  32. /**
  33. * 列表
  34. * @return string|\think\response\Json
  35. */
  36. public function editor(){
  37. try{
  38. if(Request::isAjax()){
  39. $data = Request::param();
  40. $data["type"] = 1;
  41. SubscribeService::save($data);
  42. return Response::returnArray("操作成功!");
  43. }
  44. return View::fetch("",SubscribeService::detail(Request::param("id")));
  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. SubscribeService::delete(Request::get("id",0,"intval"));
  56. return Response::returnArray("删除成功");
  57. } catch (\Exception $ex) {
  58. return Response::returnArray("操作失败,请稍候在试。",0);
  59. }
  60. }
  61. }