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
...
@@ -36,7 +36,7 @@ class CategoryController extends AppserverController
// url的参数,排序方向
// url的参数,排序方向
protected
$_direction
=
'dir'
;
protected
$_direction
=
'dir'
;
// url的参数,排序字段
// url的参数,排序字段
protected
$_sort
=
'sort'
;
protected
$_sort
=
'sort
Column
'
;
// url的参数,页数
// url的参数,页数
protected
$_page
=
'p'
;
protected
$_page
=
'p'
;
// url的参数,价格
// url的参数,价格
...
@@ -48,6 +48,8 @@ class CategoryController extends AppserverController
...
@@ -48,6 +48,8 @@ class CategoryController extends AppserverController
protected
$_filter_attr
;
protected
$_filter_attr
;
protected
$_numPerPageVal
;
protected
$_numPerPageVal
;
protected
$_page_count
;
protected
$_page_count
;
protected
$category_name
;
protected
$sp
=
'---'
;
public
function
actionIndex
(){
public
function
actionIndex
(){
...
@@ -70,21 +72,14 @@ class CategoryController extends AppserverController
...
@@ -70,21 +72,14 @@ class CategoryController extends AppserverController
$this
->
_productCount
=
$productCollInfo
[
'count'
];
$this
->
_productCount
=
$productCollInfo
[
'count'
];
$p
=
Yii
::
$app
->
request
->
get
(
'p'
);
$p
=
Yii
::
$app
->
request
->
get
(
'p'
);
$p
=
(
int
)
$p
;
$p
=
(
int
)
$p
;
if
(
$p
>
1
)
{
//$this->getAjaxProductHtml($products);
return
[
'code'
=>
200
,
'content'
=>
[
'products'
=>
$products
]
];
}
$query_item
=
$this
->
getQueryItem
();
$query_item
=
$this
->
getQueryItem
();
$page_count
=
$this
->
getProductPageCount
();
$page_count
=
$this
->
getProductPageCount
();
$this
->
category_name
=
Yii
::
$service
->
store
->
getStoreAttrVal
(
$this
->
_category
[
'name'
],
'name'
);
//echo $this->_productCount;
//echo $this->_productCount;
return
[
return
[
'code'
=>
200
,
'code'
=>
200
,
'content'
=>
[
'content'
=>
[
'name'
=>
$this
->
category_name
,
'title'
=>
$this
->
_title
,
'title'
=>
$this
->
_title
,
'image'
=>
$this
->
_category
[
'image'
]
?
Yii
::
$service
->
category
->
image
->
getUrl
(
$this
->
_category
[
'image'
])
:
''
,
'image'
=>
$this
->
_category
[
'image'
]
?
Yii
::
$service
->
category
->
image
->
getUrl
(
$this
->
_category
[
'image'
])
:
''
,
'products'
=>
$products
,
'products'
=>
$products
,
...
@@ -92,7 +87,7 @@ class CategoryController extends AppserverController
...
@@ -92,7 +87,7 @@ class CategoryController extends AppserverController
'refine_by_info'
=>
$this
->
getRefineByInfo
(),
'refine_by_info'
=>
$this
->
getRefineByInfo
(),
'filter_info'
=>
$this
->
getFilterInfo
(),
'filter_info'
=>
$this
->
getFilterInfo
(),
'filter_price'
=>
$this
->
getFilterPrice
(),
'filter_price'
=>
$this
->
getFilterPrice
(),
'filter_category'
=>
$this
->
getFilterCategory
Html
(),
'filter_category'
=>
$this
->
getFilterCategory
(),
'page_count'
=>
$page_count
,
'page_count'
=>
$page_count
,
],
],
//'content' => Yii::$service->store->getStoreAttrVal($this->_category['content'],'content'),
//'content' => Yii::$service->store->getStoreAttrVal($this->_category['content'],'content'),
...
@@ -148,12 +143,31 @@ class CategoryController extends AppserverController
...
@@ -148,12 +143,31 @@ class CategoryController extends AppserverController
*/
*/
protected
function
getFilterCategory
()
protected
function
getFilterCategory
()
{
{
$arr
=
[];
$category_id
=
$this
->
_primaryVal
;
$category_id
=
$this
->
_primaryVal
;
$parent_id
=
$this
->
_category
[
'parent_id'
];
$parent_id
=
$this
->
_category
[
'parent_id'
];
$filter_category
=
Yii
::
$service
->
category
->
getFilterCategory
(
$category_id
,
$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
;
return
$filter_category
;
}
}
/**
/**
* @property $filter_category | Array
* @property $filter_category | Array
* 通过递归的方式,得到分类以及子分类的html。
* 通过递归的方式,得到分类以及子分类的html。
...
@@ -204,20 +218,9 @@ class CategoryController extends AppserverController
...
@@ -204,20 +218,9 @@ class CategoryController extends AppserverController
$category_query
=
Yii
::
$app
->
controller
->
module
->
params
[
'category_query'
];
$category_query
=
Yii
::
$app
->
controller
->
module
->
params
[
'category_query'
];
$numPerPage
=
$category_query
[
'numPerPage'
];
$numPerPage
=
$category_query
[
'numPerPage'
];
$sort
=
$category_query
[
'sort'
];
$sort
=
$category_query
[
'sort'
];
$current_sort
=
Yii
::
$app
->
request
->
get
(
$this
->
_sort
);
$frontNumPerPage
=
[];
$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
=
[];
$frontSort
=
[];
if
(
is_array
(
$sort
)
&&
!
empty
(
$sort
))
{
if
(
is_array
(
$sort
)
&&
!
empty
(
$sort
))
{
$attrUrlStr
=
$this
->
_sort
;
$attrUrlStr
=
$this
->
_sort
;
...
@@ -225,21 +228,16 @@ class CategoryController extends AppserverController
...
@@ -225,21 +228,16 @@ class CategoryController extends AppserverController
foreach
(
$sort
as
$np
=>
$info
)
{
foreach
(
$sort
as
$np
=>
$info
)
{
$label
=
$info
[
'label'
];
$label
=
$info
[
'label'
];
$direction
=
$info
[
'direction'
];
$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
[]
=
[
$frontSort
[]
=
[
'label'
=>
$label
,
'label'
=>
$label
,
'value'
=>
$np
,
'value'
=>
$np
,
'url'
=>
$urlInfo
[
'url'
],
'selected'
=>
$selected
,
'selected'
=>
$urlInfo
[
'selected'
],
];
];
}
}
}
}
...
@@ -334,12 +332,28 @@ class CategoryController extends AppserverController
...
@@ -334,12 +332,28 @@ class CategoryController extends AppserverController
*/
*/
protected
function
getFilterPrice
()
protected
function
getFilterPrice
()
{
{
$symbol
=
Yii
::
$service
->
page
->
currency
->
getCurrentSymbol
();
$currenctPriceFilter
=
Yii
::
$app
->
request
->
get
(
$this
->
_filterPrice
);
$filter
=
[];
$filter
=
[];
$priceInfo
=
Yii
::
$app
->
controller
->
module
->
params
[
'category_query'
];
$priceInfo
=
Yii
::
$app
->
controller
->
module
->
params
[
'category_query'
];
if
(
isset
(
$priceInfo
[
'price_range'
])
&&
!
empty
(
$priceInfo
[
'price_range'
])
&&
is_array
(
$priceInfo
[
'price_range'
]))
{
if
(
isset
(
$priceInfo
[
'price_range'
])
&&
!
empty
(
$priceInfo
[
'price_range'
])
&&
is_array
(
$priceInfo
[
'price_range'
]))
{
foreach
(
$priceInfo
[
'price_range'
]
as
$price_item
)
{
foreach
(
$priceInfo
[
'price_range'
]
as
$price_item
)
{
$info
=
Yii
::
$service
->
url
->
category
->
getFilterChooseAttrUrl
(
$this
->
_filterPrice
,
$price_item
,
$this
->
_page
);
list
(
$b_price
,
$e_price
)
=
explode
(
'-'
,
$price_item
);
$info
[
'val'
]
=
$this
->
getFormatFilterPrice
(
$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
;
$filter
[
$this
->
_filterPrice
][]
=
$info
;
}
}
}
}
...
@@ -397,9 +411,14 @@ class CategoryController extends AppserverController
...
@@ -397,9 +411,14 @@ class CategoryController extends AppserverController
if
(
isset
(
$category_query_config
[
'sort'
]))
{
if
(
isset
(
$category_query_config
[
'sort'
]))
{
$sortConfig
=
$category_query_config
[
'sort'
];
$sortConfig
=
$category_query_config
[
'sort'
];
if
(
is_array
(
$sortConfig
))
{
if
(
is_array
(
$sortConfig
))
{
//return $category_query_config['numPerPage'][0];
//return $category_query_config['numPerPage'][0];
if
(
$sort
&&
isset
(
$sortConfig
[
$sort
]))
{
if
(
$sort
&&
isset
(
$sortConfig
[
$sort
]))
{
$orderInfo
=
$sortConfig
[
$sort
];
$orderInfo
=
$sortConfig
[
$sort
];
//var_dump($orderInfo);
if
(
!
$direction
)
{
$direction
=
$orderInfo
[
'direction'
];
}
}
else
{
}
else
{
foreach
(
$sortConfig
as
$k
=>
$v
)
{
foreach
(
$sortConfig
as
$k
=>
$v
)
{
$orderInfo
=
$v
;
$orderInfo
=
$v
;
...
@@ -409,6 +428,7 @@ class CategoryController extends AppserverController
...
@@ -409,6 +428,7 @@ class CategoryController extends AppserverController
break
;
break
;
}
}
}
}
$db_columns
=
$orderInfo
[
'db_columns'
];
$db_columns
=
$orderInfo
[
'db_columns'
];
if
(
$direction
==
'desc'
)
{
if
(
$direction
==
'desc'
)
{
$direction
=
-
1
;
$direction
=
-
1
;
...
@@ -416,7 +436,7 @@ class CategoryController extends AppserverController
...
@@ -416,7 +436,7 @@ class CategoryController extends AppserverController
$direction
=
1
;
$direction
=
1
;
}
}
//var_dump([$db_columns => $direction]);
//var_dump([$db_columns => $direction]);
//exit;
return
[
$db_columns
=>
$direction
];
return
[
$db_columns
=>
$direction
];
}
}
}
}
...
@@ -535,6 +555,7 @@ class CategoryController extends AppserverController
...
@@ -535,6 +555,7 @@ class CategoryController extends AppserverController
}
}
}
}
$filter_price
=
Yii
::
$app
->
request
->
get
(
$this
->
_filterPrice
);
$filter_price
=
Yii
::
$app
->
request
->
get
(
$this
->
_filterPrice
);
//echo $filter_price;
list
(
$f_price
,
$l_price
)
=
explode
(
'-'
,
$filter_price
);
list
(
$f_price
,
$l_price
)
=
explode
(
'-'
,
$filter_price
);
if
(
$f_price
==
'0'
||
$f_price
)
{
if
(
$f_price
==
'0'
||
$f_price
)
{
$where
[
$this
->
_filterPriceAttr
][
'$gte'
]
=
(
float
)
$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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录