namespace appindexcontroller;
use appBase;
use thinkApp;
use thinkfacadeCache;
use thinkRequest;
use thinkfacadeView;
use thinkfacadeDb;
use appindexmodelIndex as Indexmodel;
use appindexserviceUserInfo 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,
]);
}