Browse Source

add file type.php attribute.php

root 9 years ago
parent
commit
7bc17a8421
2 changed files with 109 additions and 0 deletions
  1. 48 0
      mobile/control/attribute.php
  2. 61 0
      mobile/control/type.php

+ 48 - 0
mobile/control/attribute.php

@@ -0,0 +1,48 @@
+<?php
+/**
+ * 前台品牌分类
+ *
+ *
+ *
+ ***/
+
+
+defined('InShopNC') or exit('Access Invalid!');
+
+class attributeControl extends mobileHomeControl
+{
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    public function effectOp()
+    {
+        $goods_attr_index_list = Model()->table('goods_attr_index')->field('attr_id')->distinct('attr_id')->where('1=1')->select();
+
+        $attr_filter_list = array();
+        foreach ($goods_attr_index_list as $value) {
+            array_push($attr_filter_list, $value['attr_id']);
+        }
+
+        $attr_list = Model()->table('attribute')->where(array('attr_name' => '功效', 'attr_show' => '1', 'attr_id' => array('in', $attr_filter_list)))->select();
+
+        $result = array();
+        foreach ($attr_list as $value) {
+
+            $type = Model()->table('type')->find($value['type_id']);
+            if (!empty($type)) {
+
+                $fields = "attr_value_id,attr_value_name,attr_id,type_id";
+                $attr_value_list = Model()->table('attribute_value')->field($fields)->where(array('attr_id' => $value['attr_id']))->select();
+
+                $attr['type_name'] = $type['type_name'];
+                $attr['data'] = $attr_value_list;
+                array_push($result, $attr);
+            }
+        }
+
+        $attribute_list = array("attribute" => $result);
+        joutput_data($attribute_list);
+    }
+}

+ 61 - 0
mobile/control/type.php

@@ -0,0 +1,61 @@
+<?php
+/**
+ * 前台品牌分类
+ *
+ *
+ *
+ ***/
+
+
+defined('InShopNC') or exit('Access Invalid!');
+
+class typeControl extends mobileHomeControl
+{
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    public function searchOp()
+    {
+        if (!empty($_GET['keyword'])) {
+
+            $keyword = urldecode($_GET['keyword']);
+
+            $gc_1 = Model()->table('goods_class')->where(array('gc_name' => array('like', '%' . $keyword . '%')))->limit(1)->select();
+
+            $goods_class = array();
+            if (!empty($gc_1)) {
+
+                $gc_2 = Model()->table('goods_class')->where(array('gc_parent_id' => $gc_1[0]['gc_id']))->select();
+                foreach ($gc_2 as $value) {
+
+                    $gc_item_2['gc_id'] = $value['gc_id'];
+                    $gc_item_2['gc_name'] = $value['gc_name'];
+
+                    $gc_3 = Model()->table('goods_class')->where(array('gc_parent_id' => $value['gc_id']))->select();
+                    if (!empty($gc_3)) {
+
+                        $gc_3_array = array();
+                        foreach ($gc_3 as $item) {
+
+                            $gc_3_item['gc_id'] = $item['gc_id'];
+                            $gc_3_item['gc_name'] = $item['gc_name'];
+                            $gc_3_item['type_id'] = $item['type_id'];
+
+                            array_push($gc_3_array, $gc_3_item);
+                        }
+
+                        $gc_item_2['data'] = $gc_3_array;
+                        array_push($goods_class, $gc_item_2);
+                    }
+                }
+            }
+            joutput_data($goods_class);
+
+        } else {
+            joutput_error(1001, "keyword is must!");
+        }
+    }
+
+}