Пример #1
0
 /**
  * 高校比较
  */
 public function compareAction()
 {
     //判断是否是ajax请求
     if ($this->request->isAjax()) {
         $validate = new \Validate();
         $data['id1'] = (int) $validate->getPost('id1');
         $data['id2'] = (int) $validate->getPost('id2');
         if ($data['id1'] == 0) {
             $this->end(400);
         }
         $this->end(json_encode((new \Search())->getSchool($data)));
     }
     $data['id1'] = (int) $this->request->getQuery('id1');
     $data['id2'] = (int) $this->request->getQuery('id2');
     if ($data['id1'] == 0 || $data['id2'] == 0) {
         $this->notFound();
     }
     $college = new \College();
     $college1 = $college->getCollegeCompare($data['id1']);
     $college2 = $college->getCollegeCompare($data['id2']);
     if (empty($college1) || empty($college2)) {
         $this->notFound();
     }
     //设置标题
     $this->tag->setTitle("51升学网-学校比较");
     $this->assets->addCss("fontend/css/school/compare.css");
     $this->assets->addJs("fontend/js/school_compare.js");
     $this->view->setVars(['college1' => $college1, 'college2' => $college2]);
 }