stanley-king 8 年 前
コミット
d8637f28e1
2 ファイル変更68 行追加30 行削除
  1. 45 24
      helper/special_helper.php
  2. 23 6
      mobile/control/search.php

+ 45 - 24
helper/special_helper.php

@@ -44,11 +44,18 @@ class brands_special
         foreach ($blocks as $block)
         {
             $items = $block['items'];
+            if(empty($items) || is_array($items) == false) continue;
+
+            foreach ($items as $item)
+            {
+                $brand_id = intval($item['data']);
+                $data = $item;
+                $data['scale'] = $block['scale'];
+
+                self::$stBImgContianers[$brand_id] = $data;
+            }
             if(!empty($items) && is_array($items)) {
-                $brand_id = intval($items[0]['data']);
-                $item = $items[0];
-                $item['scale'] = $block['scale'];
-                self::$stBImgContianers[$brand_id] = $item;
+
             }
         }
     }
@@ -78,33 +85,46 @@ class special_helper
         $this->special_id = $special_id;
         $this->read_cache();
     }
+
+    public static function format_brand_sale($brand_id,$can_click)
+    {
+        if($brand_id <= 0) return array();
+
+        $helper = new brands_special();
+        $info = $helper->info($brand_id);
+        if($info == false) return array();
+
+        $result['item_title'] = '';
+        $result['item_type'] = 'home1';
+        $result['scale'] = $info['scale'];
+
+        $item['image'] = $info['image'];
+        $item['type']  = $info['type'];
+        if($can_click == true) {
+            $item['data']  = $info['data'];
+        } else {
+            $item['data']  = 0;
+        }
+
+        $item['title'] = $info['title'];
+        $result['items'][] = $item;
+
+        return $result;
+    }
+
+
     public static function format_brand($brands)
     {
         if(empty($brands)) return array();
 
-        $result = [];
         if(count($brands) == 1)
         {
             $brand_id = intval($brands[0]['data']);
-            if($brand_id <= 0) return array();
-
-            $helper = new brands_special();
-            $info = $helper->info($brand_id);
-            if($info == false) return array();
-
-            $result['item_title'] = '';
-            $result['item_type'] = 'home1';
-            $result['scale'] = $info['scale'];
-
-            $item['image'] = $info['image'];
-            $item['type']  = $info['type'];
-            $item['data']  = $info['data'];
-            $item['title'] = $info['title'];
-
-            $result['items'][] = $item;
+            return self::format_brand_sale($brand_id,true);
         }
         else
         {
+            $result = [];
             $result['item_title'] = '';
             $result['item_type'] = 'homewords';
 
@@ -116,15 +136,16 @@ class special_helper
 
                 $result['items'][] = $item;
             }
-        }
 
-        return $result;
+            return $result;
+        }
     }
 
     public static function format_category($cats,$title = '')
     {
-        $result = [];
+        if(empty($cats)) return array();
 
+        $result = [];
         $result['item_title'] = $title;
         $result['item_type'] = 'homewords';
 

+ 23 - 6
mobile/control/search.php

@@ -50,6 +50,10 @@ class search_param
             return $result;
         }
     }
+
+    public function brand_id() {
+        return $this->mBrandId;
+    }
 }
 
 class searchControl extends mobileHomeControl
@@ -102,12 +106,25 @@ class searchControl extends mobileHomeControl
         else
         {
             $blocks = [];
-            if($this->page_no() == 1) {
-                $brand_blocks = special_helper::format_brand($result['brands']);
-                $cat_blocks = special_helper::format_category($result['hots']);
-                $block = array_merge($brand_blocks,$cat_blocks);
-
-                $blocks[] = $block;
+            if($this->page_no() == 1)
+            {
+                if($param->brand_id() != 0)
+                {
+                    $block = special_helper::format_brand_sale($param->brand_id(),false);
+                    if(!empty($block)) {
+                        $blocks[] = $block;
+                    }
+                } else {
+                    $block = special_helper::format_brand($result['brands']);
+                    if(!empty($block)) {
+                        $blocks[] = $block;
+                    }
+                }
+                
+                $block = special_helper::format_category($result['hots']);
+                if(!empty($block)) {
+                    $blocks[] = $block;
+                }
             }
 
             foreach ($goods_list as $goods) {