Browse Source

首页重构

lizhen_gitee 8 months ago
parent
commit
a7bfac5a29
2 changed files with 10 additions and 53 deletions
  1. 0 3
      application/api/controller/Index.php
  2. 10 50
      application/api/controller/Tvindex.php

+ 0 - 3
application/api/controller/Index.php

@@ -17,9 +17,6 @@ class Index extends Api
     protected $noNeedLogin = ['banner', 'activelist', 'personaltype', 'personalactivetype', 'car', 'leader', 'personaldirection', 'activeinfo', 'position', 'gamelist', 'special_models', 'app_error','indexdata','tudingc'];
     protected $noNeedRight = ['*'];
 
-    public function __construct(){
-        $this->error('老接口全部停用');
-    }
 
     /**
      * 首页

+ 10 - 50
application/api/controller/Tvindex.php

@@ -46,66 +46,26 @@ class Tvindex extends Api
         $data['page_wenzhen'] = list_domain_image($page_wenzhen,['image']);
 
         //大分类+剧集
-        $video_type = Db::name('video_type')->field('id,name,showtype')->where('status',1)->where('type','neq',3)->order('weigh asc, id desc')->select();
-        $video = Db::name('video')->field('id, video_type_id, title, image, is_pay')->where(['status' => 1, 'inject_status' => 2])->order('weigh asc, id desc')->select();
-        $video = list_domain_image($video, ['image']);
+        $video_cate = Db::name('video_cate')->field('id,name,showtype,is_zhuanti')->where('status',1)->order('weigh asc, id desc')->select();
+        $video_childcate = Db::name('video_childcate')->field('id, cate_id, name, image')->where('status',1)->order('weigh asc, id desc')->select();
+        $video_childcate = list_domain_image($video_childcate, ['image']);
 
         //分布:1=左一右四,2=两行八个,3=一行四个,4=一行三个
-        $more = [
-            'id' => 0,
-            'video_type_id' => 0,
-            'title' => '查看更多',
-            'image' => 'https://jiankang-1304634122.cos.ap-nanjing.myqcloud.com/uploads/20240529/37bd30cf2b80186b51f3bbfedb10a7d5.png',
-            'is_pay'=> 0,
-        ];
-        foreach($video_type as $key => $type){
-            $type['child'] = [];
-
-            $more['video_type_id'] = $type['id'];
+        foreach($video_cate as $key => $cate){
+            $cate['child'] = [];
 
             //循环放入child
             $child = [];
-            foreach($video as $k => $v){
-                if($type['id'] == $v['video_type_id']){
+            foreach($video_childcate as $k => $v){
+                if($cate['id'] == $v['cate_id']){
                     $child[] = $v;
                 }
             }
-            //查看更多
-            if($type['showtype'] == 1){
-                if(count($child) > 5){
-                    $child = array_chunk($child,4)[0];
-                    $child[] = $more;
-                }
-            }
-            if($type['showtype'] == 2){
-                if(count($child) > 8){
-                    $child = array_chunk($child,7)[0];
-                    $child[] = $more;
-                }
-            }
-            if($type['showtype'] == 3){
-                if(count($child) > 4){
-                    $child = array_chunk($child,3)[0];
-                    $child[] = $more;
-                }
-            }
-            if($type['showtype'] == 4){
-                if(count($child) > 3){
-                    $child = array_chunk($child,2)[0];
-                    $child[] = $more;
-                }
-            }
 
-            $type['child'] = $child;
-            $video_type[$key] = $type;
+            $cate['child'] = $child;
+            $video_cate[$key] = $cate;
         }
-        $data['video_type'] = $video_type;
-
-
-        //精彩专题
-        $data['buttom_name'] = '精彩专题';
-        $buttom_list = Db::name('video_type')->field('id,name,image')->where('status',1)->where('type',3)->order('weigh asc,id desc')->limit(3)->select();
-        $data['buttom_list'] = list_domain_image($buttom_list,['image']);
+        $data['video_cate'] = $video_cate;
 
         $this->success('首页',$data);
     }