lizhen_gitee 11 місяців тому
батько
коміт
35ed8ee0db
1 змінених файлів з 17 додано та 0 видалено
  1. 17 0
      application/api/controller/Tvindex.php

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

@@ -195,4 +195,21 @@ class Tvindex extends Api
         $this->success('', $data);
     }
 
+    //搜索页
+    public function search(){
+        $keyword = input('keyword','');
+
+        //热门推荐4个
+        if(empty($keyword)){
+            $list = Db::name('video')->field('id, title, image, is_pay')->where(['status' => 1, 'inject_status' => 2])
+                ->orderRaw('rand()')->limit(12)->select();
+            $list = list_domain_image($list, ['image']);
+        }else{
+            $list = Db::name('video')->field('id, title, image, is_pay')->where(['status' => 1, 'inject_status' => 2])->where('search_title','LIKE','%'.$keyword.'%')->order('is_pay asc,weigh asc,id desc')->select();
+            $list = list_domain_image($list, ['image']);
+        }
+
+        $this->success('视频', $list);
+    }
+
 }