Example #1
0
 /**
  * 高校详情
  */
 public function indexAction($col_id)
 {
     //判断是否是ajax请求
     if ($this->request->isAjax()) {
         $validate = new \Validate();
         $data['col_id'] = $col_id;
         $data['name'] = $validate->getPost('name');
         $data['content'] = $validate->getPost('content', \Validate::length(255, 0), ['slashes' => true, 'html' => true]);
         $data['phone'] = $validate->getPost('phone');
         if ($validate->getMessage()) {
             $this->end(404);
         }
         $this->end((new \College())->SignUp($data));
     }
     //页面缓存时间
     $cacheTime = 3600;
     $html_name = $col_id . '.html';
     //检查是否使用缓存页面
     //$this->staticHtml($html_name, $cacheTime);
     $model = new \College();
     //获取大学信息
     $college = $model->getCollegeDetail($col_id);
     if (!$college) {
         $this->notFound();
     }
     $model->addClick($col_id, rand(5, 12));
     //获取学校属性
     $attribute = $model->getAttribute($col_id);
     //获取学校热门专业
     $major = $model->getHotMajor($col_id, 10);
     //获取推荐学校
     $command = $model->getCommand($college['col_type'], 4);
     //获取学校动态
     $news = $model->getColNews($col_id);
     //获取知名校友
     $alumnus = $model->getColAlumnus($col_id);
     $praise = $model->getColPraise($col_id, 5);
     foreach ($praise['list'] as $key => $val) {
         $praise['list'][$key]['col_rev_ip'] = $this->ipGetCity($val['col_rev_ip']) == 404 ? "未知网友" : $this->ipGetCity($val['col_rev_ip']);
     }
     //设置标题
     $this->tag->setTitle($college['col_name'] . "-51升学网");
     $web_desc = strip_tags($college['col_summary']);
     //引入css 和js
     $this->assets->addCss("fontend/css/org2/university/index.css");
     $this->assets->addJs("fontend/js/org2_index.js");
     $this->view->setVars(['college' => $college, 'attribute' => $attribute, 'major' => $major, 'command' => $command, 'web_desc' => $web_desc, 'news' => $news, 'alumnus' => $alumnus, 'praise' => $praise]);
 }