Notice.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com.cn
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
  9. * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
  10. * =========================================================
  11. */
  12. namespace app\admin\controller;
  13. use app\model\web\NoticeClass;
  14. use app\model\web\NoticeClass as NoticeClassModel;
  15. use app\model\web\Notice as NoticeModel;
  16. /**
  17. * 商家帮助
  18. */
  19. class Notice extends BaseAdmin
  20. {
  21. /**
  22. * 分类列表
  23. */
  24. public function classList()
  25. {
  26. if (request()->isAjax()) {
  27. $page = input('page', 1);
  28. $page_size = input('page_size', PAGE_LIST_ROWS);
  29. $search_text = input('search_text', '');
  30. $condition[] = [ 'name', 'like', '%' . $search_text . '%' ];
  31. $order = 'create_time desc';
  32. $field = '*';
  33. $help_model = new NoticeClassModel();
  34. return $help_model->getNoticeClassPageList($condition, $page, $page_size, $order, $field);
  35. } else {
  36. $this->forthMenu();
  37. return $this->fetch('notice/class_list');
  38. }
  39. }
  40. /**
  41. * 分类添加
  42. */
  43. public function addClass()
  44. {
  45. if (request()->isAjax()) {
  46. $data = [
  47. 'name' => input('class_name', ''),
  48. 'create_time'=>time(),
  49. ];
  50. $help_model = new NoticeClassModel();
  51. return $help_model->addNoticeClass($data);
  52. } else {
  53. return $this->fetch('notice/add_class');
  54. }
  55. }
  56. /**
  57. * 分类编辑
  58. */
  59. public function editClass()
  60. {
  61. $help_model = new NoticeClassModel();
  62. if (request()->isAjax()) {
  63. $data = [
  64. 'class_name' => input('class_name', ''),
  65. 'create_time'=>time(),
  66. ];
  67. $class_id = input('class_id', 0);
  68. return $help_model->editnNoticeClass($data, $class_id);
  69. } else {
  70. $class_id = input('class_id', 0);
  71. $this->assign('class_id', $class_id);
  72. //帮助详情
  73. $class_info = $help_model->getNoticeClassInfo([ [ 'id', '=', $class_id ] ]);
  74. $this->assign('class_info', $class_info);
  75. return $this->fetch('notice/edit_class');
  76. }
  77. }
  78. /**
  79. * 分类删除
  80. */
  81. public function deleteClass()
  82. {
  83. if (request()->isAjax()) {
  84. $class_id = input('class_id', 0);
  85. $help_model = new NoticeClassModel();
  86. return $help_model->deleteNoticeClass([ [ 'id', '=', $class_id ] ]);
  87. }
  88. }
  89. /**
  90. * 帮助列表
  91. */
  92. public function helpList()
  93. {
  94. if (request()->isAjax()) {
  95. $page = input('page', 1);
  96. $page_size = input('page_size', PAGE_LIST_ROWS);
  97. $search_text = input('search_text', '');
  98. $condition[] = [ 'title', 'like', '%' . $search_text . '%' ];
  99. $order = 'create_time desc';
  100. $field = 'id,title,class_id,class_name,create_time';
  101. $help_model = new NoticeModel();
  102. return $help_model->getNoticePageList($condition, $page, $page_size, $order, $field);
  103. } else {
  104. $this->forthMenu();
  105. return $this->fetch('notice/help_list');
  106. }
  107. }
  108. /**
  109. * 帮助添加
  110. */
  111. public function addHelp()
  112. {
  113. $help_model = new NoticeModel();
  114. if (request()->isAjax()) {
  115. $data = [
  116. 'title' => input('title', ''),
  117. 'content' => input('content', ''),
  118. 'class_id' => input('class_id', ''),
  119. 'class_name' => input('class_name', ''),
  120. 'create_time' => time(),
  121. ];
  122. return $help_model->addNotice($data);
  123. } else {
  124. $help_class_model = new NoticeClassModel();
  125. //帮助分类
  126. $help_class_list = $help_class_model->getNoticeClassList([], 'id, name');
  127. $this->assign('help_class_list', $help_class_list['data']);
  128. return $this->fetch('notice/add_help');
  129. }
  130. }
  131. /**
  132. * 帮助编辑
  133. */
  134. public function editHelp()
  135. {
  136. $help_model = new NoticeModel();
  137. if (request()->isAjax()) {
  138. $data = [
  139. 'title' => input('title', ''),
  140. 'content' => input('content', ''),
  141. 'class_id' => input('class_id', ''),
  142. 'class_name' => input('class_name', ''),
  143. 'modify_time' => time(),
  144. ];
  145. $id = input('id', 0);
  146. return $help_model->editNotice($data, [ [ 'id', '=', $id ] ]);
  147. } else {
  148. $id = input('id', 0);
  149. $this->assign('id', $id);
  150. $help_info = $help_model->getNoticeInfo([['id','=',$id]]);
  151. $this->assign('help_info', $help_info['data']);
  152. //帮助分类
  153. $help_class_model = new NoticeClassModel();
  154. $help_class_list = $help_class_model->getNoticeClassList([ ], 'id, name');
  155. $this->assign('help_class_list', $help_class_list['data']);
  156. // print_r($help_info); print_r($help_class_list);die;
  157. return $this->fetch('notice/edit_help');
  158. }
  159. }
  160. /**
  161. * 帮助删除
  162. */
  163. public function deleteHelp()
  164. {
  165. if (request()->isAjax()) {
  166. $id = input('id', 0);
  167. $help_model = new NoticeModel();
  168. return $help_model->deleteNotice([ [ 'id', '=', $id ] ]);
  169. }
  170. }
  171. }