Banner.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <?php
  2. namespace app\mall\controller;
  3. use app\common\service\UserSynth;
  4. use library\Controller;
  5. use think\Db;
  6. /**
  7. * 轮播图
  8. * Class Goods
  9. * @package app\mall\controller
  10. */
  11. class Banner extends Controller
  12. {
  13. /**
  14. * 绑定数据表
  15. * @var string
  16. */
  17. protected $table = 'StoreBanner';
  18. /**
  19. * 轮播图列表
  20. * @auth true
  21. * @menu true
  22. * @throws \think\Exception
  23. * @throws \think\db\exception\DataNotFoundException
  24. * @throws \think\db\exception\ModelNotFoundException
  25. * @throws \think\exception\DbException
  26. * @throws \think\exception\PDOException
  27. */
  28. public function index()
  29. {
  30. $this->title = '轮播图列表';
  31. $this->place_desc = [
  32. ''=>'--',
  33. 'service' => '客服',
  34. 'video'=>'视频',
  35. 'datum'=>'资料',
  36. 'article'=>'图文',
  37. 'supplier'=>'供应商商品',
  38. 'press'=>'新闻',
  39. 'demand'=>'需求',
  40. 'recruit'=>'招聘',
  41. 'activity'=>'活动',
  42. 'forum'=>'问题',
  43. ];
  44. $query = $this->_query($this->table)->where('is_deleted',0);
  45. $query->like('name');
  46. if(input('place')) $query->where('place',input('place'));
  47. $query->order(' sort desc , id asc')->page();
  48. }
  49. /**
  50. * 数据列表处理
  51. * @auth true
  52. * @menu true
  53. * @param array $data
  54. * @throws \think\db\exception\DataNotFoundException
  55. * @throws \think\db\exception\ModelNotFoundException
  56. * @throws \think\exception\DbException
  57. */
  58. protected function _index_page_filter(&$data)
  59. {
  60. }
  61. /**
  62. * 添加轮播图
  63. * @auth true
  64. * @menu true
  65. * @throws \think\Exception
  66. * @throws \think\db\exception\DataNotFoundException
  67. * @throws \think\db\exception\ModelNotFoundException
  68. * @throws \think\exception\DbException
  69. * @throws \think\exception\PDOException
  70. */
  71. public function add()
  72. {
  73. $this->title = '添加轮播图';
  74. $this->_form($this->table, 'form');
  75. }
  76. /**
  77. * 编辑轮播图
  78. * @auth true
  79. * @menu true
  80. * @throws \think\Exception
  81. * @throws \think\db\exception\DataNotFoundException
  82. * @throws \think\db\exception\ModelNotFoundException
  83. * @throws \think\exception\DbException
  84. * @throws \think\exception\PDOException
  85. */
  86. public function edit()
  87. {
  88. $this->title = '编辑轮播图';
  89. $this->_form($this->table, 'form');
  90. }
  91. /**
  92. * 启用
  93. * @auth true
  94. * @menu true
  95. * @throws \think\Exception
  96. * @throws \think\exception\PDOException
  97. */
  98. public function enable()
  99. {
  100. $this->_save($this->table, ['status' => 1]);
  101. }
  102. /**
  103. * 删除
  104. * @auth true
  105. * @menu true
  106. * @throws \think\Exception
  107. * @throws \think\exception\PDOException
  108. */
  109. public function del()
  110. {
  111. $this->_save($this->table, ['is_deleted' => 1]);
  112. }
  113. /**
  114. * 删除
  115. * @auth true
  116. * @menu true
  117. * @throws \think\Exception
  118. * @throws \think\exception\PDOException
  119. */
  120. public function remove()
  121. {
  122. $this->_save($this->table, ['is_deleted' => 1]);
  123. }
  124. /**
  125. * 表单数据处理
  126. * @auth true
  127. * @menu true
  128. * @param array $data
  129. */
  130. protected function _form_filter(&$data)
  131. {
  132. $data['create_at'] = date('Y-m-d H:i:s');
  133. $this->place_desc = [
  134. ''=>'全部',
  135. 'service' => '客服',
  136. 'video'=>'视频',
  137. 'datum'=>'资料',
  138. 'article'=>'图文',
  139. 'supplier'=>'供应商商品',
  140. 'press'=>'新闻',
  141. 'demand'=>'需求',
  142. 'recruit'=>'招聘',
  143. 'activity'=>'活动',
  144. 'forum'=>'问题',
  145. ];
  146. $this->module_list= UserSynth::getAllModuleTitle();
  147. }
  148. /**
  149. * 表单结果处理
  150. * @param boolean $result
  151. * @throws \think\db\exception\DataNotFoundException
  152. * @throws \think\db\exception\DbException
  153. * @throws \think\db\exception\ModelNotFoundException
  154. */
  155. protected function _form_result(bool $result)
  156. {
  157. if ($result && $this->request->isPost()) {
  158. // GoodsService::stock(input('code'));
  159. $this->success('操作成功!', 'javascript:history.back()');
  160. }
  161. }
  162. }