Selaa lähdekoodia

修改添加、修改组件

15313670163 5 kuukautta sitten
vanhempi
sitoutus
c0164a0b7e
1 muutettua tiedostoa jossa 47 lisäystä ja 17 poistoa
  1. 47 17
      app/JsonRpc/PublicRpcService.php

+ 47 - 17
app/JsonRpc/PublicRpcService.php

@@ -1490,8 +1490,8 @@ class PublicRpcService implements PublicRpcServiceInterface
         if(empty($component_type)){
             return Result::error('组件分类不存在!');
         }
-        // 组件分类:1:资讯-头条组件;2:资讯-轮播组件;3:资讯-推荐图类组件;4:资讯-最新类组件;5:资讯-推荐类;6:资讯-热点类组件;
-        // 7:资讯-栏目类组件;8:列表类组件;9:详情类组件;10:二级导航栏类组件;11:广告类;12:静态资源类;13:底部导航类;
+        // '组件分类:1:资讯-头条组件;2:资讯-轮播组件;3:资讯-推荐图类组件;4:资讯-最新类组件;5:资讯-推荐类;6:资讯-热点类组件;7:资讯-栏目类组件;
+        // 8:列表类组件;9:详情类组件;10:二级导航栏类组件;11:广告类;12:静态资源类;13:底部导航类;14:广告资讯混合类
         $data['type_id'] = intval($data['type_id']);
         $add_arr = [
             // 'template_id' => intval($data['template_id']),
@@ -1601,7 +1601,7 @@ class PublicRpcService implements PublicRpcServiceInterface
                 $add_arr['component_width'] = intval($data['ad_width']);
                 $add_arr['component_height'] = intval($data['ad_height']);
                 $add_arr['ad_type'] = intval($data['ad_type']);
-                // $add_arr['ad_img'] = $data['ad_img'];
+                $add_arr['ad_img'] = $data['ad_img'];
                 $ad = [
                     'width' => $add_arr['ad_width'],
                     'height' => $add_arr['ad_height'],
@@ -1609,7 +1609,7 @@ class PublicRpcService implements PublicRpcServiceInterface
                     'price' => '',
                     'introduce' => '',
                     'website_id' => '',
-                    // 'thumb' => $add_arr['ad_img'],
+                    'thumb' => $add_arr['ad_img'],
                     'typeid' => $add_arr['ad_type'],
                     'ad_tag' => '',
                 ];
@@ -1634,7 +1634,7 @@ class PublicRpcService implements PublicRpcServiceInterface
                 $add_arr['component_width'] = intval($data['component_width']);
                 $add_arr['component_height'] = intval($data['component_height']);
                 $add_arr['ad_type'] = intval($data['ad_type']);
-                // $add_arr['ad_img'] = $data['ad_img'];
+                $add_arr['ad_img'] = $data['ad_img'];
                 $add_arr['img_num'] = intval($data['img_num']);
                 $add_arr['text_num'] = intval($data['text_num']);
                 $add_arr['child_imgnum'] = intval($data['child_imgnum'] ?? null);
@@ -1659,7 +1659,7 @@ class PublicRpcService implements PublicRpcServiceInterface
                     'price' => '',
                     'introduce' => '',
                     'website_id' => '',
-                    // 'thumb' => $add_arr['ad_img'],
+                    'thumb' => $add_arr['ad_img'],
                     'typeid' => $add_arr['ad_type'],
                     'ad_tag' => '',
                 ];
@@ -1874,7 +1874,7 @@ class PublicRpcService implements PublicRpcServiceInterface
                 $add_arr['component_width'] = intval($data['ad_width']);
                 $add_arr['component_height'] = intval($data['ad_height']);
                 $add_arr['ad_type'] = intval($data['ad_type']);
-                // $add_arr['ad_img'] = $data['ad_img'];
+                $add_arr['ad_img'] = $data['ad_img'];
                 $ad = [
                     'width' => $add_arr['ad_width'],
                     'height' => $add_arr['ad_height'],
@@ -1882,7 +1882,7 @@ class PublicRpcService implements PublicRpcServiceInterface
                     'price' => '',
                     'introduce' => '',
                     'website_id' => '',
-                    // 'thumb' => $add_arr['ad_img'],
+                    'thumb' => $add_arr['ad_img'],
                     'typeid' => $add_arr['ad_type'],
                     'ad_tag' => '',
                 ];
