From afafa4c68309e1f5de93d78cc8f2c1c6dbb57954 Mon Sep 17 00:00:00 2001 From: bill <276957690@qq.com> Date: Tue, 2 Nov 2021 17:16:13 +0800 Subject: [PATCH] 3 --- app/Http/Controllers/Home/IndexController.php | 46 +++++++++++-------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/app/Http/Controllers/Home/IndexController.php b/app/Http/Controllers/Home/IndexController.php index d7707b5..35e427e 100644 --- a/app/Http/Controllers/Home/IndexController.php +++ b/app/Http/Controllers/Home/IndexController.php @@ -3,6 +3,8 @@ namespace App\Http\Controllers\Home; use App\Http\Controllers\Home\CommonController; +use App\Http\Model\Article; +use App\Http\Model\Slide; use Illuminate\Support\Facades\DB; use Illuminate\Http\Request; @@ -28,29 +30,37 @@ class IndexController extends BaseController $data['tjlist'] = $res['data']['list']; //列表 - $pagesize = 10; - $offset = 0; + $res = logic('article')->getList([], array('id', 'desc'), '*', 0, 10); - $postdata = array( - 'limit' => $pagesize, - 'offset' => $offset - ); - $url = env('APP_API_URL') . "/article_list"; - $res = curl_request($url, $postdata, 'GET'); + if($res['count']>0) + { + foreach($res['list'] as $k=>$v) + { + $res['list'][$k]->url = get_front_url(array("id"=>$v->id,"type"=>'content')); + $res['list'][$k]->pubdatetext = date("Y-m-d", $v->pubdate); - $data['article_list'] = $res['data']['list']; - $data['article_count'] = intval($res['data']['count']); + } + } + $data['article_list'] = $res['list']; + $data['article_count'] = intval($res['count']); //banner轮播图 - $postdata = array( - 'type' => 0, - 'limit' => 5, - 'offset' => 0 - ); - $url = env('APP_API_URL') . "/slide_list"; - $res = curl_request($url, $postdata, 'GET'); - $data['slide_list'] = $res['data']['list']; + $where = [ + "type"=>0 + ]; + $where['is_show'] = Slide::IS_SHOW; + + $res = logic('Slide')->getList($where, array('listorder', 'asc'), '*', 0, 5); + + if($res['count']>0) + { + foreach($res['list'] as $k=>$v) + { + if(!empty($res['list'][$k]->pic)){$res['list'][$k]->pic = http_host().$v->pic;} + } + } + $data['slide_list'] = collect($res['list'])->toArray(); return view('home.index.index', $data); }