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.
308 lines
13 KiB
308 lines
13 KiB
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: Administrator
|
|
* Date: 2018/4/2
|
|
* Time: 9:56
|
|
*/
|
|
|
|
namespace app\admin\controller;
|
|
|
|
use think\Db;
|
|
class Roadshow extends Base
|
|
{
|
|
/**
|
|
* 固态栏目路演列表
|
|
*/
|
|
public function roadshow_list()
|
|
{
|
|
$roadshow_list=Db::name('lypt')->order('sort,create_time desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
|
|
$show = $roadshow_list->render();
|
|
$show=preg_replace("(<a[^>]*page[=|/](\d+).+?>(.+?)<\/a>)","<a href='javascript:ajax_page($1);'>$2</a>",$show);
|
|
$this->assign('page',$show);
|
|
$this->assign('roadshow_list',$roadshow_list);
|
|
if(request()->isAjax()){
|
|
return $this->fetch('ajax_roadshow_list');
|
|
}else{
|
|
return $this->fetch('roadshow_list');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 添加显示
|
|
*/
|
|
public function roadshow_add()
|
|
{
|
|
if (!request()->isAjax()){
|
|
return $this->fetch('roadshow_add');
|
|
}else{
|
|
$count=Db::name('lypt')-> count();
|
|
if($count>=24){
|
|
$this->error('最多上传24个视频文件!',url('admin/Roadshow/roadshow_list'));
|
|
}else{
|
|
$img_one='';
|
|
$file = request()->file('pic_one');
|
|
$validate = config('upload_validate');
|
|
//单图
|
|
if ($file) {
|
|
$info = $file[0]->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
|
|
if ($info) {
|
|
$img_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
|
|
//写入数据库
|
|
$data['uptime'] = time();
|
|
$data['filesize'] = $info->getSize();
|
|
$data['path'] = $img_url;
|
|
Db::name('plug_files')->insert($data);
|
|
$img_one = $img_url;
|
|
} else {
|
|
$this->error($file->getError(), url('admin/Lcwhcyb/whcybly_list',['whcyb_type'=>$type]));
|
|
}
|
|
}
|
|
//视频(使用oss)
|
|
$files = request()->file('file_all');
|
|
$fileall_url='';
|
|
if($files){
|
|
if(config('aliyun_oss.oss_open')){
|
|
$config=config('aliyun_oss');
|
|
$oss=new \OSS\OssClient($config['accesskey'],$config['secretkey'],$config['endpoint'],true);
|
|
foreach ($files as $file) {
|
|
$fileinfo=$file->getInfo();
|
|
$size_list= $fileinfo['size'];
|
|
if($size_list>209715200){
|
|
$this->error('不能上传超过200M的视频文件!', url('admin/Roadshow/roadshow_list'));//限制上传大小
|
|
}
|
|
$filename=$fileinfo['name'];
|
|
$path=$fileinfo['tmp_name'];
|
|
try{
|
|
$oss->uploadFile($config['bucket'],$filename,$path);
|
|
} catch(OssException $e) {
|
|
$this->error($e->getMessage(), url('admin/Roadshow/roadshow_list'));//否则就是上传错误,显示错误原因
|
|
}
|
|
$file_url = $config['endpoint'].'/'.$filename;
|
|
//写入数据库
|
|
$data['uptime'] = time();
|
|
$data['filesize'] = $fileinfo['size'];
|
|
$data['path'] = $file_url;
|
|
Db::name('plug_files')->insert($data);
|
|
$fileall_url = $file_url;
|
|
}
|
|
}else{
|
|
foreach ($files as $file) {
|
|
$info = $file->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
|
|
if ($info) {
|
|
$file_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
|
|
//写入数据库
|
|
$data['uptime'] = time();
|
|
$data['filesize'] = $info->getSize();
|
|
$data['path'] = $file_url;
|
|
Db::name('plug_files')->insert($data);
|
|
$fileall_url = $file_url;
|
|
} else {
|
|
$this->error($file->getError(), url('admin/Roadshow/roadshow_list'));//否则就是上传错误,显示错误原因
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$sl_data=array(
|
|
'name'=>input('name'),
|
|
'activity_introduce'=>input('activity_introduce'),
|
|
'start_time'=>input('start_time','')?strtotime(input('start_time','')):time(),
|
|
'host_unit'=>input('host_unit'),
|
|
'status'=>input('status',0),
|
|
'create_uid'=>session('admin_auth.aid'),
|
|
'create_time'=>time(),
|
|
'sort'=>input('sort',20,'intval'),
|
|
'video'=>$fileall_url,
|
|
'pic'=>$img_one,
|
|
);
|
|
$rst=Db::name('lypt')->insert($sl_data);
|
|
if($rst){
|
|
$this->success('添加成功',url('admin/Roadshow/roadshow_list'));
|
|
}else{
|
|
$this->error('添加失败',url('admin/Roadshow/roadshow_list'));
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 编辑显示
|
|
*/
|
|
public function roadshow_edit()
|
|
{
|
|
if (!request()->isAjax()) {
|
|
$id = input('id');
|
|
if (empty($id)) {
|
|
if($id){
|
|
$this->error('参数错误', url('admin/Roadshow/roadshow_list'));
|
|
}else{
|
|
$this->error('参数错误', url('admin/Roadshow/roadshow_list'));
|
|
}
|
|
}
|
|
$roadshow_list = Db::name('lypt')->find($id);
|
|
$this->assign('roadshow_list', $roadshow_list);
|
|
return $this->fetch('roadshow_edit');
|
|
}else{
|
|
$img_one='';
|
|
$file = request()->file('pic_one');
|
|
$validate = config('upload_validate');
|
|
//单图
|
|
if ($file) {
|
|
$info = $file[0]->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
|
|
if ($info) {
|
|
$img_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
|
|
//写入数据库
|
|
$data['uptime'] = time();
|
|
$data['filesize'] = $info->getSize();
|
|
$data['path'] = $img_url;
|
|
Db::name('plug_files')->insert($data);
|
|
$img_one = $img_url;
|
|
} else {
|
|
$this->error($file->getError(), url('admin/Lcwhcyb/whcybly_list',['whcyb_type'=>$type]));
|
|
}
|
|
}
|
|
//视频
|
|
$files = request()->file('file_all');
|
|
$fileall_url='';
|
|
if($files){
|
|
if(config('aliyun_oss.oss_open')){
|
|
$config=config('aliyun_oss');
|
|
$oss=new \OSS\OssClient($config['accesskey'],$config['secretkey'],$config['endpoint'],true);
|
|
foreach ($files as $file) {
|
|
$fileinfo=$file->getInfo();
|
|
$size_list= $fileinfo['size'];
|
|
if($size_list>209715200){
|
|
$this->error('不能上传超过200M的视频文件!', url('admin/Roadshow/roadshow_list'));//限制上传大小
|
|
}
|
|
$filename=$fileinfo['name'];
|
|
$path=$fileinfo['tmp_name'];
|
|
try{
|
|
$oss->uploadFile($config['bucket'],$filename,$path);
|
|
} catch(OssException $e) {
|
|
$this->error($e->getMessage(), url('admin/Roadshow/roadshow_list'));//否则就是上传错误,显示错误原因
|
|
}
|
|
$file_url = $config['endpoint'].'/'.$filename;
|
|
//写入数据库
|
|
$data['uptime'] = time();
|
|
$data['filesize'] = $fileinfo['size'];
|
|
$data['path'] = $file_url;
|
|
Db::name('plug_files')->insert($data);
|
|
$fileall_url = $file_url;
|
|
}
|
|
}else{
|
|
foreach ($files as $file) {
|
|
$info = $file->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
|
|
if ($info) {
|
|
$file_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
|
|
//写入数据库
|
|
$data['uptime'] = time();
|
|
$data['filesize'] = $info->getSize();
|
|
$data['path'] = $file_url;
|
|
Db::name('plug_files')->insert($data);
|
|
$fileall_url = $file_url;
|
|
} else {
|
|
$this->error($file->getError(), url('admin/Roadshow/roadshow_list'));//否则就是上传错误,显示错误原因
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$sl_data=array(
|
|
'id'=>input('id'),
|
|
'name'=>input('name'),
|
|
'activity_introduce'=>input('activity_introduce'),
|
|
'start_time'=>input('start_time','')?strtotime(input('start_time','')):time(),
|
|
'host_unit'=>input('host_unit'),
|
|
'status'=>input('status',0),
|
|
'create_uid'=>session('admin_auth.aid'),
|
|
'create_time'=>time(),
|
|
'sort'=>input('sort',20,'intval'),
|
|
);
|
|
//图片字段处理
|
|
if(!empty($img_one)){
|
|
$sl_data['pic']=$img_one;
|
|
}
|
|
|
|
if(!empty($fileall_url)){
|
|
$sl_data['video']=$fileall_url;
|
|
}
|
|
$rst=Db::name('lypt')->update($sl_data);
|
|
if($rst!==false){
|
|
$this->success('修改成功',url('admin/Roadshow/roadshow_list'));
|
|
}else{
|
|
$this->error('修改失败',url('admin/Roadshow/roadshow_list'));
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 排序
|
|
*/
|
|
public function roadshow_order()
|
|
{
|
|
if (!request()->isAjax()){
|
|
$this->error('提交方式不正确', url('admin/Roadshow/roadshow_list'));
|
|
}else{
|
|
foreach (input('post.') as $vd_id => $vd_order){
|
|
Db::name('lypt')->update(['id'=>$vd_id,'sort'=>$vd_order]);
|
|
}
|
|
$this->success('排序更新成功',url('admin/Roadshow/roadshow_list'));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 删除(单个)
|
|
*/
|
|
public function roadshow_del()
|
|
{
|
|
$p=input('p');
|
|
$rst=Db::name('lypt')->delete(input('id'));
|
|
if($rst!==false){
|
|
$this->success('删除成功',url('admin/Roadshow/roadshow_list',array('p'=>$p)));
|
|
}else{
|
|
$this -> error("删除失败!",url('admin/Roadshow/roadshow_list',array('p'=>$p)));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 删除(全选)
|
|
*/
|
|
public function roadshow_alldel()
|
|
{
|
|
$p = input('p');
|
|
$ids = input('id/a');
|
|
if(empty($ids)){
|
|
$this -> error("请选择待删除数据",url('admin/Roadshow/roadshow_list',array('p'=>$p)));
|
|
}
|
|
if(is_array($ids)){
|
|
$where = 'id in('.implode(',',$ids).')';
|
|
}else{
|
|
$where = 'id='.$ids;
|
|
}
|
|
$rst=Db::name('lypt')->where($where)->delete();
|
|
if($rst!==false){
|
|
$this->success("删除成功",url('admin/Roadshow/roadshow_list',array('p'=>$p)));
|
|
}else{
|
|
$this -> error("删除失败!",url('admin/Roadshow/roadshow_list',array('p'=>$p)));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 审核/取消审核
|
|
*/
|
|
public function roadshow_state()
|
|
{
|
|
$id=input('x');
|
|
$status=Db::name('lypt')->where(array('id'=>$id))->value('status');
|
|
if($status==1){
|
|
$statedata = array('status'=>0);
|
|
Db::name('lypt')->where(array('id'=>$id))->setField($statedata);
|
|
$this->success('未审');
|
|
}else{
|
|
$statedata = array('status'=>1);
|
|
Db::name('lypt')->where(array('id'=>$id))->setField($statedata);
|
|
$this->success('已审');
|
|
}
|
|
}
|
|
|
|
}
|