NewsController.php 5.3 KB
<?php
/**
 * 新闻与媒体
 * Author : xiaojie
 * DateTime: 2018/12/06 11:42
 */
namespace app\portal\controller;

use app\portal\model\PageModel;
use app\portal\model\PortalCategoryModel;
use app\portal\model\ShowModel;
use cmf\controller\HomeBaseController;

class NewsController extends HomeBaseController
{

    /**
     * 行业新闻,展会新闻,媒体报道,展会视频(36,37,38,39)
     * portal/news/news
     */
    public function news()
    {
        $cate_id = $this->request->param('cate_id');
        $showModel = new ShowModel();
        $list = $showModel->getList($cate_id);
        if($cate_id == 36){
            $location = '行业新闻';
            $menu_id = '42';
        }elseif ($cate_id == 37){
            $location = '展会新闻';
            $menu_id = '43';
        }elseif ($cate_id == 38){
            $location = '媒体报道';
            $menu_id = '44';
        }else{
            return false;
        }
        //分页样式
        $page = $this->getPageStyle($list);
        //所在位置
        $location = [
            [
                'location' => '新闻与媒体',
                'url' => 'javascript:;'
            ],
            [
                'location' => $location,
                'url' => 'javascript:;'
            ]
        ];
        $this->assign('list',$list);
        $this->assign('location',$location);
        $this->assign('page',$page);
        $this->assign('menu_id',$menu_id);
        return $this->fetch(':list');
    }

    /**
     * 展会视频
     * portal/news/video
     */
    public function video()
    {
        $cate_id = 39;
        $showModel = new ShowModel();
        $list = $showModel->getList($cate_id,'',6);
        //分页样式
        $page = $this->getPageStyle($list);
        //所在位置
        $location = [
            [
                'location' => '新闻与媒体',
                'url' => 'javascript:;'
            ],
            [
                'location' => '展会视频',
                'url' => 'javascript:;'
            ]
        ];

        $this->assign('list',$list);
        $this->assign('location',$location);
        $this->assign('page',$page);
        return $this->fetch();
    }


    /**
     * 合作媒体
     * portal/news/media
     */
    public function media()
    {
//        $cate_id = 40;
//        $showModel = new ShowModel();
//        $list = $showModel->getList($cate_id,'',16);
//        //分页样式
//        $page = $this->getPageStyle($list);
//        //所在位置
//        $location = [
//            [
//                'location' => '新闻与媒体',
//                'url' => 'javascript:;'
//            ],
//            [
//                'location' => '合作媒体',
//                'url' => 'javascript:;'
//            ]
//        ];
//
//        $this->assign('list',$list);
//        $this->assign('page',$page);
//        $this->assign('location',$location);
//        return $this->fetch();
        $keyword = $this->request->param('keyword','');
        $showModel = new ShowModel();
        $list = $showModel->getList(40,$keyword,16);
        $page = $this->getPageStyle($list);
        //所在位置
        $location = [
            [
                'location' => '新闻与媒体',
                'url' => 'javascript:;'
            ],
            [
                'location' => '合作媒体',
                'url' => 'javascript:;'
            ]
        ];
        $this->assign('list',$list);
        $this->assign('location',$location);
        $this->assign('page',$page);
        $this->assign('keyword',empty($keyword)?'':$keyword);
        return $this->fetch();
    }


    /**
     * 下载中心
     * portal/news/download
     */
    public function download()
    {
        $cate_id = 41;
        $showModel = new ShowModel();
        $list = $showModel->getList($cate_id,'',17);
        //分页样式
        $page = $this->getPageStyle($list);
        //所在位置
        $location = [
            [
                'location' => '新闻与媒体',
                'url' => 'javascript:;'
            ],
            [
                'location' => '下载中心',
                'url' => 'javascript:;'
            ]
        ];

        $this->assign('list',$list);
        $this->assign('page',$page);
        $this->assign('location',$location);
        return $this->fetch();
    }

    /**
     * 下载操作
     */
    public function download_file()
    {
        $id = $this->request->param('id');
        $showModel = new ShowModel();
        //增加下载次数
        $showModel->where('id',$id)->setInc('down_num',1);
        $this->apiResponse(1,'操作成功');
    }

    /**
     * 全部新闻
     * portal/news/all_news
     */
    public function all_news()
    {
        $cate_id = [36,37,38];
        $showModel = new ShowModel();
        $list = $showModel->getList($cate_id);
        //分页样式
        $page = $this->getPageStyle($list);
        //所在位置
        $location = [
            [
                'location' => '全部新闻',
                'url' => 'javascript:;'
            ],
            [
                'location' => '',
                'url' => 'javascript:;'
            ]
        ];
        $this->assign('list',$list);
        $this->assign('location',$location);
        $this->assign('page',$page);
        return $this->fetch(':list');
    }

}