Response.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace app\admin\controller\wechat;
  3. use app\common\controller\Backend;
  4. use fast\service\Wechat;
  5. /**
  6. * 资源管理
  7. *
  8. * @icon fa fa-list-alt
  9. */
  10. class Response extends Backend
  11. {
  12. protected $model = null;
  13. public function _initialize()
  14. {
  15. parent::_initialize();
  16. $this->model = model('WechatResponse');
  17. }
  18. /**
  19. * 选择素材
  20. */
  21. public function select()
  22. {
  23. return $this->view->fetch();
  24. }
  25. /**
  26. * 添加
  27. */
  28. public function add()
  29. {
  30. if ($this->request->isPost())
  31. {
  32. $this->code = -1;
  33. $params = $this->request->post("row/a");
  34. $params['eventkey'] = $params['eventkey'] ? $params['eventkey'] : uniqid();
  35. $params['content'] = json_encode($params['content']);
  36. $params['createtime'] = time();
  37. if ($params)
  38. {
  39. $this->model->save($params);
  40. $this->code = 1;
  41. $this->content = $params;
  42. }
  43. return;
  44. }
  45. $appConfig = Wechat::appConfig();
  46. $this->view->applist = $appConfig;
  47. return $this->view->fetch();
  48. }
  49. /**
  50. * 编辑
  51. */
  52. public function edit($ids = NULL)
  53. {
  54. $row = $this->model->get($ids);
  55. if (!$row)
  56. $this->error(__('No Results were found'));
  57. if ($this->request->isPost())
  58. {
  59. $this->code = -1;
  60. $params = $this->request->post("row/a");
  61. $params['eventkey'] = $params['eventkey'] ? $params['eventkey'] : uniqid();
  62. $params['content'] = json_encode($params['content']);
  63. if ($params)
  64. {
  65. $row->save($params);
  66. $this->code = 1;
  67. }
  68. return;
  69. }
  70. $this->view->assign("row", $row);
  71. $appConfig = Wechat::appConfig();
  72. $this->view->applist = $appConfig;
  73. return $this->view->fetch();
  74. }
  75. }