|
|
@@ -20,7 +20,7 @@ class StoreBrandServices extends BaseServices |
|
|
|
$this->dao = $dao; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取品牌列表 |
|
|
|
* @param $where |
|
|
|
* @return array |
|
|
@@ -74,26 +74,26 @@ class StoreBrandServices extends BaseServices |
|
|
|
public function getList($where) |
|
|
|
{ |
|
|
|
$list = $this->dao->getList($where, ['product', 'children']); |
|
|
|
$count = $this->dao->count($where); |
|
|
|
$count = $this->dao->count($where); |
|
|
|
if ($list) { |
|
|
|
foreach ($list as &$item) { |
|
|
|
$item['brand_num'] = $item['product'][0]['brand_num'] ?? 0; |
|
|
|
$item['fid'] = $item['fid'] ? array_map('intval', explode(',', $item['fid'])) : []; |
|
|
|
$item['type'] = count($item['fid']) < 2 ? 1 : 0; |
|
|
|
//添加子品牌fid |
|
|
|
if ($item['type'] == 1) { |
|
|
|
$item['fid_son'] = $item['fid']; |
|
|
|
array_push($item['fid_son'], $item['id']); |
|
|
|
} |
|
|
|
if (isset($item['children']) && $item['children']) { |
|
|
|
$item['children'] = []; |
|
|
|
$item['loading'] = false; |
|
|
|
$item['_loading'] = false; |
|
|
|
} else { |
|
|
|
unset($item['children']); |
|
|
|
} |
|
|
|
unset($item['product']); |
|
|
|
} |
|
|
|
foreach ($list as &$item) { |
|
|
|
$item['brand_num'] = $item['product'][0]['brand_num'] ?? 0; |
|
|
|
$item['fid'] = $item['fid'] ? array_map('intval', explode(',', $item['fid'])) : []; |
|
|
|
$item['type'] = count($item['fid']) < 2 ? 1 : 0; |
|
|
|
//添加子品牌fid |
|
|
|
if ($item['type'] == 1) { |
|
|
|
$item['fid_son'] = $item['fid']; |
|
|
|
array_push($item['fid_son'], $item['id']); |
|
|
|
} |
|
|
|
if (isset($item['children']) && $item['children']) { |
|
|
|
$item['children'] = []; |
|
|
|
$item['loading'] = false; |
|
|
|
$item['_loading'] = false; |
|
|
|
} else { |
|
|
|
unset($item['children']); |
|
|
|
} |
|
|
|
unset($item['product']); |
|
|
|
} |
|
|
|
} |
|
|
|
return compact('list', 'count'); |
|
|
|
} |
|
|
@@ -117,7 +117,7 @@ class StoreBrandServices extends BaseServices |
|
|
|
} |
|
|
|
$menus = []; |
|
|
|
$where['is_del'] = 0; |
|
|
|
$where['is_show'] = 1; |
|
|
|
$where['is_show'] = 1; |
|
|
|
$list = get_tree_children($this->dao->getList($where, [], ['id as value', 'brand_name as label', 'pid']), 'children', 'value'); |
|
|
|
if ($top) { |
|
|
|
$menus = [['value' => 0, 'label' => '顶级品牌']]; |
|
|
@@ -132,7 +132,15 @@ class StoreBrandServices extends BaseServices |
|
|
|
} |
|
|
|
} |
|
|
|
$menus = array_merge($menus, $list); |
|
|
|
return $menus; |
|
|
|
$data2 = []; |
|
|
|
foreach ($menus as $k => $v) { |
|
|
|
$cx = $v['value']; |
|
|
|
if (!isset($data2[$cx])) { |
|
|
|
$data2[$cx] = $v; |
|
|
|
} |
|
|
|
} |
|
|
|
$data2 = array_values($data2); |
|
|
|
return $data2; |
|
|
|
} |
|
|
|
|
|
|
|
/** |