Banner.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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\Banner as AdvModel;
  14. /**
  15. * 广告管理
  16. */
  17. class Banner extends BaseAdmin
  18. {
  19. /**
  20. * 广告位管理
  21. * @return mixed
  22. */
  23. public function index()
  24. {
  25. $adv_position = new AdvModel();
  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. $type = input('type', '');//位置类型 1 pc端 2 手机端
  31. $condition = [];
  32. if (!empty($search_text)) {
  33. $condition[] = [ 'ap_name', 'like', '%' . $search_text . '%' ];
  34. }
  35. if ($type !== '') {
  36. $condition[] = [ 'type', '=', $type ];
  37. }
  38. return json_encode([
  39. 'code' => 0,
  40. 'data' => [
  41. 'count' => 1,
  42. 'list' => [],
  43. ],
  44. 'message' => 'cc'
  45. ]);
  46. return $adv_position->getbannerList($condition);
  47. } else {
  48. $this->forthMenu();
  49. return $this->fetch("banner/index");
  50. }
  51. }
  52. /**
  53. * 添加广告位
  54. */
  55. public function addPosition()
  56. {
  57. $adv_position = new AdvModel();
  58. if (request()->isAjax()) {
  59. $data = [
  60. 'show_image' => input('show_image', ''),
  61. 'link' => input('link', ''),
  62. 'create_time' => input('create_time', ''),
  63. ];
  64. return $adv_position->addbanner($data);
  65. } else {
  66. return $this->fetch("banner/add_adv");
  67. }
  68. }
  69. /**
  70. * 编辑广告位
  71. */
  72. public function editPosition()
  73. {
  74. $adv_position = new AdvPosition();
  75. $ap_id = input('ap_id', 0);
  76. if (request()->isAjax()) {
  77. $data = [
  78. 'ap_name' => input('ap_name', ''),
  79. 'keyword' => input('keyword', ''),
  80. 'ap_intro' => input('ap_intro', ''),
  81. 'ap_height' => input('ap_height', 0),
  82. 'ap_width' => input('ap_width', 0),
  83. 'default_content' => input('default_content', ''),
  84. 'ap_background_color' => input('ap_background_color', ''),
  85. 'type' => input('type', ''),
  86. ];
  87. return $adv_position->editAdvPosition($data, [ [ 'ap_id', '=', $ap_id ] ]);
  88. } else {
  89. $ap_info = $adv_position->getAdvPositionInfo([ [ 'ap_id', '=', $ap_id ] ]);
  90. $this->assign('info', $ap_info['data']);
  91. return $this->fetch("adv/edit_position");
  92. }
  93. }
  94. /**
  95. * 修改广告位字段
  96. */
  97. public function editPositionField()
  98. {
  99. if (request()->isAjax()) {
  100. $adv_position = new AdvPosition();
  101. $type = input('type', '');
  102. $value = input('value', 0);
  103. $ap_id = input('ap_id', 0);
  104. $data = [
  105. $type => $value
  106. ];
  107. return $adv_position->editAdvPosition($data, [ [ 'ap_id', '=', $ap_id ] ]);
  108. }
  109. }
  110. /**
  111. * 删除广告位
  112. */
  113. public function deletePosition()
  114. {
  115. if (request()->isAjax()) {
  116. $ap_ids = input('ap_ids', 0);
  117. $adv_position = new AdvPosition();
  118. return $adv_position->deleteAdvPosition([ [ 'ap_id', 'in', $ap_ids ] ]);
  119. }
  120. }
  121. /**
  122. * 广告列表
  123. */
  124. public function lists()
  125. {
  126. $adv = new AdvModel();
  127. $ap_id = input('ap_id', '');
  128. if (request()->isAjax()) {
  129. $page = input('page', 1);
  130. $page_size = input('page_size', PAGE_LIST_ROWS);
  131. $search_text = input('search_text', '');
  132. $ap_id = input('ap_id', '');
  133. $condition = [];
  134. if (!empty($search_text)) {
  135. $condition[] = [ 'a.adv_title', 'like', '%' . $search_text . '%' ];
  136. }
  137. if ($ap_id !== '') {
  138. $condition[] = [ 'a.ap_id', '=', $ap_id ];
  139. }
  140. return $adv->getbannerList($condition);
  141. } else {
  142. $this->assign('ap_id', $ap_id);
  143. $this->forthMenu();
  144. return $this->fetch("banner/lists");
  145. }
  146. }
  147. /**
  148. * 添加广告
  149. */
  150. public function addAdv()
  151. {
  152. $adv = new AdvModel();
  153. if (request()->isAjax()) {
  154. $data = [
  155. 'ap_id' => input('ap_id', 0),
  156. 'adv_title' => input('adv_title', ''),
  157. 'adv_url' => input('adv_url', ''),
  158. 'adv_image' => input('adv_image', ''),
  159. 'slide_sort' => input('slide_sort', 0),
  160. 'price' => input('price', 0),
  161. 'background' => input('background', ''),
  162. ];
  163. return $adv->addAdv($data);
  164. } else {
  165. return $this->fetch("adv/add_adv");
  166. }
  167. }
  168. /**
  169. * 编辑广告
  170. */
  171. public function editAdv()
  172. {
  173. $adv_id = input('adv_id', '');
  174. $adv = new AdvModel();
  175. if (request()->isAjax()) {
  176. $data = [
  177. 'ap_id' => input('ap_id', 0),
  178. 'adv_title' => input('adv_title', ''),
  179. 'adv_url' => input('adv_url', ''),
  180. 'adv_image' => input('adv_image', ''),
  181. 'slide_sort' => input('slide_sort', 0),
  182. 'price' => input('price', 0),
  183. 'background' => input('background', ''),
  184. ];
  185. return $adv->editAdv($data, [ [ 'adv_id', '=', $adv_id ] ]);
  186. } else {
  187. $adv_position = new AdvPosition();
  188. $adv_position_list = $adv_position->getAdvPositionList();
  189. $this->assign('adv_position_list', $adv_position_list['data']);
  190. $adv_info = $adv->getAdvInfo($adv_id);
  191. $this->assign('adv_info', $adv_info['data']);
  192. return $this->fetch("adv/edit_adv");
  193. }
  194. }
  195. /**
  196. * 修改广告字段
  197. */
  198. public function editAdvField()
  199. {
  200. if (request()->isAjax()) {
  201. $adv = new AdvModel();
  202. $type = input('type', '');
  203. $value = input('value', '');
  204. $adv_id = input('adv_id', '');
  205. $data = [
  206. $type => $value
  207. ];
  208. return $adv->editAdv($data, [ [ 'adv_id', '=', $adv_id ] ]);
  209. }
  210. }
  211. /**
  212. * 删除广告
  213. */
  214. public function deleteAdv()
  215. {
  216. if (request()->isAjax()) {
  217. $adv_ids = input('adv_ids', 0);
  218. $adv = new AdvModel();
  219. return $adv->deleteAdv([ [ 'adv_id', 'in', $adv_ids ] ]);
  220. }
  221. }
  222. }