汪总电商平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

104 lines
4.0 KiB

<?php
namespace app\admin\controller\video;
use app\common\controller\Backend;
use app\common\model\Config as ConfigModel;
/**
* 公益课堂主管理
*
* @icon fa fa-circle-o
*/
class Main extends Backend
{
/**
* Main模型对象
* @var \app\admin\model\video\Main
*/
protected $model = null;
protected $classType = [
['value'=>'1','name'=>'语文'],
['value'=>'2','name'=>'数学'],
['value'=>'3','name'=>'地理'],
['value'=>'4','name'=>'英语'],
['value'=>'5','name'=>'物理'],
['value'=>'6','name'=>'语文'],
['value'=>'7','name'=>'其他']
];
protected $classPage = [
['value'=>'1','name'=>'第一章'],
['value'=>'2','name'=>'第二章'],
['value'=>'3','name'=>'第三章'],
['value'=>'4','name'=>'第四章'],
['value'=>'5','name'=>'第五章'],
['value'=>'6','name'=>'第六章'],
['value'=>'7','name'=>'第七章']
];
protected $classDetail = [
['value'=>'1','name'=>'第一课'],
['value'=>'2','name'=>'第二课'],
['value'=>'3','name'=>'第三课'],
['value'=>'4','name'=>'第四课'],
['value'=>'5','name'=>'第五课'],
['value'=>'6','name'=>'第六课'],
['value'=>'7','name'=>'第七课']
];
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\video\Main;
$this->view->assign("statusList", $this->model->getStatusList());
}
public function add(){
if($this->request->isAjax()){
$post = $this->request->post();
$data = $post['row'];
if(empty($data['video_url'])&&empty($data['video_url_input'])) $this->error("请上传视频或者填写视频地址");
if(empty($data['video_url'])) $data['video_url'] = $data['video_url_input'];
unset($data['video_url_input']);
$data['createtime'] = date("Y-m-d H:i:s",time());
if(!$this->model->insert($data)) $this->error("公益课堂发布失败");
$this->success("公益课堂发布成功");
}
$this->assign('classType',$this->classType);
$this->assign('classPage',$this->classPage);
$this->assign('classDetail',$this->classDetail);
return $this->view->fetch();
}
public function edit($ids = null){
$detail = $this->model->get($ids);
if($this->request->isAjax()){
$post = $this->request->post();
$data = $post['row'];
if(empty($data['video_url'])&&empty($data['video_url_input'])) $this->error("请上传视频或者填写视频地址");
if(empty($data['video_url'])) $data['video_url'] = $data['video_url_input'];
$detail->class_name = $data['class_name'];
$detail->class_type = $data['class_type'];
$detail->class_page = $data['class_page'];
$detail->class_detail = $data['class_detail'];
$detail->status = $data['status'];
$detail->video_name = $data['video_name'];
$detail->video_url = $data['video_url'];
if(!$detail->save()) $this->success("公益课堂修改成功");
$this->success("公益课堂修改成功");
}
$detail['video_url_input'] = "";
$this->assign('classType',$this->classType);
$this->assign('classPage',$this->classPage);
$this->assign('classDetail',$this->classDetail);
$this->assign('row',$detail);
return $this->view->fetch();
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
}