stanley-king 8 vuotta sitten
vanhempi
commit
ce09d5ccfa
2 muutettua tiedostoa jossa 65 lisäystä ja 22 poistoa
  1. 37 20
      helper/special_helper.php
  2. 28 2
      mobile/control/index.php

+ 37 - 20
helper/special_helper.php

@@ -20,6 +20,23 @@ class special_helper
         $this->read_cache();
     }
 
+    public static function format_goods($goods_ids,$title)
+    {
+        $result = [];
+
+        $result['item_title'] = empty($title) ? '' : $title;
+        $result['item_type'] = 'home_goods';
+        foreach ($goods_ids as $goods_id) {
+            $item['image'] = "";
+            $item['type'] = "goods";
+            $item['data'] = $goods_id;
+
+            $result['items'][] = $item;
+        }
+
+        return $result;
+    }
+
     public function format(&$goods_ids)
     {
         $goods_ids = $this->goods_ids;
@@ -31,27 +48,27 @@ class special_helper
         $mod_special = Model('mb_special');
         $specials = $mod_special->getMbSpecialItemUsableListByID($this->special_id);
 
-        unset($specials['mobile_filter_data'],$specials['mobile_goods_ids']);
+//        unset($specials['mobile_filter_data'],$specials['mobile_goods_ids']);
+//
+//        $this->filter_data = $this->filter($specials,$goods_ids);
+//        $this->goods_ids = $goods_ids;
+//
+//        $specials['mobile_filter_data'] = $this->filter_data;
+//        $specials['mobile_goods_ids'] = $goods_ids;
 
-        $this->filter_data = $this->filter($specials,$goods_ids);
-        $this->goods_ids = $goods_ids;
+        if(array_key_exists("mobile_filter_data",$specials)) {
+            $this->filter_data = $specials['mobile_filter_data'];
+            $this->goods_ids   = $specials['mobile_goods_ids'];
+        } else {
+            $this->filter_data = $this->filter($specials,$goods_ids);
+            $this->goods_ids = $goods_ids;
 
-        $specials['mobile_filter_data'] = $this->filter_data;
-        $specials['mobile_goods_ids'] = $goods_ids;
+            $specials['mobile_filter_data'] = $this->filter_data;
+            $specials['mobile_goods_ids'] = $goods_ids;
 
-//        if(array_key_exists("mobile_filter_data",$specials)) {
-//            $this->filter_data = $specials['mobile_filter_data'];
-//            $this->goods_ids   = $specials['mobile_goods_ids'];
-//        } else {
-//            $this->filter_data = $this->filter($specials,$goods_ids);
-//            $this->goods_ids = $goods_ids;
-//
-//            $specials['mobile_filter_data'] = $this->filter_data;
-//            $specials['mobile_goods_ids'] = $goods_ids;
-//
-//            $cache = array('special' => serialize($specials));
-//            wcache($this->special_id, $cache, 'mb_special');
-//        }
+            $cache = array('special' => serialize($specials));
+            wcache($this->special_id, $cache, 'mb_special');
+        }
     }
 
     private function filter($specials,&$goods_ids)
@@ -132,8 +149,8 @@ class special_helper
         $items = [];
 
         $item['image'] = $val['image'];
-        $item['type'] = $val['type'];
-        $item['data'] = $val['data'];
+        $item['type']  = $val['type'];
+        $item['data']  = $val['data'];
 
         $scale = $this->scale($item['image']);
         $items[] = $item;

+ 28 - 2
mobile/control/index.php

@@ -23,11 +23,37 @@ class indexControl extends specialControl
     {
         parent::__construct();
     }
+
     public function homeOp()
     {
-        $ret = $this->get_special(self::HomeSpecialID);
-        return self::outsuccess($ret,"shop/home");
+        if($this->cur_page == 1) {
+            $ret = $this->get_special(self::HomeSpecialID);
+            $ret['mobile_page'] = mobile_page(2);
+
+            return self::outsuccess($ret,"shop/home");
+        }
+        else
+        {
+            $goods_ids = activity_helper::recomoned_goodsids();
+
+            $ret = array_chunk($goods_ids,$this->page_size());
+            $pages = count($ret);
+            $page_no = $pages >= $this->page_no() ? $this->page_no() : $pages;
+            $goods_ids = $ret[$page_no - 1];
+
+            $helper = new goods_helper();
+            $ret = $helper->get_summary($goods_ids,$other_goods);
+            $blocks = special_helper::format_goods($goods_ids,"热门推荐");
+
+            self::outsuccess(array('special_list' => $blocks,
+                'summary' => $ret['summary'],
+                'groupbuy' => $ret['groupbuy'],
+                'limitime' => $ret['limitime'],
+                'bundling' => $ret['bundling'],
+                'mobile_page' => mobile_page($pages + 1)));
+        }
     }
+
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     public function indexOp()
     {