Commit ee659885 by 杨树贤

分类页面模板数据

parent 014d32aa
<?php
namespace App\Http\Controllers\Api;
use App\Http\Requests\InquirySave;
use App\Http\Services\BrandService;
use App\Http\Services\CountryService;
use App\Http\Services\InquiryService;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
class BrandApiController extends Controller
{
public function list(Request $request)
{
$data = BrandService::getStandardBrandList($request->all());
return $this->setSuccessData($data);
}
}
......@@ -25,8 +25,8 @@ class BrandController extends Controller
public function map()
{
$brandList = BrandService::getStandardBrandList();
$brandList = BrandService::getStandardBrandListWithLetter();
return view('brand.map',compact('brandList'));
}
......
......@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Http\Services\ClassService;
use Illuminate\Http\Request;
class ClassificationController extends Controller
......@@ -21,8 +22,20 @@ class ClassificationController extends Controller
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index()
public function index(Request $request)
{
return view('classification.index');
//获取分类信息
$secondClass = ClassService::getClassificationById($request->class_id, true);
$thirdClass = [];
if ($secondClass['parent_id']) {
$thirdClass = $secondClass;
$secondClass = ClassService::getClassificationById($secondClass['parent_id']);
}
$crumbs = [
'second_class' => $secondClass,
'third_class' => $thirdClass,
];
$classification = $thirdClass ?: $secondClass;
return view('classification.index', compact('classification', 'crumbs'));
}
}
......@@ -7,8 +7,21 @@ use Illuminate\Support\Facades\Redis;
class BrandService
{
public static function getStandardBrandList($map)
{
$standardBrandCache = Redis::hgetall('standard_brand');
$standardBrandCache = array_map(function ($value) {
return json_decode($value, true);
}, $standardBrandCache);
ksort($standardBrandCache);
if (!empty($map['brand_name'])) {
}
return $standardBrandCache;
}
//获取品牌页的数据(标准品牌)
public static function getStandardBrandList()
public static function getStandardBrandListWithLetter()
{
$redisKey = 'semour_standard_brand_map';
$standardBrandList = Redis::get($redisKey);
......
......@@ -58,4 +58,29 @@ class ClassService
return array_values($topFields);
}
public static function getClassificationById($classId,$includeChildren = false)
{
$classification = Redis::hget('pool_class_info', $classId);
$classification = json_decode($classification,true);
if ($classification['parent_id']) {
return $classification;
}
//获取子分类
$classificationCache = Redis::hgetall('pool_class_info');
$totalSkuNumber = 0;
foreach ($classificationCache as $classCache) {
$classCache = json_decode($classCache, true);
if ($classCache['parent_id'] == $classId) {
if (empty($classCache['class_name_en'])) {
continue;
}
$classCache['sku_number'] = Redis::hget('pool_class_info_count', $classCache['class_id']) ?: 0;
$totalSkuNumber += $classCache['sku_number'];
$classification['children'][] = $classCache;
}
}
$classification['sku_number'] = $totalSkuNumber;
return $classification;
}
}
......@@ -8,22 +8,27 @@
@include('common.mallHeaderTop')
@include('common.mallHeaderNav')
<div class="classbox w1200">
<div class="bread-menu row boxsiz">
<a href="">Home</a>
<i>></i>
<a href="">Discrete Semiconductor Products</a>
<i>></i>
<span>Diodes - Zener - Single</span>
</div>
<div class="class-three-box boxsiz">
<div class="chead boxsiz">二级分类NAME(100000)</div>
<div class="csec boxsiz clear">
<a href="">三积分类NAME(100000)</a>
<a href="">Diodes - Zener - Single(100000)</a>
</div>
</div>
<div class="bread-menu row boxsiz">
<a href="">Home</a>
@if(!empty($crumbs['second_class']))
<i>></i>
<a href="/class/{{$crumbs['second_class']['class_id']}}">{{$crumbs['second_class']['class_name_en']}}</a>
@endif
@if(!empty($crumbs['third_class']))
<i>></i>
<span>{{$crumbs['third_class']['class_name_en']}}</span>
@endif
</div>
<div class="class-three-box boxsiz">
<div class="chead boxsiz">{{$classification['class_name_en']}}</div>
@if(!empty($classification['children']))
<div class="csec boxsiz clear">
@foreach($classification['children'] as $class)
<a href="/class/{{$class['class_id']}}">{{$class['class_name_en']}}</a>
@endforeach
</div>
@endif
</div>
<div class="shit-box boxsiz">
<p class="titletext">Manufacturer</p>
......@@ -95,7 +100,7 @@
<div class="jtpr">50+</div>
<div class="jtpc">$2222.2222</div>
</div>
</div>
</div>
<div class="td">
......@@ -108,7 +113,7 @@
</div>
</div>
</div>
</div>
</div>
</div>
......@@ -119,4 +124,4 @@
@section('js')
<script src="{{$public}}/assets/js/class/class.js?v={{time()}}"></script>
@endsection
\ No newline at end of file
@endsection
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment