123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- <?php
- /**
- * Niushop商城系统 - 团队十年电商经验汇集巨献!
- * =========================================================
- * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
- * ----------------------------------------------
- * 官方网址: https://www.niushop.com.cn
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
- * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
- * =========================================================
- */
- namespace app\admin\controller;
- use app\model\web\Banner as AdvModel;
- /**
- * 广告管理
- */
- class Banner extends BaseAdmin
- {
-
- /**
- * 广告位管理
- * @return mixed
- */
- public function index()
- {
- $adv_position = new AdvModel();
- if (request()->isAjax()) {
- $page = input('page', 1);
- $page_size = input('page_size', PAGE_LIST_ROWS);
- $search_text = input('search_text', '');
- $type = input('type', '');//位置类型 1 pc端 2 手机端
-
- $condition = [];
- if (!empty($search_text)) {
- $condition[] = [ 'ap_name', 'like', '%' . $search_text . '%' ];
- }
- if ($type !== '') {
- $condition[] = [ 'type', '=', $type ];
- }
- return json_encode([
- 'code' => 0,
- 'data' => [
- 'count' => 1,
- 'list' => [],
- ],
- 'message' => 'cc'
- ]);
- return $adv_position->getbannerList($condition);
- } else {
- $this->forthMenu();
- return $this->fetch("banner/index");
- }
- }
-
- /**
- * 添加广告位
- */
- public function addPosition()
- {
- $adv_position = new AdvModel();
- if (request()->isAjax()) {
- $data = [
- 'show_image' => input('show_image', ''),
- 'link' => input('link', ''),
- 'create_time' => input('create_time', ''),
- ];
- return $adv_position->addbanner($data);
- } else {
- return $this->fetch("banner/add_adv");
- }
- }
-
- /**
- * 编辑广告位
- */
- public function editPosition()
- {
- $adv_position = new AdvPosition();
- $ap_id = input('ap_id', 0);
- if (request()->isAjax()) {
- $data = [
- 'ap_name' => input('ap_name', ''),
- 'keyword' => input('keyword', ''),
- 'ap_intro' => input('ap_intro', ''),
- 'ap_height' => input('ap_height', 0),
- 'ap_width' => input('ap_width', 0),
- 'default_content' => input('default_content', ''),
- 'ap_background_color' => input('ap_background_color', ''),
- 'type' => input('type', ''),
- ];
- return $adv_position->editAdvPosition($data, [ [ 'ap_id', '=', $ap_id ] ]);
- } else {
- $ap_info = $adv_position->getAdvPositionInfo([ [ 'ap_id', '=', $ap_id ] ]);
- $this->assign('info', $ap_info['data']);
- return $this->fetch("adv/edit_position");
- }
- }
-
-
- /**
- * 修改广告位字段
- */
- public function editPositionField()
- {
- if (request()->isAjax()) {
- $adv_position = new AdvPosition();
- $type = input('type', '');
- $value = input('value', 0);
- $ap_id = input('ap_id', 0);
- $data = [
- $type => $value
- ];
- return $adv_position->editAdvPosition($data, [ [ 'ap_id', '=', $ap_id ] ]);
- }
- }
-
-
- /**
- * 删除广告位
- */
- public function deletePosition()
- {
- if (request()->isAjax()) {
- $ap_ids = input('ap_ids', 0);
- $adv_position = new AdvPosition();
- return $adv_position->deleteAdvPosition([ [ 'ap_id', 'in', $ap_ids ] ]);
- }
- }
-
- /**
- * 广告列表
- */
- public function lists()
- {
- $adv = new AdvModel();
- $ap_id = input('ap_id', '');
- if (request()->isAjax()) {
- $page = input('page', 1);
- $page_size = input('page_size', PAGE_LIST_ROWS);
- $search_text = input('search_text', '');
- $ap_id = input('ap_id', '');
-
- $condition = [];
- if (!empty($search_text)) {
- $condition[] = [ 'a.adv_title', 'like', '%' . $search_text . '%' ];
- }
- if ($ap_id !== '') {
- $condition[] = [ 'a.ap_id', '=', $ap_id ];
- }
- return $adv->getbannerList($condition);
- } else {
- $this->assign('ap_id', $ap_id);
- $this->forthMenu();
- return $this->fetch("banner/lists");
- }
- }
-
- /**
- * 添加广告
- */
- public function addAdv()
- {
- $adv = new AdvModel();
- if (request()->isAjax()) {
- $data = [
- 'ap_id' => input('ap_id', 0),
- 'adv_title' => input('adv_title', ''),
- 'adv_url' => input('adv_url', ''),
- 'adv_image' => input('adv_image', ''),
- 'slide_sort' => input('slide_sort', 0),
- 'price' => input('price', 0),
- 'background' => input('background', ''),
- ];
- return $adv->addAdv($data);
- } else {
- return $this->fetch("adv/add_adv");
- }
- }
-
- /**
- * 编辑广告
- */
- public function editAdv()
- {
- $adv_id = input('adv_id', '');
- $adv = new AdvModel();
- if (request()->isAjax()) {
- $data = [
- 'ap_id' => input('ap_id', 0),
- 'adv_title' => input('adv_title', ''),
- 'adv_url' => input('adv_url', ''),
- 'adv_image' => input('adv_image', ''),
- 'slide_sort' => input('slide_sort', 0),
- 'price' => input('price', 0),
- 'background' => input('background', ''),
- ];
- return $adv->editAdv($data, [ [ 'adv_id', '=', $adv_id ] ]);
- } else {
- $adv_position = new AdvPosition();
- $adv_position_list = $adv_position->getAdvPositionList();
- $this->assign('adv_position_list', $adv_position_list['data']);
- $adv_info = $adv->getAdvInfo($adv_id);
- $this->assign('adv_info', $adv_info['data']);
-
- return $this->fetch("adv/edit_adv");
- }
- }
-
- /**
- * 修改广告字段
- */
- public function editAdvField()
- {
- if (request()->isAjax()) {
- $adv = new AdvModel();
- $type = input('type', '');
- $value = input('value', '');
- $adv_id = input('adv_id', '');
- $data = [
- $type => $value
- ];
- return $adv->editAdv($data, [ [ 'adv_id', '=', $adv_id ] ]);
- }
- }
-
- /**
- * 删除广告
- */
- public function deleteAdv()
- {
- if (request()->isAjax()) {
- $adv_ids = input('adv_ids', 0);
- $adv = new AdvModel();
- return $adv->deleteAdv([ [ 'adv_id', 'in', $adv_ids ] ]);
- }
- }
-
- }
|