zxb пре 5 година
родитељ
комит
de792b899c
2 измењених фајлова са 23 додато и 8 уклоњено
  1. 11 3
      app/index/controller/JiamengController.php
  2. 12 5
      app/index/controller/NewsController.php

+ 11 - 3
app/index/controller/JiamengController.php

@@ -324,8 +324,16 @@ class JiamengController extends HomeBaseController
         //排行
         $paihang = Db::name('jiameng')->field('id,title,logo,touzi_level,mendian,hits')->where('catid', $info['catid'])->where('status', 1)->order('hits desc')->limit(5)->select();
         //动态
-        $about_news = Db::name('news')->field('id,title,thumb,create_time')->where(['ncatid' => 1, 'status' => 1])->order('id desc')->limit(6)->select();
-        $brand_news = Db::name('news')->field('id,title,thumb,create_time')->where(['catid' => $info['catid'], 'status' => 1])->order('id desc')->limit(6)->select();
+        // $about_news = Db::name('news')->field('id,title,thumb,create_time')->where(['ncatid' => 1, 'status' => 1])->order('id desc')->limit(6)->select();
+        // $brand_news = Db::name('news')->field('id,title,thumb,create_time')->where(['catid' => $info['catid'], 'status' => 1])->order('id desc')->limit(6)->select();
+
+        $about_news = Db::name('news')->field('id,title,thumb,create_time')->where(['status' => 1])
+          ->where('create_time','lt',$info['create_time'])
+          ->order('id desc')->limit(6)->select();
+        $brand_news = Db::name('news')->field('id,title,thumb,create_time')->where(['status' => 1])
+          ->where('create_time','gt',$info['create_time'])
+          ->limit(6)->select();
+
         //热门加盟
         $hot_jm = Db::name('jiameng')->field('id,title,hits')->where('catid', $info['catid'])->where('status', 1)->order('hits desc')->limit(20)->select();
         //最新加盟
@@ -351,7 +359,7 @@ class JiamengController extends HomeBaseController
         $this->assign('hot_jm', $hot_jm);
         $this->assign('zx_jm', $zx_jm);
         $this->assign('jx_jm', $jx_jm);
-        $this->assign('about_news', $about_news);
+        $this->assign('about_news', array_reverse($about_news->toArray()));
         $this->assign('brand_news', $brand_news);
         $this->assign('paihang', $paihang);
         $this->assign('hot_cate', $hot_cate);

+ 12 - 5
app/index/controller/NewsController.php

@@ -112,11 +112,18 @@ class NewsController extends HomeBaseController
         //相关动态和品牌动态   2020-08-24
         $about_news = Db::name('news')->field('id,title,thumb,create_time')->where(['status'=> 1])
         ->where(function($query) use ($id){
+            $query->where('id','lt',$id);
+        })
+        ->order('id desc')
+        ->limit(6)->select();  
+        //echo Db::name('news')->getLastSql();die();
+        // $brand_news = Db::name('news')->field('id,title,thumb,create_time')->where(['catid'=>$info['catid'],'status'=> 1])->order('id desc')->limit(6)->select();
+        $brand_news = Db::name('news')->field('id,title,thumb,create_time')->where(['status'=> 1])
+        ->where(function($query) use ($id){
             $query->where('id','gt',$id);
         })
-        ->order('list_order')->limit(6)->select();  
-
-        $brand_news = Db::name('news')->field('id,title,thumb,create_time')->where(['catid'=>$info['catid'],'status'=> 1])->order('id desc')->limit(6)->select();
+       
+        ->limit(6)->select();  
 
         $keywords = [];
         if(isset($info['keywords']) && !empty($info['keywords'])){
@@ -134,9 +141,9 @@ class NewsController extends HomeBaseController
         $this->assign('jm_news',$jm_news);
         $this->assign('other_news',$other_news);
         $this->assign('keywords',$keywords);
-
+        //print_r(array_reverse($about_news->toArray()));die();
         //seo
-        $this->assign('about_news',$about_news);
+        $this->assign('about_news',array_reverse($about_news->toArray()));
         $this->assign('brand_news',$brand_news);
         $seo_title = $info['seo_title'];
         $seo_keywords = $info['seo_keywords'];;