Przeglądaj źródła

更多页,详情页

lizhen_gitee 11 miesięcy temu
rodzic
commit
59aafe52de
1 zmienionych plików z 77 dodań i 0 usunięć
  1. 77 0
      application/api/controller/Tvindex.php

+ 77 - 0
application/api/controller/Tvindex.php

@@ -10,6 +10,7 @@ class Tvindex extends Api
     protected $noNeedLogin = '*';
     protected $noNeedRight = '*';
 
+    //首页
     public function indexdata(){
 
         //左上角 logo,名称,4个按钮
@@ -98,4 +99,80 @@ class Tvindex extends Api
         $this->success('首页',$data);
     }
 
+    //更多页
+    //视频列表
+    public function video_list() {
+        $type_id = input('type_id', 0, 'intval'); //分类id
+        if (!$type_id) {
+            $this->error('您的网络开小差了~');
+        }
+
+        $video_type = Db::name('video_type')->where('id',$type_id)->value('name');
+
+        $list = Db::name('video')->field('id, title, image, is_pay')->where(['video_type_id' => $type_id, 'status' => 1, 'inject_status' => 2])
+            ->order('weigh asc, id desc')->select();
+        $list = list_domain_image($list, ['image']);
+
+        $result = [
+            'typename'  => $video_type,
+            'videolist' => $list,
+        ];
+        $this->success('视频更多', $result);
+    }
+
+    //视频详情
+    public function videoinfo() {
+
+        $id = input('id', 0, 'intval'); //视频id
+        if (!$id) {
+            $this->error('您的网络开小差了');
+        }
+
+        $info = Db::name('video')->field('id,video_type_id, title, image, desc, is_pay, status, inject_status, seriesid, programid, movieid')
+            ->where(['id' => $id])->find();
+        if (!$info) {
+            $this->error('数据不存在');
+        }
+        if ($info['status'] != 1) {
+            $this->error('视频丢失');
+        }
+        if ($info['inject_status'] != 2) {
+            $this->error('视频丢失');
+        }
+
+        $info['image'] = one_domain_image($info['image']);
+        $info['is_collection'] = Db::name('video_collection')->where(['user_id' => $this->auth->id, 'video_id' => $id])->count('id');
+        $info['is_good']       = Db::name('video_good')->where(['user_id' => $this->auth->id, 'video_id' => $id])->count('id');
+
+        //剧集列表
+        $juji = [];
+        $video_list = Db::name('video')->field('id, title, image, is_pay')->where(['video_type_id' => $info['video_type_id'], 'status' => 1, 'inject_status' => 2])
+            ->order('weigh asc, id desc')->select();
+        if(!empty($video_list)){
+            $video_list = list_domain_image($video_list, ['image']);
+
+            $video_list = array_chunk($video_list,10);
+            foreach($video_list as $page => $ten){
+                $juji[] = [
+                    'name'=> ($page*10 + 1) .'-'. ($page*10 + 10),
+                    'list'=>$ten,
+                ];
+            }
+        }
+
+        //猜你喜欢
+        $guess_list = Db::name('video')->field('id, title, image, is_pay')->where(['status' => 1, 'inject_status' => 2])
+            ->orderRaw('rand()')->limit(4)->select();
+        $guess_list = list_domain_image($guess_list, ['image']);
+
+        //
+        $result = [
+            'video_info' => $info,
+            'juji_list'  => $juji,
+            'guess_list' => $guess_list,
+        ];
+
+        $this->success('详情', $result);
+    }
+
 }