103 行
3.3 KiB
PHP
103 行
3.3 KiB
PHP
<?php
|
|
|
|
|
|
namespace addons\official\controller\web;
|
|
|
|
|
|
use addons\official\model\OfficialCategory;
|
|
use addons\official\model\OfficialListJournalism;
|
|
use think\Request;
|
|
|
|
class OfficialJournalism extends OfficialBaseController
|
|
{
|
|
protected $model;
|
|
protected $noNeedLogin = '*';
|
|
protected $noNeedRight = '*';
|
|
|
|
|
|
public function __construct(Request $request = null)
|
|
{
|
|
$this->model = new OfficialListJournalism();
|
|
parent::__construct($request);
|
|
}
|
|
|
|
/**
|
|
* 列表
|
|
*/
|
|
public function list()
|
|
{
|
|
$data = [];
|
|
$p_id = (int)input('param.pid');
|
|
$son_id = (int)input('param.sid');
|
|
$this->setBasic();
|
|
//查詢父级
|
|
$res = $this->get_cate_pid_in_sid();
|
|
//如果所有子级别和父级一样
|
|
$status = 1;
|
|
if (($p_id == $son_id) && (count($res['son']))) {
|
|
$status = 2;
|
|
$ids = [$p_id];
|
|
foreach ($res['son'] as $item) {
|
|
if (($res['status'] != $item['status']) || ($res['official_rule_id'] != $item['official_rule_id'])) {
|
|
$status = 1;
|
|
}
|
|
$ids[] = $item['id'];
|
|
}
|
|
}
|
|
if ($son_id) {
|
|
$data = $this->model;
|
|
if ($status == 1) {
|
|
$data = $data->where('official_category_id', $son_id);
|
|
} else {
|
|
$data = $data->whereIn('official_category_id', $ids);
|
|
}
|
|
$data = $data->where('language', $this->language)
|
|
->where('deletetime', null)
|
|
->order('weigh', 'desc')
|
|
->field(['id,title,image,subheading,createtime'])
|
|
->paginate(15, $simple = $this->isMobile(), $config = [
|
|
'query' => ['pid' => $p_id, 'sid' => $son_id]
|
|
]);
|
|
}
|
|
return view("web/official_journalism/list{$this->Mobile}", compact('res', 'data'));
|
|
}
|
|
|
|
/**
|
|
* 详情
|
|
*/
|
|
public function details()
|
|
{
|
|
$id = (int)input('param.id');
|
|
//增加点击量
|
|
$this->addClick($this->model, $id);
|
|
|
|
$data = $this->model
|
|
->where('id', $id)
|
|
->where('language', $this->language)
|
|
->where('deletetime', null)
|
|
->find();
|
|
$this->setBasic(999, $data['title'], '', $data['subheading']);
|
|
$category = (new OfficialCategory())->where('id', $data['official_category_id'])->field(['id,name,e_name'])->find();
|
|
//前面一个新闻
|
|
$before = $this->model
|
|
->where('id', '<', $data['id'])
|
|
->where('official_category_id', $data['official_category_id'])
|
|
->where('language', $this->language)
|
|
->where('deletetime', null)
|
|
->order('id', 'desc')
|
|
->field(['id,title'])
|
|
->find();
|
|
//后面第一个新闻
|
|
$after = $this->model
|
|
->where('id', '>', $data['id'])
|
|
->where('official_category_id', $data['official_category_id'])
|
|
->where('language', $this->language)
|
|
->where('deletetime', null)
|
|
->order('id', 'asc')
|
|
->field(['id,title'])
|
|
->find();
|
|
|
|
return view("web/official_journalism/details{$this->Mobile}", compact('data', 'category', 'before', 'after'));
|
|
}
|
|
|
|
} |