<?php namespace app\api\controller; use app\common\controller\Api; use think\Db; /** * 首页接口 */ class Index extends Api { protected $noNeedLogin = ['*']; protected $noNeedRight = ['*']; /** * 首页 * */ public function index() { $this->success('请求成功'); } // 新闻列表 public function news() { $is_hot = input('is_hot',''); $query = Db::name('news')->field('id,title,image,create_time'); if (in_array($is_hot,[1])){ $query->where('is_hot',$is_hot); } $list = $query->where('status',1)->order('weigh desc')->order('id desc')->autopage()->select(); foreach ($list as $k => $v) { $list[$k]['image'] = cdnurl($v['image']); $list[$k]['create_time_text'] = date('Y-m-d H:i',$v['create_time']); $list[$k]['url'] = \app\utils\Common::getHttp('/index/index/news_detail/id/'.$v['id']); } return $this->success('success',$list); } }