namespace app\index\controller;
use app\Base;
use think\App;
use think\facade\Cache;
use think\Request;
use think\facade\View;
use think\facade\Db;
use app\index\model\Index as Indexmodel;
use app\index\service\UserInfo as UserInfoService;
class Common extends Base
{
public function __construct()
{
parent::__construct();
$user_info = Db::name('user') ->where(['uid' => session('user')['uid']])->find();
$controller = Request()->controller();
$action = Request()->action();
$lang_all = config('console')['lang'];
$array_config = Db::name('webconfig')->where(['type'=>0])->select();
$web_config = array();
foreach ($array_config as $k => $v) {
$web_config[$v['code']] = $v['value'];
}
//首页顶级分类展示
$cate_parent = (new Indexmodel())->geTparentCateGory();
foreach ($cate_parent as $k => $val ){
$son = Db::name('category')->where('parent_id',$val['id'])->select();
$cate_parent[$k]['son'] = $son;
}
// halt($cate_parent);
// 首页子分类展示
$cate_list = (new Indexmodel())->geTcateGory();
// halt($cate_list);
//底部文章的查询
$article = Db::name('new')->select();
//个人信息的查询
$user_where['uid'] = session('user')['uid'];
$user_info = (new UserInfoService())->getUser($user_where);
if(!empty($user_info['uid'])){
$is_login = 1;
}else{
$is_login = 0;
}
//友情链接
$link = Db::name('link')->select();
// 热门搜索
$HotSearch = Db::name('search')->order('search_number','desc')->limit(5)->select();
//系统处理
$articledd = Db::name('article')->where('uid',session('user')['uid'])->where('status','7')->count();
//处理失败
$articled2 = Db::name('article')->where('uid',session('user')['uid'])->where('status','8')->count();
//待自审
$articled3 = Db::name('article')->where('uid',session('user')['uid'])->where('status','9')->count();
//后台审核
$articled4 = Db::name('article')->where('uid',session('user')['uid'])->where('status','1')->count();
//审核被拒
$articled5 = Db::name('article')->where('uid',session('user')['uid'])->where('status','3')->count();
//已上架
$articled6 = Db::name('article')->where('uid',session('user')['uid'])->where('status','2')->count();
//已下架
$articled7 = Db::name('article')->where('uid',session('user')['uid'])->where('status','0')->count();
//我的消息
$allmsg = Db::name('notification')->alias('n')->where('n.recipient_uid',session('user')['uid'])->join(['aws_notification_data'=>'b'],'n.notification_id = b.notification_id')->where('read_flag','0')->count();
$id = session('user')['uid'];
$where[] = ['recipient_uid','like',"%{$id}%"];
$mail = Db::name('webmaster_msg')->where($where)->where('read_flag','0')->count();
$countmsg = $allmsg+$mail;
//企业认证状态
$company_status =Db::name('user_company')->where('uid',session('user')['uid'])->find();
//个人认证状态
$authentication =Db::name('user_authentication')->where('uid',session('user')['uid'])->order('a_add_time','desc')->limit(1)->select();
View::assign([
'cate_list'=>$cate_list,
'user_info' => $user_info,
'controller' => $controller,
'action' => $action,
'lang_all'=>$lang_all,
'lang_cookie'=> cookie('think_lang'),
'user_session'=>session('user'),
'web_config'=>$web_config,
'link'=>$link,
'article'=>$article,
'cate_parent'=>$cate_parent,
'is_login' =>$is_login,
'HotSearch' => $HotSearch,
'articledd' => $articledd,
'articled2' => $articled2,
'articled3' => $articled3,
'articled4' => $articled4,
'articled5' => $articled5,
'articled6' => $articled6,
'articled7' => $articled7,
'countmsg' => $countmsg,
'company_status' => $company_status,
'authentication' => $authentication,
]);
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
- 48.
- 49.
- 50.
- 51.
- 52.
- 53.
- 54.
- 55.
- 56.
- 57.
- 58.
- 59.
- 60.
- 61.
- 62.
- 63.
- 64.
- 65.
- 66.
- 67.
- 68.
- 69.
- 70.
- 71.
- 72.
- 73.
- 74.
- 75.
- 76.
- 77.
- 78.
- 79.
- 80.
- 81.
- 82.
- 83.
- 84.
- 85.
- 86.
- 87.
- 88.
- 89.
- 90.
- 91.
- 92.
- 93.
- 94.
- 95.
- 96.
- 97.
- 98.
- 99.
- 100.
- 101.
- 102.
- 103.
- 104.