dever 3 年之前
父節點
當前提交
9decb58f0c
共有 1 個文件被更改,包括 29 次插入2 次删除
  1. 29 2
      src/Api.php

+ 29 - 2
src/Api.php

@@ -26,6 +26,33 @@ class Api
 		return $cate;
 	}
 
+	/**
+	 * 根据json格式获取信息
+	 *
+	 * @return mixed
+	 */
+	public function getInfoByJson($data)
+	{
+		$result = array();
+
+		foreach ($data as $k => $v) {
+
+			$info = Dever::db('attr/info')->find($v['attr_id']);
+			$result[$k]['id'] = $info['id'];
+			$result[$k]['name'] = $info['name'];
+
+			if ($v['id']) {
+				$attr = Dever::db('attr/value')->find($v['id']);
+				if ($attr) {
+					$result[$k]['value_id'] = $attr['id'];
+					$result[$k]['value_name'] = $attr['name'];
+				}
+			}
+		}
+
+		return $result;
+	}
+
 	/**
 	 * 获取属性详细信息,有类别
 	 *
@@ -467,7 +494,7 @@ class Api
                 } elseif ($v['type'] == 1) {
 
                 	$search = Dever::db('attr/search')->getData(array('info_id' => $v['id']));
-                	print_r($where[$key]);die;
+                	//print_r($where[$key]);die;
                 	/*
                     $temp = explode("\n", $v['type_option']);
                     if (isset($temp[$where[$key]-1])) {
@@ -485,7 +512,7 @@ class Api
                 } elseif ($v['type'] == 9 && $v['type_option']) {
 
                 	$search = Dever::db('attr/search')->getData(array('info_id' => $v['id']));
-                	print_r($where[$key]);die;
+                	//print_r($where[$key]);die;
 
                 	/*
                     $temp = explode("\n", $v['type_option']);