NewsController.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * NewsController.php UTF-8
  4. * 新闻处理类
  5. *
  6. * @date : 2018/1/19 16:25
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : linjiebin <ljb@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace web\pc\controller\v8;
  13. use huolib\constant\NewsConst;
  14. use web\common\controller\WebBaseController;
  15. use web\pc\logic\SlideLogic;
  16. use web\pc\logic\PostLogic;
  17. class NewsController extends WebBaseController {
  18. public function __construct() {
  19. parent::__construct();
  20. }
  21. public function index() {
  22. $_web_info = $this->web_info;
  23. $this->set_seo($_web_info['web_basic']['company_name']);
  24. $_posts_class = new PostLogic();
  25. $_row = $this->request->param('row', 10);
  26. $_new_page = $this->request->param('new_page', 1);
  27. $_activity_page = $this->request->param('activity_page', 1);
  28. $_strategy_page = $this->request->param('strategy_page', 1);
  29. $_news_list['new'] = $_posts_class->getList(['catalog' => NewsConst::NEWS_TYPE_NEWS], $_new_page.','.$_row,'id desc');
  30. $_news_list['activity'] = $_posts_class->getList(['catalog' => NewsConst::NEWS_TYPE_STRATEGY], $_activity_page.','.$_row);
  31. $_news_list['strategy'] = $_posts_class->getList(['catalog' => NewsConst::NEWS_TYPE_ACTIVITY], $_strategy_page.','.$_row);
  32. $_title_map = [
  33. 'catalog'=>[
  34. 'in',
  35. [NewsConst::NEWS_TYPE_NEWS, NewsConst::NEWS_TYPE_STRATEGY, NewsConst::NEWS_TYPE_ACTIVITY]
  36. ]
  37. ];
  38. $_title_list = $_posts_class->getList($_title_map, '1,3');
  39. $_rdata = [
  40. 'news_list' => $_news_list,
  41. 'title_list' => $_title_list
  42. ];
  43. if($this->request->isAjax()){
  44. return $_rdata;
  45. }
  46. $this->assign($_rdata);
  47. return $this->fetch('News/index');
  48. }
  49. public function detail() {
  50. $_newsid = $this->request->param('newsid', 0);
  51. if(empty($_newsid)) {
  52. $this->error('参数错误');
  53. }
  54. $_posts_class = new PostLogic();
  55. $_rdata['detail'] = $_posts_class->getDetail($_newsid);
  56. if(!empty($_rdata['detail']['gameid'])) {
  57. $_map['gameid'] = $_rdata['detail']['gameid'];
  58. }else{
  59. $_map['catalog'] = $_rdata['detail']['type'];
  60. }
  61. $_rdata['similar'] = $_posts_class->getList($_map,'1,4');
  62. $_web_info = $this->web_info;
  63. $this->set_seo($_web_info['web_basic']['company_name'],'',$_rdata['detail']['title']);
  64. $this->assign($_rdata);
  65. return $this->fetch('News/detail');
  66. }
  67. }