Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
semour
/
semour_web
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ee659885
authored
Nov 21, 2022
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
分类页面模板数据
parent
014d32aa
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
102 additions
and
25 deletions
app/Http/Controllers/Api/BrandApiController.php
app/Http/Controllers/BrandController.php
app/Http/Controllers/ClassificationController.php
app/Http/Services/BrandService.php
app/Http/Services/ClassService.php
resources/views/classification/index.blade.php
app/Http/Controllers/Api/BrandApiController.php
0 → 100644
View file @
ee659885
<?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
);
}
}
app/Http/Controllers/BrandController.php
View file @
ee659885
...
...
@@ -25,8 +25,8 @@ class BrandController extends Controller
public
function
map
()
{
$brandList
=
BrandService
::
getStandardBrandList
();
$brandList
=
BrandService
::
getStandardBrandList
WithLetter
();
return
view
(
'brand.map'
,
compact
(
'brandList'
));
}
...
...
app/Http/Controllers/ClassificationController.php
View file @
ee659885
...
...
@@ -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'
));
}
}
app/Http/Services/BrandService.php
View file @
ee659885
...
...
@@ -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
getStandardBrandList
WithLetter
()
{
$redisKey
=
'semour_standard_brand_map'
;
$standardBrandList
=
Redis
::
get
(
$redisKey
);
...
...
app/Http/Services/ClassService.php
View file @
ee659885
...
...
@@ -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
;
}
}
resources/views/classification/index.blade.php
View file @
ee659885
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment