2020-01-01 13:17:19 +08:00
|
|
|
<?php
|
2022-08-02 21:13:36 +08:00
|
|
|
/*
|
|
|
|
* @Author: TaoLer <317927823@qq.com>
|
|
|
|
* @Date: 2021-12-06 16:04:50
|
|
|
|
* @LastEditTime: 2022-07-27 09:14:12
|
|
|
|
* @LastEditors: TaoLer
|
|
|
|
* @Description: 首页优化版
|
|
|
|
* @FilePath: \github\TaoLer\app\index\controller\Index.php
|
|
|
|
* Copyright (c) 2020~2022 https://www.aieok.com All rights reserved.
|
|
|
|
*/
|
2020-01-01 13:17:19 +08:00
|
|
|
namespace app\index\controller;
|
|
|
|
|
|
|
|
use app\common\controller\BaseController;
|
2023-03-16 22:25:27 +08:00
|
|
|
use app\common\lib\facade\HttpHelper;
|
2020-01-01 13:17:19 +08:00
|
|
|
use think\facade\View;
|
|
|
|
use think\facade\Request;
|
|
|
|
use think\facade\Db;
|
2020-11-30 17:13:55 +08:00
|
|
|
use app\facade\Article;
|
2021-07-22 10:43:48 +08:00
|
|
|
use app\common\model\Slider;
|
2020-11-25 15:29:48 +08:00
|
|
|
use app\common\lib\Msgres;
|
2023-03-16 22:25:27 +08:00
|
|
|
use yzh52521\EasyHttp\Http;
|
|
|
|
use QL\QueryList;
|
2020-01-01 13:17:19 +08:00
|
|
|
|
|
|
|
class Index extends BaseController
|
2020-11-27 16:25:08 +08:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* 首页
|
|
|
|
* @return string
|
|
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
|
* @throws \think\db\exception\DbException
|
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
|
*/
|
2020-01-01 13:17:19 +08:00
|
|
|
public function index()
|
2022-04-17 17:09:19 +08:00
|
|
|
{
|
2020-01-08 17:37:41 +08:00
|
|
|
$types = input('type');
|
2020-11-29 17:27:47 +08:00
|
|
|
|
2021-07-22 10:43:48 +08:00
|
|
|
$slider = new Slider();
|
2022-04-17 17:09:19 +08:00
|
|
|
//幻灯
|
2022-08-02 21:13:36 +08:00
|
|
|
$sliders = Request::isMobile() ? $slider->getSliderList(12) : $slider->getSliderList(1);
|
2020-01-01 13:17:19 +08:00
|
|
|
//置顶文章
|
2020-11-30 17:13:55 +08:00
|
|
|
$artTop = Article::getArtTop(5);
|
2020-11-25 15:29:48 +08:00
|
|
|
//首页文章列表,显示20个
|
2022-04-17 17:09:19 +08:00
|
|
|
$artList = Article::getArtList(22);
|
2020-11-25 15:29:48 +08:00
|
|
|
//热议文章
|
2020-11-30 17:13:55 +08:00
|
|
|
$artHot = Article::getArtHot(10);
|
2022-08-02 21:13:36 +08:00
|
|
|
//首页广告
|
|
|
|
$indexAd = $slider->getSliderList(13);
|
2021-07-22 10:43:48 +08:00
|
|
|
//温馨通道
|
|
|
|
$fast_links = $slider->getSliderList(8);
|
2020-01-01 13:17:19 +08:00
|
|
|
//首页赞助
|
2021-07-22 10:43:48 +08:00
|
|
|
$ad_index = $slider->getSliderList(5);
|
|
|
|
//首页右栏图片
|
|
|
|
$ad_comm = $slider->getSliderList(2);
|
|
|
|
|
2021-07-07 17:17:58 +08:00
|
|
|
//友情链接申请
|
|
|
|
$adminEmail = Db::name('user')->where('id',1)->cache(true)->value('email');
|
|
|
|
|
2020-01-01 13:17:19 +08:00
|
|
|
$vs = [
|
|
|
|
'slider' => $sliders,
|
|
|
|
'artTop' => $artTop,
|
|
|
|
'artList' => $artList,
|
|
|
|
'artHot' => $artHot,
|
2022-08-02 21:13:36 +08:00
|
|
|
'ad_index_r'=> $indexAd,
|
2020-01-01 13:17:19 +08:00
|
|
|
'type' => $types,
|
|
|
|
'ad_index' => $ad_index,
|
|
|
|
'ad_comm' => $ad_comm,
|
2021-07-07 17:17:58 +08:00
|
|
|
'fastlinks' => $fast_links,
|
|
|
|
'adminEmail' => $adminEmail,
|
2021-05-20 11:52:40 +08:00
|
|
|
'jspage' => '',
|
2020-01-01 13:17:19 +08:00
|
|
|
];
|
|
|
|
View::assign($vs);
|
|
|
|
|
|
|
|
return View::fetch();
|
|
|
|
}
|
|
|
|
|
|
|
|
//回帖榜
|
|
|
|
public function reply()
|
|
|
|
{
|
2020-11-27 16:25:08 +08:00
|
|
|
$comment = new \app\common\model\Comment();
|
|
|
|
return $comment->reply(20);
|
2020-01-01 13:17:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public function jump()
|
|
|
|
{
|
|
|
|
$username = Request::param('username');
|
|
|
|
$u = Db::name('user')->whereOr('nickname', $username)->whereOr('name', $username)->find();
|
2020-04-30 18:35:46 +08:00
|
|
|
return redirect((string) url('user/home',['id'=>$u['id']]));
|
2020-01-01 13:17:19 +08:00
|
|
|
|
|
|
|
}
|
2020-11-01 18:13:05 +08:00
|
|
|
|
2020-11-02 21:54:26 +08:00
|
|
|
public function language()
|
2020-11-01 18:13:05 +08:00
|
|
|
{
|
2020-11-02 21:54:26 +08:00
|
|
|
if(request()->isPost()){
|
|
|
|
$language = new \app\common\controller\Language;
|
|
|
|
$lang = $language->select(input('language'));
|
|
|
|
if($lang){
|
2020-11-27 16:25:08 +08:00
|
|
|
return Msgres::success();
|
2020-11-02 21:54:26 +08:00
|
|
|
}
|
|
|
|
}else {
|
2020-11-25 15:29:48 +08:00
|
|
|
return Msgres::error('illegal_request');
|
2020-11-01 18:13:05 +08:00
|
|
|
}
|
|
|
|
}
|
2020-01-01 13:17:19 +08:00
|
|
|
|
|
|
|
}
|