Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
yii2_fecshop
提交
4be187c1
Y
yii2_fecshop
项目概览
OpenDocCN
/
yii2_fecshop
通知
18
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
yii2_fecshop
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4be187c1
编写于
8月 16, 2017
作者:
T
Terry
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
appserver 分类侧栏过滤部分的接口
上级
cd5e69e9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
60 addition
and
39 deletion
+60
-39
app/appserver/modules/Catalog/controllers/CategoryController.php
...server/modules/Catalog/controllers/CategoryController.php
+60
-39
未找到文件。
app/appserver/modules/Catalog/controllers/CategoryController.php
浏览文件 @
4be187c1
...
...
@@ -36,7 +36,7 @@ class CategoryController extends AppserverController
// url的参数,排序方向
protected
$_direction
=
'dir'
;
// url的参数,排序字段
protected
$_sort
=
'sort'
;
protected
$_sort
=
'sort
Column
'
;
// url的参数,页数
protected
$_page
=
'p'
;
// url的参数,价格
...
...
@@ -48,6 +48,8 @@ class CategoryController extends AppserverController
protected
$_filter_attr
;
protected
$_numPerPageVal
;
protected
$_page_count
;
protected
$category_name
;
protected
$sp
=
'---'
;
public
function
actionIndex
(){
...
...
@@ -70,21 +72,14 @@ class CategoryController extends AppserverController
$this
->
_productCount
=
$productCollInfo
[
'count'
];
$p
=
Yii
::
$app
->
request
->
get
(
'p'
);
$p
=
(
int
)
$p
;
if
(
$p
>
1
)
{
//$this->getAjaxProductHtml($products);
return
[
'code'
=>
200
,
'content'
=>
[
'products'
=>
$products
]
];
}
$query_item
=
$this
->
getQueryItem
();
$page_count
=
$this
->
getProductPageCount
();
$this
->
category_name
=
Yii
::
$service
->
store
->
getStoreAttrVal
(
$this
->
_category
[
'name'
],
'name'
);
//echo $this->_productCount;
return
[
'code'
=>
200
,
'content'
=>
[
'name'
=>
$this
->
category_name
,
'title'
=>
$this
->
_title
,
'image'
=>
$this
->
_category
[
'image'
]
?
Yii
::
$service
->
category
->
image
->
getUrl
(
$this
->
_category
[
'image'
])
:
''
,
'products'
=>
$products
,
...
...
@@ -92,7 +87,7 @@ class CategoryController extends AppserverController
'refine_by_info'
=>
$this
->
getRefineByInfo
(),
'filter_info'
=>
$this
->
getFilterInfo
(),
'filter_price'
=>
$this
->
getFilterPrice
(),
'filter_category'
=>
$this
->
getFilterCategory
Html
(),
'filter_category'
=>
$this
->
getFilterCategory
(),
'page_count'
=>
$page_count
,
],
//'content' => Yii::$service->store->getStoreAttrVal($this->_category['content'],'content'),
...
...
@@ -148,12 +143,31 @@ class CategoryController extends AppserverController
*/
protected
function
getFilterCategory
()
{
$arr
=
[];
$category_id
=
$this
->
_primaryVal
;
$parent_id
=
$this
->
_category
[
'parent_id'
];
$filter_category
=
Yii
::
$service
->
category
->
getFilterCategory
(
$category_id
,
$parent_id
);
return
$this
->
getAppServerFilterCategory
(
$filter_category
);
}
protected
function
getAppServerFilterCategory
(
$filter_category
){
if
((
is_array
(
$filter_category
)
||
is_object
(
$filter_category
))
&&
!
empty
(
$filter_category
)){
foreach
(
$filter_category
as
$category_id
=>
$v
){
$filter_category
[
$category_id
][
'name'
]
=
Yii
::
$service
->
store
->
getStoreAttrVal
(
$v
[
'name'
],
'name'
);
if
(
$filter_category
[
$category_id
][
'name'
]
==
$this
->
category_name
){
$filter_category
[
$category_id
][
'current'
]
=
true
;
}
else
{
$filter_category
[
$category_id
][
'current'
]
=
false
;
}
$filter_category
[
$category_id
][
'url'
]
=
'catalog/category/'
.
$category_id
;
if
(
isset
(
$v
[
'child'
])){
$filter_category
[
$category_id
][
'child'
]
=
$this
->
getAppServerFilterCategory
(
$v
[
'child'
]);
}
}
}
return
$filter_category
;
}
/**
* @property $filter_category | Array
* 通过递归的方式,得到分类以及子分类的html。
...
...
@@ -204,20 +218,9 @@ class CategoryController extends AppserverController
$category_query
=
Yii
::
$app
->
controller
->
module
->
params
[
'category_query'
];
$numPerPage
=
$category_query
[
'numPerPage'
];
$sort
=
$category_query
[
'sort'
];
$current_sort
=
Yii
::
$app
->
request
->
get
(
$this
->
_sort
);
$frontNumPerPage
=
[];
if
(
is_array
(
$numPerPage
)
&&
!
empty
(
$numPerPage
))
{
$attrUrlStr
=
$this
->
_numPerPage
;
foreach
(
$numPerPage
as
$np
)
{
$urlInfo
=
Yii
::
$service
->
url
->
category
->
getFilterChooseAttrUrl
(
$attrUrlStr
,
$np
,
$this
->
_page
);
//var_dump($url);
//exit;
$frontNumPerPage
[]
=
[
'value'
=>
$np
,
'url'
=>
$urlInfo
[
'url'
],
'selected'
=>
$urlInfo
[
'selected'
],
];
}
}
$frontSort
=
[];
if
(
is_array
(
$sort
)
&&
!
empty
(
$sort
))
{
$attrUrlStr
=
$this
->
_sort
;
...
...
@@ -225,21 +228,16 @@ class CategoryController extends AppserverController
foreach
(
$sort
as
$np
=>
$info
)
{
$label
=
$info
[
'label'
];
$direction
=
$info
[
'direction'
];
$arr
[
'sort'
]
=
[
'key'
=>
$attrUrlStr
,
'val'
=>
$np
,
];
$arr
[
'dir'
]
=
[
'key'
=>
$dirUrlStr
,
'val'
=>
$direction
,
];
$urlInfo
=
Yii
::
$service
->
url
->
category
->
getFilterSortAttrUrl
(
$arr
,
$this
->
_page
);
if
(
$current_sort
==
$np
){
$selected
=
true
;
}
else
{
$selected
=
false
;
}
$frontSort
[]
=
[
'label'
=>
$label
,
'value'
=>
$np
,
'url'
=>
$urlInfo
[
'url'
],
'selected'
=>
$urlInfo
[
'selected'
],
'selected'
=>
$selected
,
];
}
}
...
...
@@ -334,12 +332,28 @@ class CategoryController extends AppserverController
*/
protected
function
getFilterPrice
()
{
$symbol
=
Yii
::
$service
->
page
->
currency
->
getCurrentSymbol
();
$currenctPriceFilter
=
Yii
::
$app
->
request
->
get
(
$this
->
_filterPrice
);
$filter
=
[];
$priceInfo
=
Yii
::
$app
->
controller
->
module
->
params
[
'category_query'
];
if
(
isset
(
$priceInfo
[
'price_range'
])
&&
!
empty
(
$priceInfo
[
'price_range'
])
&&
is_array
(
$priceInfo
[
'price_range'
]))
{
foreach
(
$priceInfo
[
'price_range'
]
as
$price_item
)
{
$info
=
Yii
::
$service
->
url
->
category
->
getFilterChooseAttrUrl
(
$this
->
_filterPrice
,
$price_item
,
$this
->
_page
);
$info
[
'val'
]
=
$this
->
getFormatFilterPrice
(
$price_item
);
list
(
$b_price
,
$e_price
)
=
explode
(
'-'
,
$price_item
);
$b_price
=
$b_price
?
$symbol
.
$b_price
:
''
;
$e_price
=
$e_price
?
$symbol
.
$e_price
:
''
;
$label
=
$b_price
.
$this
->
sp
.
$e_price
;
if
(
$currenctPriceFilter
&&
(
$currenctPriceFilter
==
$price_item
)){
$selected
=
true
;
}
else
{
$selected
=
false
;
}
$info
=
[
'selected'
=>
$selected
,
'label'
=>
$label
,
'val'
=>
$price_item
];
$filter
[
$this
->
_filterPrice
][]
=
$info
;
}
}
...
...
@@ -397,9 +411,14 @@ class CategoryController extends AppserverController
if
(
isset
(
$category_query_config
[
'sort'
]))
{
$sortConfig
=
$category_query_config
[
'sort'
];
if
(
is_array
(
$sortConfig
))
{
//return $category_query_config['numPerPage'][0];
if
(
$sort
&&
isset
(
$sortConfig
[
$sort
]))
{
$orderInfo
=
$sortConfig
[
$sort
];
//var_dump($orderInfo);
if
(
!
$direction
)
{
$direction
=
$orderInfo
[
'direction'
];
}
}
else
{
foreach
(
$sortConfig
as
$k
=>
$v
)
{
$orderInfo
=
$v
;
...
...
@@ -409,6 +428,7 @@ class CategoryController extends AppserverController
break
;
}
}
$db_columns
=
$orderInfo
[
'db_columns'
];
if
(
$direction
==
'desc'
)
{
$direction
=
-
1
;
...
...
@@ -416,7 +436,7 @@ class CategoryController extends AppserverController
$direction
=
1
;
}
//var_dump([$db_columns => $direction]);
//exit;
return
[
$db_columns
=>
$direction
];
}
}
...
...
@@ -535,6 +555,7 @@ class CategoryController extends AppserverController
}
}
$filter_price
=
Yii
::
$app
->
request
->
get
(
$this
->
_filterPrice
);
//echo $filter_price;
list
(
$f_price
,
$l_price
)
=
explode
(
'-'
,
$filter_price
);
if
(
$f_price
==
'0'
||
$f_price
)
{
$where
[
$this
->
_filterPriceAttr
][
'$gte'
]
=
(
float
)
$f_price
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录