提交
This commit is contained in:
55
app/home/controller/News.php
Normal file
55
app/home/controller/News.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
use api\Httpcurl;
|
||||
use think\facade\Log;
|
||||
use think\facade\View;
|
||||
use think\Request;
|
||||
|
||||
class News extends Base
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
$page = input('page') ? input('page') : 1;
|
||||
$size = input('size') ? input('size') : 10;
|
||||
$news_list = Httpcurl::request(config('app.NEWS_LIST'), 'post', [
|
||||
'type' => MODEL,
|
||||
'page' => $page,
|
||||
'size' => $size,
|
||||
]);
|
||||
$news_list = json_decode($news_list[0], true);
|
||||
Log::info(json_encode($news_list));
|
||||
if ($news_list['code'] == 1) {
|
||||
View::assign('news_list', $news_list['data']);
|
||||
View::assign('count', $news_list['count']);
|
||||
View::assign('page', $page);
|
||||
View::assign('size', $size);
|
||||
} else {
|
||||
View::assign('news_list', []);
|
||||
}
|
||||
return View::fetch('news');
|
||||
}
|
||||
|
||||
public function detail(Request $request)
|
||||
{
|
||||
$data = $request->param();
|
||||
if (empty($data['id'])) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
$info = Httpcurl::request(config('app.NEWS_DETAIL'), 'post', [
|
||||
'type' => MODEL,
|
||||
'id' => $data['id'],
|
||||
]);
|
||||
$info = json_decode($info[0], true);
|
||||
Log::info(json_encode($info));
|
||||
$info_detail = [];
|
||||
if ($info['code'] == 1) {
|
||||
$info_detail = $info['data'];
|
||||
}
|
||||
|
||||
View::assign('info', $info_detail);
|
||||
return View::fetch('news_detail');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user