@@ -1906,7 +1906,7 @@ class PublicRpcService implements PublicRpcServiceInterface
                 $add_arr['component_width'] = intval($data['component_width']);
                 $add_arr['component_height'] = intval($data['component_height']);
                 $add_arr['ad_type'] = intval($data['ad_type']);
-                // $add_arr['ad_img'] = $data['ad_img'];
+                $add_arr['ad_img'] = $data['ad_img'];
                 $add_arr['img_num'] = intval($data['img_num']);
                 $add_arr['text_num'] = intval($data['text_num']);
                 $add_arr['child_imgnum'] = intval($data['child_imgnum'] ?? null);
@@ -1931,7 +1931,7 @@ class PublicRpcService implements PublicRpcServiceInterface
                     'price' => '',
                     'introduce' => '',
                     'website_id' => '',
-                    // 'thumb' => $add_arr['ad_img'],
+                    'thumb' => $add_arr['ad_img'],
                     'typeid' => $add_arr['ad_type'],
                     'ad_tag' => '',
                 ];
@@ -2632,8 +2632,8 @@ class PublicRpcService implements PublicRpcServiceInterface
                 $where['component.component_height'] = $data['height'];
             }
             $component = Component::where($where)
-            // ->leftJoin('size','component.size_id','=','size.id')
-            // ->select('component.*','size.width','size.height')
+            ->leftJoin('component_img','component.component_id','=','component_img.component_id')
+            ->select('component.*','component_img.img_id','component_img.img_url','img_name')
             ->get()->all();
         }
         
@@ -2649,19 +2649,49 @@ class PublicRpcService implements PublicRpcServiceInterface
     {
         $where = [];
          if(isset($data['template_id']) && !empty($data['template_id'])){
-            $where['template_id'] = $data['template_id'];
+            $where['sector.template_id'] = $data['template_id'];
         }
         if(isset($data['page_type']) && !empty($data['page_type'])){
-            array_push($where,['page_type', 'like', '%'.$data['page_type'].'%']);
+            array_push($where,['sector.page_type', 'like', '%'.$data['page_type'].'%']);
         }
         $sector = Sector::where($where)
-        // ->leftJoin('size','sector.size_id','=','size.id')
-        ->select('sector.*')
+        ->leftJoin('sector_component','sector.sector_id','=','sector_component.sector_id')
+        ->leftJoin('component','sector_component.component_id','component.component_type')
+        ->select('sector.sector_name','sector_component.sector_id','component.*')
+        // ->select('sector.*')
         ->get()->all();
+        foreach($sector as $key => $value){
+            $setor_id = $value['sector_id'];
+            $page[$key][$setor_id]['sectorName'] = $value['sector_name'];
+            // 1:资讯;2:广告;3:静态;
+            // $component_code = json_decode($value['component_code']) ?? [];
+
+            // $page[$key][$setor_id]['componentList'] = 
+            // '组件分类:1:资讯-头条组件;2:资讯-轮播组件;3:资讯-推荐图类组件;4:资讯-最新类组件;5:资讯-推荐类;6:资讯-热点类组件;7:资讯-栏目类组件;
+            // 8:列表类组件;9:详情类组件;10:二级导航栏类组件;11:广告类;12:静态资源类;13:底部导航类;14:广告资讯混合类'
+            if(in_array($value['type_id'],[1,2,3,4,5,6,7,8,9,13,14])){
+                $type = 1;
+            }else if(in_array($value['type_id'],[10,12])){
+                $type = 3;
+            }else if($value['type_id']== 11){
+                $type = 2;
+                $page[$key][$setor_id]['componentList']['componentData']=[];
+                $ad = json_decode($value['ad']) ?? [];
+                // 在 $page[$key][$setor_id] 中增加一个键值为 ad 的数组
+                // $page[$key][$setor_id]['ad'] = is_object($ad) ? (array)$ad->ad ?? [] : $ad['ad'] ?? [];
+                $page[$key][$setor_id]['ad'] = $ad ?? [];
+            }else{
+                $type = 0;
+            }
+            $page[$key][$setor_id]['componentList']['component_style'] =  1;
+            $page[$key][$setor_id]['componentList']['sort'] =  $value['sort_id'];
+            $page[$key][$setor_id]['componentList']['component_type'] = $type;
+        }
+        // $sector_page = $this->getSectorPage($sector);
         if(empty($sector)){
             return Result::error('通栏不存在!');
         }
-        return Result::success($sector);
+        return Result::success($page);
     }
     /**
      * 自助建站-组件管理-获取组件预览图列表