Index.php 1022 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. /**
  6. * 首页接口
  7. */
  8. class Index extends Api
  9. {
  10. protected $noNeedLogin = ['*'];
  11. protected $noNeedRight = ['*'];
  12. /**
  13. * 首页
  14. *
  15. */
  16. public function index()
  17. {
  18. $this->success('请求成功');
  19. }
  20. // 新闻列表
  21. public function news()
  22. {
  23. $is_hot = input('is_hot','');
  24. $query = Db::name('news')->field('id,title,image,create_time');
  25. if (in_array($is_hot,[1])){
  26. $query->where('is_hot',$is_hot);
  27. }
  28. $list = $query->where('status',1)->order('weigh desc')->order('id desc')->autopage()->select();
  29. foreach ($list as $k => $v) {
  30. $list[$k]['image'] = cdnurl($v['image']);
  31. $list[$k]['create_time_text'] = date('Y-m-d H:i',$v['create_time']);
  32. $list[$k]['url'] = \app\utils\Common::getHttp('/index/index/news_detail/id/'.$v['id']);
  33. }
  34. return $this->success('success',$list);
  35. }
  36. }