|
@@ -0,0 +1,101 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace app\api\controller;
|
|
|
+
|
|
|
+use app\common\controller\Api;
|
|
|
+use think\Db;
|
|
|
+
|
|
|
+class Tvindex extends Api
|
|
|
+{
|
|
|
+ protected $noNeedLogin = '*';
|
|
|
+ protected $noNeedRight = '*';
|
|
|
+
|
|
|
+ public function indexdata(){
|
|
|
+
|
|
|
+ //左上角 logo,名称,4个按钮
|
|
|
+
|
|
|
+ $data['index_logo'] = localpath_to_netpath(config('site.index_logo'));
|
|
|
+ $data['index_appname'] = config('site.index_appname');
|
|
|
+
|
|
|
+ $data['index_tuiding_switch'] = config('site.index_tuiding_switch');
|
|
|
+ $data['index_search_switch'] = config('site.index_search_switch');
|
|
|
+ $data['index_history_switch'] = config('site.index_history_switch');
|
|
|
+ $data['index_dinggou_switch'] = config('site.index_dinggou_switch');
|
|
|
+
|
|
|
+ //右上角 三行
|
|
|
+
|
|
|
+ $data['index_right_1'] = config('site.index_right_1');
|
|
|
+ $data['index_right_2'] = config('site.index_right_2');
|
|
|
+ $data['index_right_3'] = config('site.index_right_3');
|
|
|
+
|
|
|
+ //固定五个
|
|
|
+ $data['index_top_video_image'] = localpath_to_netpath(config('site.index_top_video_image'));
|
|
|
+ $data['index_top_video'] = localpath_to_netpath(config('site.index_top_video'));
|
|
|
+
|
|
|
+ $page_wenzhen = Db::name('page_wenzhen')->field('id,name,image,url')->where('status',1)->order('weigh asc')->select();
|
|
|
+ $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']);
|
|
|
+
|
|
|
+ //分布: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'] = [];
|
|
|
+
|
|
|
+ //循环放入child
|
|
|
+ $child = [];
|
|
|
+ foreach($video as $k => $v){
|
|
|
+ if($type['id'] == $v['video_type_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;
|
|
|
+ }
|
|
|
+ $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']);
|
|
|
+
|
|
|
+ $this->success('首页',$data);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|