Exemple #1
0
 public function actionIndex()
 {
     //友情链接
     $friendLink = new FriendLink();
     $friendLinks = $friendLink->getFriendLinks();
     $num = ceil(count($friendLinks) / 8);
     for ($i = 0; $i < count($friendLinks); $i++) {
         $newFriendLinks[floor($i / 8)][] = $friendLinks[$i];
     }
     // p($newFriendLinks[0][1]);
     //学术会议和展览展会
     $meetingModel = new MirMeeting();
     $xueshuMeetings = $meetingModel->find()->select("meeting_id,meeting_name,meeting_bdate")->where(["meeting_class" => '1'])->orderBy('meeting_id desc')->limit(5)->all();
     $zhanhuiMeetings = $meetingModel->find()->select("meeting_id,meeting_name,meeting_bdate")->where(["meeting_class" => '2'])->orderBy('meeting_id desc')->limit(5)->all();
     $meetingModel = new MirMeeting();
     //新闻中心
     $articleModel = new MirArticle();
     $news = $articleModel->articleToIndex(0);
     //招标公告
     $zhaobiao = $articleModel->articleToIndex(2);
     //技术分享
     $jishus = $articleModel->articleToIndex(3);
     // p($zhaobiao);
     //临床医学
     $ivdModel = new MirIvd();
     $linchuangyixues = $ivdModel->getIvdlist(3);
     $pinpaililiang = $ivdModel->getIvdlist(1);
     $zhutizhuanfang = $ivdModel->getIvdlist(2);
     $zhuanjiazhuanlan = $ivdModel->getIvdlist(4);
     // p($linchuangyixues);
     // 把主题专访  四个合并成一个
     $firstData[] = $linchuangyixues;
     $firstData[] = $zhutizhuanfang;
     $firstData[] = $zhuanjiazhuanlan;
     $firstData[] = $pinpaililiang;
     // p($firstData);
     // p($linchuangyixues);
     // IVD展厅
     $porduct = new MirProduct();
     $porducts = MirProduct::find()->orderBy("product_id desc")->limit(5)->all();
     // p($porducts[0]->product_pic);
     //索刊
     $mgzModel = new MirMgz();
     $mgz = $mgzModel->find()->orderBy("mgz_id desc")->groupBy("mgz_year,mgz_num")->all();
     for ($i = 0; $i < count($mgz); $i++) {
         $mgzYear[] = $mgz[$i]->mgz_year;
         $mgzNum[] = $mgz[$i]->mgz_num;
     }
     $fourPic = $porduct->find()->andWhere(["!=", "product_pic", "productnopic.gif"])->orderBy("product_id desc")->limit(4)->all();
     // p($fourPic);
     //获得视屏中心的照片
     $videoModel = new MirVideo();
     $videos = $videoModel->find()->orderBy("video_id desc")->all();
     return $this->render('index', ['newFriendLinks' => $newFriendLinks, 'zhanhuiMeetings' => $zhanhuiMeetings, 'xueshuMeetings' => $xueshuMeetings, 'news' => $news, 'zhaobiao' => $zhaobiao, 'jishus' => $jishus, 'firstData' => $firstData, 'porducts' => $porducts, 'mgzYear' => $mgzYear, 'mgzNum' => $mgzNum, 'fourPic' => $fourPic, 'videos' => $videos]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     /**
      *  根据参数选择展示的商品
      *  @var dis=>1 不现实的 0=>显示的 
      */
     $display = Yii::$app->request->get('dis');
     $map = ['product_disp' => $display];
     $query = MirProduct::find()->where($map);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['product_id' => $this->product_id, 'product_price' => $this->product_price, 'product_disp' => $this->product_disp, 'product_rank' => $this->product_rank]);
     $query->andFilterWhere(['like', 'product_name', $this->product_name])->andFilterWhere(['like', 'product_name_e', $this->product_name_e])->andFilterWhere(['like', 'product_date', $this->product_date])->andFilterWhere(['like', 'product_class', $this->product_class])->andFilterWhere(['like', 'product_place', $this->product_place])->andFilterWhere(['like', 'product_place_e', $this->product_place_e])->andFilterWhere(['like', 'product_standards', $this->product_standards])->andFilterWhere(['like', 'product_standards_e', $this->product_standards_e])->andFilterWhere(['like', 'product_model', $this->product_model])->andFilterWhere(['like', 'product_model_e', $this->product_model_e])->andFilterWhere(['like', 'product_performance', $this->product_performance])->andFilterWhere(['like', 'product_performance_e', $this->product_performance_e])->andFilterWhere(['like', 'product_parameter', $this->product_parameter])->andFilterWhere(['like', 'product_parameter_e', $this->product_parameter_e])->andFilterWhere(['like', 'product_contrast', $this->product_contrast])->andFilterWhere(['like', 'product_contrast_e', $this->product_contrast_e])->andFilterWhere(['like', 'product_appraise', $this->product_appraise])->andFilterWhere(['like', 'product_appraise_e', $this->product_appraise_e])->andFilterWhere(['like', 'product_pic', $this->product_pic])->andFilterWhere(['like', 'product_mainclass', $this->product_mainclass])->andFilterWhere(['like', 'product_brand', $this->product_brand])->andFilterWhere(['like', 'product_tui', $this->product_tui])->andFilterWhere(['in', 'product_maker', $this->product_maker]);
     return $dataProvider;
 }
Exemple #3
0
 public function actionIndex()
 {
     $classifyModel = new Classify();
     $dafenlei = $classifyModel->find()->where(["ParentID" => '0'])->limit(8)->all();
     // p($dafenlei);
     $articleModel = new MirArticle();
     $jobs = $articleModel->articleToIndex(5);
     //技术分享
     $jishus = $articleModel->articleToIndex(3);
     $productModel = new MirProduct();
     //ivd 五个广告图
     $adModel = new MirAd();
     $ads = $adModel->find()->orderBy("ad_rank desc,id desc")->limit(5)->all();
     // p($ads);
     // p($fourPic);
     // P($ivdList);
     // p(count($ivdList));
     //产品照片显示
     $mainClass = $productModel->mainClass();
     foreach ($mainClass as $k => $v) {
         $mainClassId[] = $k;
     }
     for ($i = 0; $i < count($mainClassId) - 1; $i++) {
         $products[] = MirProduct::find()->where(['product_mainclass' => $mainClassId[$i]])->orderBy("product_rank desc,product_id desc")->limit(9)->all();
         $data = $productModel->find()->where(["product_mainclass" => $mainClassId[$i]]);
         $pages = new Pagination(['totalCount' => $data->count(), 'pageSize' => '10']);
         $dataShow = $data->offset($pages->offset)->limit($pages->limit)->orderBy("product_rank desc,product_id desc")->all();
         $pagesArray[] = $pages;
         $productArray[] = $dataShow;
     }
     // p(count($products[1]));
     // p($pagesArray);
     // p($productArray);
     $mainClass = array_values($mainClass);
     return $this->render('index', ['dafenlei' => $dafenlei, 'jobs' => $jobs, 'jishus' => $jishus, 'ivdList' => $ivdList, 'mainClass' => $mainClass, 'products' => $products, 'productArray' => $productArray, 'pagesArray' => $pagesArray, 'ads' => $ads]);
 }