AdvimgController.class.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author J_da
  12. *
  13. */
  14. namespace Seller\Controller;
  15. class AdvimgController extends CommonController{
  16. protected function _initialize(){
  17. parent::_initialize();
  18. $this->breadcrumb1='广告图片';
  19. $this->breadcrumb2='广告列表';
  20. $this->sellerid = SELLERUID;
  21. }
  22. /**
  23. * 广告列表
  24. */
  25. public function index()
  26. {
  27. $_GPC = I('request.');
  28. $this->gpc = $_GPC;
  29. $condition = ' 1 ';
  30. $pindex = max(1, intval($_GPC['page']));
  31. $psize = 20;
  32. $time = $_GPC['time'];
  33. if (!empty($_GPC['keyword'])) {
  34. $_GPC['keyword'] = trim($_GPC['keyword']);
  35. $condition .= ' and adv_name like "%'.$_GPC['keyword'].'%" ';
  36. }
  37. if (isset($_GPC['enabled']) && trim($_GPC['enabled']) != '') {
  38. $_GPC['enabled'] = trim($_GPC['enabled']);
  39. $condition .= ' and enabled = ' . $_GPC['enabled'];
  40. }
  41. $label = M('lionfish_comshop_advimg')->where( $condition )->order(' displayorder desc ')->limit( (($pindex - 1) * $psize) . ',' . $psize )->select();
  42. $total = M('lionfish_comshop_advimg')->where( $condition )->count();
  43. $pager = pagination2($total, $pindex, $psize);
  44. $this->label = $label;
  45. $this->pager = $pager;
  46. $this->display();
  47. }
  48. /**
  49. * 添加广告
  50. */
  51. public function add(){
  52. $_GPC = I('request.');
  53. if (IS_POST) {
  54. $data = $_GPC['data'];
  55. if(empty($data['thumb'])){
  56. show_json(0, array('message' => '广告图片不能为空'));
  57. }
  58. if(empty($data['link']) && $data['linktype']<3){
  59. show_json(0, array('message' => '广告链接不能为空'));
  60. }
  61. D('Seller/Advimg')->update($_GPC);
  62. show_json(1, array('url' => U('advimg/add')));
  63. }
  64. // $id = intval($_GPC['id']);
  65. $id = M('lionfish_comshop_advimg')->field('id')->order('id desc')->find();
  66. $item = '';
  67. if (!empty($id)) {
  68. $item = M('lionfish_comshop_advimg')->where( $id )->find();
  69. $item['pos'] = explode(',', $item['pos']);
  70. }
  71. $category = D('Seller/GoodsCategory')->getFullCategory(false, true);
  72. $this->category = $category;
  73. $this->item = $item;
  74. $this->display();
  75. }
  76. /**
  77. * 更新弹窗广告状态
  78. */
  79. public function change_status(){
  80. $_GPC = I('request.');
  81. $id = intval($_GPC['id']);
  82. if (empty($id)) {
  83. $id = $_GPC['ids'];
  84. }
  85. if( is_array($id) )
  86. {
  87. M('lionfish_comshop_advimg')->where( array('id' => array('in', $id)) )->save( array('enabled' => intval($_GPC['enabled'])) );
  88. }else{
  89. M('lionfish_comshop_advimg')->where( array('id' =>$id ) )->save( array('enabled' => intval($_GPC['enabled'])) );
  90. }
  91. show_json(1, array('url' => U('advimg/index')));
  92. }
  93. /**
  94. * 删除弹窗广告
  95. */
  96. public function delete(){
  97. $_GPC = I('request.');
  98. $id = intval($_GPC['id']);
  99. if (empty($id)) {
  100. $id = $_GPC['ids'];
  101. }
  102. if( is_array($id) )
  103. {
  104. M('lionfish_comshop_advimg')->where( array('id' => array('in', $id)) )->delete();
  105. }else{
  106. M('lionfish_comshop_advimg')->where( array('id' =>$id ) )->delete();
  107. }
  108. show_json(1, array('url' => U('advimg/index')));
  109. }
  110. }
  111. ?>