stanley-king před 7 roky
rodič
revize
fbf4a74e4e

+ 3 - 1
data/model/mb_special.model.php

@@ -232,7 +232,7 @@ class mb_specialModel extends Model
             } else {
                 $items = $this->_formatMbSpecialData($item_data, $value['item_type']);
             }
-            if($item_type == 'home1' || $item_type == 'home2' || $item_type == 'home4') {
+            if($item_type == 'home1' || $item_type == 'home2' || $item_type == 'home4' || $item_type == 'home_ugc') {
                 $block['items'] = $items;
             }
             else {
@@ -326,6 +326,8 @@ class mb_specialModel extends Model
             case 'home2':
             case 'home4':
                 break;
+            case 'home_ugc':
+                break;
             default:
                 $new_item = array();
                 foreach ((array)$item_data['item'] as $key => $value)

+ 33 - 0
helper/special_helper.php

@@ -435,6 +435,13 @@ class special_formater
         elseif($key == 'home4') {
             $items = $this->filter_home4($org_items,$goods_ids,$scale);
         }
+        elseif($key == 'home_ugc')
+        {
+            $items = $this->filter_home_ugc($org_items,$goods_ids);
+            $block['items'] = $items;
+            $scale = 1;
+            return $block;
+        }
         else {
             return false;
         }
@@ -559,6 +566,32 @@ class special_formater
         }
     }
 
+    private function filter_home_ugc($val,&$goods_ids)
+    {
+        $items = [];
+
+        $item['image'] = $val['image'];
+        $item['type']  = $val['type'];
+        $item['data']  = $val['data'];
+        $item['show_type']  = $val['show_type'];
+        $item['show_data']  = $val['show_data'];
+        $item['reserved']   = $this->safe_string($val['reserved']);
+        $item['title']  = $this->safe_string($val['title']);
+
+        $ids = [];
+        if($item['type'] == 'goods') {
+            $ids[] = intval($item['data']);
+        }
+
+        if(self::check_goods($ids)) {
+            $goods_ids = array_merge($goods_ids,$ids);
+            $items[] = $item;
+            return $items;
+        } else {
+            return false;
+        }
+    }
+
     private function filter_home2($val,&$goods_ids,&$scale)
     {
         $items = [];

+ 3 - 3
helper/ugc/ugc_content.php

@@ -24,7 +24,7 @@ abstract class UGContent
     }
     public function base_info()
     {
-        $param['item_type'] = 'home1';
+        $param['item_type'] = 'home_ugc';
         $param['bg_type'] = content_config::def_item_bg_type;
         $param['bg_data'] = content_config::def_item_bg_color;
         $param['has_margin'] = 0;
@@ -38,7 +38,7 @@ abstract class UGContent
 
     protected function item_data($show_type, $show_data, $title='', $type='', $data='', $reserved='')
     {
-        $result['home1_title'] = $title;
+        $result['home_title']  = $title;
         $result['image']       = $show_data;
         $result['show_type'] = $show_type;
         $result['show_data'] = $show_data;
@@ -228,7 +228,7 @@ class vote_item extends UGContent
             $item['text'] = $val;
             $result[] = $item;
         }
-        return json_encode($result);
+        return json_encode($result,JSON_UNESCAPED_UNICODE);
     }
     public function is_vote() {
         return true;

+ 2 - 2
mobile/control/control.php

@@ -277,9 +277,9 @@ class mbMemberControl extends mobileControl
 
 function bonus_version()
 {
-    return "v=2017071101";
+    return "v=20170723";
 }
 function shop_version()
 {
-    return "v=2017071101";
+    return "v=20170723";
 }

+ 5 - 7
mobile/control/search.php

@@ -202,13 +202,13 @@ class searchControl extends mobileHomeControl
             $ret = $helper->summary($goods_list,$related_goods);
 
             $blocks = special_formater::format_ugc_goods($goods_ids,"",$ret['sort_summary']);
-            
-            return self::outsuccess(array('special_list' => $blocks,
+
+            return self::outsuccess(['special_list' => $blocks,
                 'summary'  => $ret['summary'],
                 'groupbuy' => $ret['groupbuy'],
                 'limitime' => $ret['limitime'],
                 'bundling' => $ret['bundling'],
-                'mobile_page' => mobile_page($page_count)));
+                'mobile_page' => mobile_page($page_count)]);
         }
     }
 
@@ -227,7 +227,7 @@ class searchControl extends mobileHomeControl
             } else {
                 $result = $this->separate_page($result,$pages);
             }
-            return self::outsuccess(array('words' => $result,'mobile_page' => mobile_page($pages)));
+            return self::outsuccess(['words' => $result,'mobile_page' => mobile_page($pages)]);
         }
     }
 
