postData(); $city_supplier_ids = empty($postData["city_supplier_ids"]) ? '' : $postData["city_supplier_ids"]; $shop_supplier_id = empty($postData["shop_supplier_id"]) ? 0 : $postData["shop_supplier_id"]; // 分类模板 $template = PageCategoryModel::detail(); // 商品分类列表 $list = array_values(CategoryModel::getCacheTreeShop($shop_supplier_id)); $list =$this->hideCate($list); $category_id=0; if(count($list)>0){ $category_id=$list[0]['category_id']; } $data=['page'=>1,'category_id'=>$category_id,'city_supplier_ids'=>$city_supplier_ids,'search'=>'','sortType'=>'','sortPrice'=>'','list_rows'=>10]; $param = array_merge($data, [ 'product_status' => 10, 'audit_status' => 10 ]); $param['shop_supplier_id'] = empty($postData["shop_supplier_id"]) ? 0 : $postData["shop_supplier_id"]; // 获取列表数据 $model = new ProductModel; $productList = $model->getList($param, $this->getUser(false)); $store = SettingModel::getItem('store'); return $this->renderSuccess('', compact('template','list','productList','store')); } public function hideCate($all){ if(empty($all)){ return $all; } foreach ($all as $i=>$first) { if (intval($all[$i]["status"]) === 0){ unset($all[$i]); } if(!empty($all[$i]['child'])){ foreach ($all[$i]['child'] as $j=>$two) { if (intval($all[$i]['child'][$j]["status"]) === 0){ unset($all[$i]['child'][$j]); } if(!empty($all[$i]['child'][$j]['child'])){ foreach ($all[$i]['child'][$j]['child'] as $k=>$three){ if (intval($all[$i]['child'][$j]["child"][$k]["status"]) === 0){ unset($all[$i]['child'][$j]["child"][$k]); } } } } } } return array_values($all); } }