12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace Admin\Controller;
- use Common\Controller\AdminController;
- class ActivityController extends AdminController {
- public function __construct(){
- parent::__construct();
- }
-
- public function index(){
- $count = M('Activity')->count();
- //分页
- $Page = new \Think\Page($count);
- $show = $Page->show();
- $list = M('Activity')->order('act_id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
- $this->assign('page',$show);
- $this->assign('list',$list);
- $this->display();
- }
-
- public function edit(){
- $step = I('step','');
- $actId = I('act_id','');
- if (empty($step)){
- $info = array();
- if (!empty($actId)){
- $info = M('Activity')->where(array('act_id'=>$actId))->find();
- }
- $this->assign('info',$info);
- $this->display();
- }else if($step==2){
- $saveData =[
- 'act_title'=>I('act_title',''),
- 'act_sort'=>I('act_sort','0'),
- 'act_pic'=>I('act_pic',''),
- 'act_name'=>I('act_name',''),
- 'act_content'=>I('act_content',''),
- ] ;
- if (empty($saveData['act_pic'])){
- $this->error('图片不能为空');
- }
- if (empty($saveData['act_title'])){
- $this->error('活动名称不能为空');
- }
- if (empty($saveData['act_name'])){
- $this->error('出品方不能为空');
- }
- if ($actId){
- M('Activity')->where(array('act_id'=>$actId))->save($saveData);
- }else{
- $saveData['operate_dt'] = time();
- M('Activity')->add($saveData);
- }
- $this->success('操作成功','/admin/activity/index');
- }
- }
-
- public function status(){
- $actId = I('act_id','');
- $actStatus = I('act_status','');
- M('Activity')->where(array('act_id'=>$actId))->save(['act_status'=>$actStatus]);
- $this->success('操作成功','/admin/activity/index');
- }
-
- //删除
- public function del(){
- $actId = I('act_id','');
- M('Activity')->where(array('act_id'=>$actId))->delete();
- $this->success('操作成功','/admin/activity/index');
- }
- }
|