Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYWAP
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
Rock Zhang
9 years ago
Commit
344c995f59cf6c97a4ef419d7e14e3f426ad3c86
1 parent
2a422c76
添加一些搜索参数,price,style等,同时支持区间查询
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
109 additions
and
27 deletions
yohobuy/m.yohobuy.com/application/controllers/Search.php
yohobuy/m.yohobuy.com/application/modules/Product/controllers/Index.php
yohobuy/m.yohobuy.com/application/controllers/Search.php
View file @
344c995
...
...
@@ -35,13 +35,14 @@ class SearchController extends AbstractAction
// 过滤请求参数
$condition
=
filter_input_array
(
INPUT_GET
,
array
(
'query'
=>
FILTER_DEFAULT
,
'brand'
=>
FILTER_
VALIDATE_IN
T
,
'brand'
=>
FILTER_
DEFAUL
T
,
'sort'
=>
FILTER_DEFAULT
,
'msort'
=>
FILTER_DEFAULT
,
'misort'
=>
FILTER_DEFAULT
,
'color'
=>
FILTER_VALIDATE_INT
,
'size'
=>
FILTER_VALIDATE_INT
,
'price'
=>
FILTER_VALIDATE_INT
,
'color'
=>
FILTER_DEFAULT
,
'size'
=>
FILTER_DEFAULT
,
'style'
=>
FILTER_DEFAULT
,
'price'
=>
FILTER_DEFAULT
,
'discount'
=>
FILTER_DEFAULT
,
'gender'
=>
FILTER_DEFAULT
,
'p_d'
=>
FILTER_DEFAULT
,),
false
);
...
...
@@ -49,7 +50,7 @@ class SearchController extends AbstractAction
$query
=
empty
(
$condition
[
'query'
])
?
null
:
strtolower
(
trim
(
$condition
[
'query'
]));
if
(
isset
(
$condition
[
'discount'
]))
{
$condition
[
'p_d'
]
=
rawurldecode
(
$condition
[
'discount'
]);
unset
(
$condition
[
'discount'
]);
// unset($condition['discount']); 为了兼容js中传参的discount
}
if
(
isset
(
$condition
[
'query'
]))
{
$condition
[
'query'
]
=
rawurlencode
(
$condition
[
'query'
]);
...
...
@@ -200,13 +201,14 @@ class SearchController extends AbstractAction
/* 过滤请求参数 */
$condition
=
filter_input_array
(
INPUT_GET
,
array
(
'query'
=>
FILTER_DEFAULT
,
'brand'
=>
FILTER_
VALIDATE_IN
T
,
'brand'
=>
FILTER_
DEFAUL
T
,
'sort'
=>
FILTER_DEFAULT
,
'msort'
=>
FILTER_DEFAULT
,
'misort'
=>
FILTER_DEFAULT
,
'color'
=>
FILTER_VALIDATE_INT
,
'size'
=>
FILTER_VALIDATE_INT
,
'price'
=>
FILTER_VALIDATE_INT
,
'color'
=>
FILTER_DEFAULT
,
'size'
=>
FILTER_DEFAULT
,
'style'
=>
FILTER_DEFAULT
,
'price'
=>
FILTER_DEFAULT
,
'discount'
=>
FILTER_DEFAULT
,
'gender'
=>
FILTER_DEFAULT
,
'p_d'
=>
FILTER_DEFAULT
,
...
...
@@ -223,6 +225,10 @@ class SearchController extends AbstractAction
if
(
isset
(
$condition
[
'misort'
]))
{
$condition
[
'misort'
]
=
rawurldecode
(
$condition
[
'misort'
]);
}
// 转义价格
if
(
isset
(
$condition
[
'price'
]))
{
$condition
[
'price'
]
=
rawurldecode
(
$condition
[
'price'
]);
}
// 转换折扣
if
(
isset
(
$condition
[
'discount'
]))
{
$condition
[
'p_d'
]
=
rawurldecode
(
$condition
[
'discount'
]);
...
...
@@ -282,13 +288,14 @@ class SearchController extends AbstractAction
// 过滤请求参数
$condition
=
filter_input_array
(
INPUT_GET
,
array
(
'query'
=>
FILTER_DEFAULT
,
'brand'
=>
FILTER_
VALIDATE_IN
T
,
'brand'
=>
FILTER_
DEFAUL
T
,
'sort'
=>
FILTER_DEFAULT
,
'msort'
=>
FILTER_VALIDATE_INT
,
'misort'
=>
FILTER_VALIDATE_INT
,
'color'
=>
FILTER_VALIDATE_INT
,
'size'
=>
FILTER_VALIDATE_INT
,
'price'
=>
FILTER_VALIDATE_INT
,
'msort'
=>
FILTER_DEFAULT
,
'misort'
=>
FILTER_DEFAULT
,
'color'
=>
FILTER_DEFAULT
,
'size'
=>
FILTER_DEFAULT
,
'style'
=>
FILTER_DEFAULT
,
'price'
=>
FILTER_DEFAULT
,
'discount'
=>
FILTER_DEFAULT
,
'gender'
=>
FILTER_DEFAULT
,
'p_d'
=>
FILTER_DEFAULT
,),
false
);
...
...
@@ -306,6 +313,10 @@ class SearchController extends AbstractAction
if
(
isset
(
$condition
[
'gender'
]))
{
$condition
[
'gender'
]
=
rawurldecode
(
$condition
[
'gender'
]);
}
// 转义价格
if
(
isset
(
$condition
[
'price'
]))
{
$condition
[
'price'
]
=
rawurldecode
(
$condition
[
'price'
]);
}
// 区别各种列表页面的筛选数据
$data
=
Product\SearchModel
::
getFilterData
(
$condition
);
...
...
yohobuy/m.yohobuy.com/application/modules/Product/controllers/Index.php
View file @
344c995
...
...
@@ -25,17 +25,54 @@ class IndexController extends AbstractAction
{
// 过滤请求参数
$condition
=
filter_input_array
(
INPUT_GET
,
array
(
'brand'
=>
FILTER_
VALIDATE_IN
T
,
'brand'
=>
FILTER_
DEFAUL
T
,
'sort'
=>
FILTER_DEFAULT
,
'msort'
=>
FILTER_DEFAULT
,
'misort'
=>
FILTER_DEFAULT
,
'color'
=>
FILTER_VALIDATE_INT
,
'size'
=>
FILTER_VALIDATE_INT
,
'price'
=>
FILTER_VALIDATE_INT
,
'discount'
=>
FILTER_VALIDATE_INT
,
'color'
=>
FILTER_DEFAULT
,
'size'
=>
FILTER_DEFAULT
,
'style'
=>
FILTER_DEFAULT
,
'price'
=>
FILTER_DEFAULT
,
'discount'
=>
FILTER_DEFAULT
,
'gender'
=>
FILTER_DEFAULT
,
'p_d'
=>
FILTER_DEFAULT
,),
false
);
// 转义品牌
if
(
isset
(
$condition
[
'brand'
]))
{
$condition
[
'brand'
]
=
rawurldecode
(
$condition
[
'brand'
]);
}
// 转义分类
if
(
isset
(
$condition
[
'sort'
]))
{
$condition
[
'sort'
]
=
rawurldecode
(
$condition
[
'sort'
]);
}
// 转义一级分类
if
(
isset
(
$condition
[
'msort'
]))
{
$condition
[
'msort'
]
=
rawurldecode
(
$condition
[
'msort'
]);
}
// 转义二级分类
if
(
isset
(
$condition
[
'misort'
]))
{
$condition
[
'misort'
]
=
rawurldecode
(
$condition
[
'misort'
]);
}
// 转义颜色
if
(
isset
(
$condition
[
'color'
]))
{
$condition
[
'color'
]
=
rawurldecode
(
$condition
[
'color'
]);
}
// 转义尺码
if
(
isset
(
$condition
[
'size'
]))
{
$condition
[
'size'
]
=
rawurldecode
(
$condition
[
'size'
]);
}
// 转义风格
if
(
isset
(
$condition
[
'style'
]))
{
$condition
[
'style'
]
=
rawurldecode
(
$condition
[
'style'
]);
}
// 转义价格
if
(
isset
(
$condition
[
'price'
]))
{
$condition
[
'price'
]
=
rawurldecode
(
$condition
[
'price'
]);
}
// 转换折扣
if
(
isset
(
$condition
[
'discount'
]))
{
$condition
[
'p_d'
]
=
rawurldecode
(
$condition
[
'discount'
]);
}
// 性别参数,不传则从COOKIE获取
if
(
!
isset
(
$condition
[
'gender'
]))
{
$condition
[
'gender'
]
=
Helpers
::
getGenderByCookie
();
...
...
@@ -54,6 +91,7 @@ class IndexController extends AbstractAction
if
(
!
$condition
)
{
$condition
=
array
();
}
print_r
(
$condition
);
$goodList
=
$condition
;
$goodList
[
'cartUrl'
]
=
Helpers
::
url
(
'/cart/index/index'
,
null
);
...
...
@@ -112,16 +150,49 @@ class IndexController extends AbstractAction
/* 过滤请求参数 */
$condition
=
filter_input_array
(
INPUT_GET
,
array
(
'sort'
=>
FILTER_DEFAULT
,
'msort'
=>
FILTER_VALIDATE_INT
,
'misort'
=>
FILTER_VALIDATE_INT
,
'color'
=>
FILTER_VALIDATE_INT
,
'size'
=>
FILTER_VALIDATE_INT
,
'price'
=>
FILTER_VALIDATE_INT
,
'discount'
=>
FILTER_VALIDATE_INT
,
'msort'
=>
FILTER_DEFAULT
,
'misort'
=>
FILTER_DEFAULT
,
'color'
=>
FILTER_DEFAULT
,
'size'
=>
FILTER_DEFAULT
,
'style'
=>
FILTER_DEFAULT
,
'price'
=>
FILTER_DEFAULT
,
'discount'
=>
FILTER_DEFAULT
,
'gender'
=>
FILTER_DEFAULT
,
'p_d'
=>
FILTER_DEFAULT
,),
false
);
$condition
[
'brand'
]
=
$brandId
;
// 转义分类
if
(
isset
(
$condition
[
'sort'
]))
{
$condition
[
'sort'
]
=
rawurldecode
(
$condition
[
'sort'
]);
}
// 转义一级分类
if
(
isset
(
$condition
[
'msort'
]))
{
$condition
[
'msort'
]
=
rawurldecode
(
$condition
[
'msort'
]);
}
// 转义二级分类
if
(
isset
(
$condition
[
'misort'
]))
{
$condition
[
'misort'
]
=
rawurldecode
(
$condition
[
'misort'
]);
}
// 转义颜色
if
(
isset
(
$condition
[
'color'
]))
{
$condition
[
'color'
]
=
rawurldecode
(
$condition
[
'color'
]);
}
// 转义尺码
if
(
isset
(
$condition
[
'size'
]))
{
$condition
[
'size'
]
=
rawurldecode
(
$condition
[
'size'
]);
}
// 转义风格
if
(
isset
(
$condition
[
'style'
]))
{
$condition
[
'style'
]
=
rawurldecode
(
$condition
[
'style'
]);
}
// 转义价格
if
(
isset
(
$condition
[
'price'
]))
{
$condition
[
'price'
]
=
rawurldecode
(
$condition
[
'price'
]);
}
// 转换折扣
if
(
isset
(
$condition
[
'discount'
]))
{
$condition
[
'p_d'
]
=
rawurldecode
(
$condition
[
'discount'
]);
}
if
(
$brandId
===
0
)
{
$condition
[
'query'
]
=
$domain
;
}
...
...
Please
register
or
login
to post a comment