SpecialController.class.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <?php
  2. /**
  3. * 小梦科技资源nanodreamtech.com
  4. *
  5. * ==========================================================================
  6. * @link https://www.nanodreamtech.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license https://www.nanodreamtech.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Seller\Controller;
  15. use Admin\Model\SpecialModel;
  16. class SpecialController extends CommonController{
  17. protected function _initialize(){
  18. parent::_initialize();
  19. $this->breadcrumb1='营销活动';
  20. $this->breadcrumb2='专题管理';
  21. }
  22. public function index(){
  23. $model=new SpecialModel();
  24. $data=$model->show_special_page();
  25. $this->assign('empty',$data['empty']);// 赋值数据集
  26. $this->assign('list',$data['list']);// 赋值数据集
  27. $this->assign('page',$data['page']);// 赋值分页输出
  28. $this->display();
  29. }
  30. /**
  31. * 专题项目添加
  32. */
  33. public function special_item_add() {
  34. $model_mb_special = new SpecialModel();
  35. $param = array();
  36. $param['special_id'] = $_POST['special_id'];
  37. $param['item_type'] = $_POST['item_type'];
  38. //广告只能添加一个
  39. if($param['item_type'] == 'adv_list') {
  40. $result = $model_mb_special->isMbSpecialItemExist($param);
  41. if($result) {
  42. echo json_encode(array('error' => '广告条板块只能添加一个'));die;
  43. }
  44. }
  45. $item_info = $model_mb_special->addMbSpecialItem($param);
  46. if($item_info) {
  47. echo json_encode($item_info);die;
  48. } else {
  49. echo json_encode(array('error' => '添加失败'));die;
  50. }
  51. }
  52. public function special_item_edit() {
  53. $model_mb_special = new SpecialModel();
  54. $item_info = $model_mb_special->getMbSpecialItemInfoByID($_GET['item_id']);
  55. $this->item_info = $item_info;
  56. $this->display('mb_special_item_edit');
  57. }
  58. /**
  59. * 专题项目保存
  60. */
  61. public function special_item_save() {
  62. $model_mb_special = new SpecialModel();
  63. $result = $model_mb_special->editMbSpecialItemByID(array('item_data' => $_POST['item_data']), $_POST['item_id'], $_POST['special_id']);
  64. $return = array(
  65. 'status'=>'success',
  66. 'message'=>'修改成功',
  67. 'jump'=>U('Special/addGoods',array('special_id' => $_POST['special_id']))
  68. );
  69. $this->osc_alert($return);
  70. }
  71. /**
  72. * 更新项目排序
  73. */
  74. public function update_item_sort() {
  75. $item_id_string = $_POST['item_id_string'];
  76. $special_id = $_POST['special_id'];
  77. if(!empty($item_id_string)) {
  78. $model_mb_special = new SpecialModel();
  79. $item_id_array = explode(',', $item_id_string);
  80. $index = 0;
  81. foreach ($item_id_array as $item_id) {
  82. $result = $model_mb_special->editMbSpecialItemByID(array('item_sort' => $index), $item_id, $special_id);
  83. $index++;
  84. }
  85. }
  86. $data = array();
  87. $data['message'] = '操作成功';
  88. echo json_encode($data);
  89. die();
  90. }
  91. /**
  92. * 更新项目启用状态
  93. */
  94. public function update_item_usable() {
  95. $model_mb_special = new SpecialModel();
  96. $result = $model_mb_special->editMbSpecialItemUsableByID($_POST['usable'], $_POST['item_id'], $_POST['special_id']);
  97. $data = array();
  98. if($result) {
  99. $data['message'] = '操作成功';
  100. } else {
  101. $data['error'] = '操作失败';
  102. }
  103. echo json_encode($data);
  104. }
  105. /**
  106. * 专题项目删除
  107. */
  108. public function special_item_del() {
  109. $model_mb_special = new SpecialModel();
  110. $condition = array();
  111. $condition['item_id'] = $_POST['item_id'];
  112. $result = $model_mb_special->delMbSpecialItem($condition, $_POST['special_id']);
  113. if($result) {
  114. echo json_encode(array('message' => '删除成功'));die;
  115. } else {
  116. echo json_encode(array('error' => '删除失败'));die;
  117. }
  118. }
  119. public function addGoods()
  120. {
  121. $special_id = I('get.special_id');
  122. $model_mb_special = new SpecialModel();
  123. $this->crumbs='制作专题';
  124. $this->special=M('mb_special')->where(array('special_id'=>$special_id ))->find();
  125. $special_item_list = $model_mb_special->getMbSpecialItemListByID($_GET['special_id']);
  126. $this->list = $special_item_list;
  127. $this->special_id = $special_id;
  128. $module_list = $model_mb_special->getMbSpecialModuleList();
  129. $this->module_list = $module_list;
  130. $this->display('modifyspecial');
  131. }
  132. function add(){
  133. if(IS_POST){
  134. $model=new SpecialModel();
  135. $data=I('post.');
  136. $return=$model->add_special($data);
  137. $this->osc_alert($return);
  138. }
  139. $this->action=U('Special/add');
  140. $this->crumbs='新增';
  141. $this->display('edit');
  142. }
  143. function edit(){
  144. $model=new SpecialModel();
  145. if(IS_POST){
  146. $data=I('post.');
  147. $return=$model->edit_special($data);
  148. $this->osc_alert($return);
  149. }
  150. $this->crumbs='编辑';
  151. $this->action=U('Special/edit');
  152. $this->special=M('mb_special')->where(array('special_id'=>I('special_id')))->find();
  153. $this->display('edit');
  154. }
  155. function del(){
  156. $model=new SpecialModel();
  157. M('mb_special')->where(array('special_id'=>I('get.special_id')))->delete();
  158. $return = array(
  159. 'status'=>'success',
  160. 'message'=>'删除成功',
  161. 'jump'=>U('Special/index')
  162. );
  163. $this->osc_alert($return);
  164. }
  165. }
  166. ?>