...
|
...
|
@@ -52,6 +52,40 @@ class ActivityController extends AdminBaseController |
|
|
$this->assign('keyword', isset($param['keyword']) ? $param['keyword'] : '');
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
public function news(){
|
|
|
$where=[];
|
|
|
$param = $this->request->param();
|
|
|
$startTime = empty($param['start_time']) ? 0 : strtotime($param['start_time']);
|
|
|
$endTime = empty($param['end_time']) ? 0 : strtotime($param['end_time']);
|
|
|
if (!empty($startTime) && !empty($endTime)) {
|
|
|
$where['create_time'] = [['>= time', $startTime], ['<= time', $endTime]];
|
|
|
} else {
|
|
|
if (!empty($startTime)) {
|
|
|
$where['create_time'] = ['>= time', $startTime];
|
|
|
}
|
|
|
if (!empty($endTime)) {
|
|
|
$where['create_time'] = ['<= time', $endTime];
|
|
|
}
|
|
|
}
|
|
|
$keyword = empty($param['keyword']) ? '' : $param['keyword'];
|
|
|
if (!empty($keyword)) {
|
|
|
$where['activity_name|abstract'] = ['like', "%$keyword%"];
|
|
|
}
|
|
|
$data=Db::name('activity_news')
|
|
|
->where('delete_time',0)
|
|
|
->where($where)
|
|
|
->order('create_time desc')
|
|
|
->paginate(10);
|
|
|
$data->appends($param);
|
|
|
$this->assign([
|
|
|
'data'=>$data,
|
|
|
'page'=>$data->render(),
|
|
|
]);
|
|
|
$this->assign('start_time', isset($param['start_time']) ? $param['start_time'] : '');
|
|
|
$this->assign('end_time', isset($param['end_time']) ? $param['end_time'] : '');
|
|
|
$this->assign('keyword', isset($param['keyword']) ? $param['keyword'] : '');
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
//编辑
|
|
|
public function edit(){
|
|
|
$id=$this->request->param('id', 0, 'intval');
|
...
|
...
|
@@ -107,6 +141,60 @@ class ActivityController extends AdminBaseController |
|
|
return $this->fetch();
|
|
|
}
|
|
|
}
|
|
|
public function editNews(){
|
|
|
$id=$this->request->param('id', 0, 'intval');
|
|
|
if($this->request->isPost()){
|
|
|
$param=$this->request->param();
|
|
|
$param['time'] = strtotime($param['time']);
|
|
|
$param['update_time'] = time();
|
|
|
$validate = new Validate([
|
|
|
'activity_name' => 'require',
|
|
|
'abstract'=>'require',
|
|
|
'content'=>'require',
|
|
|
'time' => 'require',
|
|
|
'thumbnail'=>'require',
|
|
|
]);
|
|
|
$validate->message([
|
|
|
'activity_name'=>'标题不能为空!',
|
|
|
'abstract'=>'摘要不能为空!',
|
|
|
'content' => '内容不能为空!',
|
|
|
'time' => '时间不能为空!',
|
|
|
'thumbnail'=>'请上传缩略图!',
|
|
|
]);
|
|
|
if (!$validate->check($param)) {
|
|
|
$this->error($validate->getError());
|
|
|
}
|
|
|
if(empty($param['is_up'])){
|
|
|
$param['is_up']=0;
|
|
|
}
|
|
|
Db::name('activity_news')
|
|
|
->where('id',$id)
|
|
|
->update($param);
|
|
|
$this->success('更新成功!');
|
|
|
}else{
|
|
|
$data=Db::name('activity_news')
|
|
|
->where('id',$id)
|
|
|
->find();
|
|
|
$activity_type=\db('activity_type')->select()->toArray();
|
|
|
foreach ($activity_type as $k=>$v){
|
|
|
$activity[$v['id']]['type_name']=$v['type_name'];
|
|
|
$activity[$v['id']]['id']=$v['id'];
|
|
|
}
|
|
|
$provincedb=db('position_province')->select()->toArray();
|
|
|
|
|
|
foreach ($provincedb as $k=>$v){
|
|
|
$province[$v['id']]['name']=$v['province_name'];
|
|
|
$province[$v['id']]['id']=$v['id'];
|
|
|
}
|
|
|
//dump($province);
|
|
|
$this->assign([
|
|
|
'data'=>$data,
|
|
|
'type'=>$activity,
|
|
|
'area'=>$province,
|
|
|
]);
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
}
|
|
|
//添加
|
|
|
public function add(){
|
|
|
if($this->request->isPost()){
|
...
|
...
|
@@ -156,6 +244,55 @@ class ActivityController extends AdminBaseController |
|
|
return $this->fetch();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public function addNews(){
|
|
|
if($this->request->isPost()){
|
|
|
$param=$this->request->param();
|
|
|
$param['create_time']=time();
|
|
|
$param['update_time']=time();
|
|
|
$param['time']=strtotime($param['time']);
|
|
|
$validate = new Validate([
|
|
|
'activity_name' => 'require',
|
|
|
'abstract'=>'require',
|
|
|
'content'=>'require',
|
|
|
'time' => 'require',
|
|
|
'thumbnail'=>'require',
|
|
|
]);
|
|
|
$validate->message([
|
|
|
'activity_name'=>'标题不能为空!',
|
|
|
'abstract'=>'摘要不能为空!',
|
|
|
'content' => '内容不能为空!',
|
|
|
'time' => '时间不能为空!',
|
|
|
'thumbnail'=>'请上传缩略图!',
|
|
|
]);
|
|
|
if (!$validate->check($param)) {
|
|
|
$this->error($validate->getError());
|
|
|
}
|
|
|
if(empty($param['is_up'])){
|
|
|
$param['is_up']=0;
|
|
|
}
|
|
|
Db::name('activity_news')
|
|
|
->insert($param);
|
|
|
$this->success('添加成功!');
|
|
|
}else{
|
|
|
$activity_type=\db('activity_type')->select()->toArray();
|
|
|
foreach ($activity_type as $k=>$v){
|
|
|
$activity[$v['id']]['type_name']=$v['type_name'];
|
|
|
$activity[$v['id']]['id']=$v['id'];
|
|
|
}
|
|
|
$provincedb=db('position_province')->select()->toArray();
|
|
|
|
|
|
foreach ($provincedb as $k=>$v){
|
|
|
$province[$v['id']]['name']=$v['province_name'];
|
|
|
$province[$v['id']]['id']=$v['id'];
|
|
|
}
|
|
|
$this->assign([
|
|
|
'type'=>$activity,
|
|
|
'area'=>$province,
|
|
|
]);
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
}
|
|
|
//删除
|
|
|
public function delete(){
|
|
|
$param = $this->request->param();
|
...
|
...
|
@@ -185,6 +322,34 @@ class ActivityController extends AdminBaseController |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
public function deleteNews(){
|
|
|
$param = $this->request->param();
|
|
|
|
|
|
if (isset($param['id'])) {
|
|
|
$id = $this->request->param('id', 0, 'intval');
|
|
|
$resultPortal = Db::name('activity')
|
|
|
->where(['id' => $id])
|
|
|
->update(['delete_time' => time()]);
|
|
|
if($resultPortal){
|
|
|
$this->success("删除成功!", '');
|
|
|
}else{
|
|
|
$this->error("删除失败!", '');
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (isset($param['ids'])) {
|
|
|
$ids = $this->request->param('ids/a');
|
|
|
$result = Db::name('activity')
|
|
|
->where(['id' => ['in', $ids]])
|
|
|
->update(['delete_time' => time()]);
|
|
|
if ($result) {
|
|
|
$this->success("删除成功!", '');
|
|
|
}else{
|
|
|
$this->error("删除失败!", '');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//排序
|
|
|
public function sort(){
|
|
|
$ids=$this->request->param('sort/a');
|
...
|
...
|
|