@@ -256,8 +256,7 @@ class searchControl extends mobileHomeControl
         $guslike = $this->guesslike();
         if($guslike == false)
         {
-            return self::outsuccess(array('special_list' => $blocks,
-                'mobile_page' => mobile_page(1)));
+            return self::outsuccess(['special_list' => $blocks,'mobile_page' => mobile_page(1)]);
         }
         else
         {
@@ -361,7 +360,6 @@ class searchControl extends mobileHomeControl
                 'bundling' => $ret['bundling']);
         }
     }
-
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
     /**

+ 39 - 4
mobile/control/special.php

@@ -12,10 +12,8 @@ require_once(BASE_ROOT_PATH . '/helper/goods_helper.php');
 require_once(BASE_ROOT_PATH . '/helper/special_helper.php');
 require_once(BASE_ROOT_PATH . '/helper/activity_helper.php');
 
-
 class specialControl extends mobileHomeControl
 {
-
     public function __construct() {
         parent::__construct();
     }
@@ -119,7 +117,7 @@ class tpl_ugc
         {
             $item_type = $block['item_type'];
             $items = $block['items'];
-            if($item_type == 'home1' && !empty($items)) {
+            if($item_type == 'home_ugc' && !empty($items)) {
                 $this->show_items($items);
             }
         }
@@ -144,9 +142,46 @@ class tpl_ugc
             }
         }
     }
+
     private function show_vote($item)
     {
-        $y = $item;
+        if(empty($item['data'])) return false;
+        $options = json_decode($item['data'],true);
+        if(empty($options)) return false;
+        $title = $item['title'];
+
+        $reserved = $item['reserved'];
+        $kv = preg_split('/=/',$reserved);
+        if(!empty($kv))
+        {
+            $k = trim($kv[0]);
+            $v = trim($kv[1]);
+            if(!empty($k) && $k == 'vote_type') {
+                $vote_type = $v;
+            }
+        }
+        $svote_type = intval($vote_type) == 0 ? '单选' :  '多选';
+
+        $str = "<div class=\"vote\">
+                    <div class=\"vote_pro\">
+                        <div class=\"vote_question\">{$title}</div>
+                        <div class=\"vote_type\">/{$svote_type}</div>
+                    </div>
+                    <div class=\"vote_options\">";
+        foreach ($options as $val)
+        {
+            $key = $val['id'];
+            $option = $val['text'];
+            $soption = "<div class=\"vote_option\">
+                            <label>
+                                <input type=\"checkbox\" value=\"{$key}\" class=\"check\" name=\"submit_vote\">
+                                <span class=\"label\">{$option}</span>
+                            </label>
+                        </div>";
+            $str .= $soption;
+        }
+        $str .= '</div></div><button class="button_vote" id="submit_btn">投票</button>';
+        echo $str;
     }
 
     private function show_text($item)

+ 19 - 3
test/pay_helperTest.php

@@ -12,13 +12,29 @@ class pay_helperTest extends PHPUnit_Framework_TestCase
 {
     public function testAdd()
     {
+
+        $y = unserialize('a:8:{s:11:"home1_title";s:9:"那句好";s:5:"image";s:0:"";s:9:"show_type";s:4:"vote";s:9:"show_data";s:0:"";s:4:"type";s:4:"vote";s:4:"data";s:75:"[{"id":0,"text":"u7b2cu4e00u53e5"},{"id":1,"text":"u7b2cu4e8cu53e5"}]";s:5:"title";s:9:"那句好";s:8:"reserved";s:11:"vote_type=0";}');
         $mobiles = array();
-//        array_push($mobiles,array('139111269867' => '江海苗C'));
-//        array_push($mobiles,array('139111269868' => '江海苗A'));
-//        array_push($mobiles,array('139111269869' => '江海苗B'));
         $mobiles['139111269867'] = '江海苗C';
         $mobiles['139111269868'] = '江海苗C';
         $mobiles['139111269869'] = '江海苗C';
     }
 
+    public function testSerialize()
+    {
+        $data = array (
+            'home1_title' => '今年春节放几天假',
+            'image' => '',
+            'show_type' => 'vote',
+            'show_data' => '',
+            'type' => 'vote',
+            'data' => '[{"id":0,"text":"\\u4e00\\u5929"},{"id":1,"text":"\\u4e24\\u5929"},{"id":2,"text":"\\u4e09\\u5929"}]',
+            'title' => '今年春节放几天假',
+            'reserved' => 'vote_type=0',
+        );
+        $x = serialize($data);
+        $y = unserialize($x);
+
+    }
+
 }