Procházet zdrojové kódy

视频详情,简单版

lizhen_gitee před 9 měsíci
rodič
revize
6585fff96c
1 změnil soubory, kde provedl 46 přidání a 0 odebrání
  1. 46 0
      application/api/controller/Tvindex.php

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

@@ -190,6 +190,52 @@ class Tvindex extends Api
 
         $this->success('详情', $result);
     }
+    public function videoinfo_simple() {
+
+        $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');
+
+        //记录浏览历史
+        if($this->auth->isLogin()){
+            $view_map = [
+                'user_id'  => $this->auth->id,
+                'video_id' => $id,
+            ];
+            $check_view = Db::name('video_view')->where($view_map)->find();
+            if($check_view){
+                Db::name('video_view')->where($view_map)->update(['updatetime'=>time()]);
+            }else{
+                $view_map['createtime'] = time();
+                $view_map['updatetime'] = time();
+                Db::name('video_view')->insertGetId($view_map);
+            }
+        }
+
+        //
+        $result = [
+            'video_info' => $info,
+        ];
+
+        $this->success('详情', $result);
+    }
 
     //专题页
     public function zhuanti(){