Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
2
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
whb
9 years ago
Commit
0ab3513434dfba36c21edd67ec320eab77d93f47
1 parent
1c3cd31e
PC的web search banner问题
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
104 additions
and
104 deletions
yohobuy/www.yohobuy.com/application/models/Product/Index.php
yohobuy/www.yohobuy.com/application/models/Product/Index.php
View file @
0ab3513
<?php
namespace
Product
;
use
WebPlugin\HelperSearch
;
use
Product\SearchModel
;
use
LibModels\Web\Product\SearchData
;
use
Api\Yohobuy
;
use
Configs\WebCacheConfig
;
use
WebPlugin\Cache
;
use
WebPlugin\Helpers
;
/**
* list Index页模板数据模型
*
*/
class
IndexModel
{
/**
* 搜索list首页数据
* @param $customCondition array(
* 'brand' => int (品牌id,必传)
* 'folder_id' => string (搜索品牌系列参数)
* )
* @param $customOptions array(
'reviewNum' => int (底部浏览记录显示个数)
'positionId' => int (搜索banner 位置id)
'controller' => string (说明当前控制器名)
'action' => string (说明当前方法名)
* ) 排序条件
* @return array() (处理后的list首页数据)
*/
public
static
function
getIndexData
(
$customCondition
,
$customOptions
)
{
$searchCondition
=
SearchModel
::
searchCondition
(
$customCondition
,
$customOptions
);
// 组合搜索商品url
$urlList
[
'product'
]
=
SearchData
::
getProductUrl
(
$searchCondition
[
'condition'
]);
// 组合搜索分类url
$sortCondition
=
array
();
if
(
isset
(
$searchCondition
[
'condition'
][
'misort'
])
&&
!
empty
(
$searchCondition
[
'condition'
][
'misort'
]))
{
$sortCondition
[
'needSmallSort'
]
=
1
;
}
$urlList
[
'sort'
]
=
SearchData
::
getClassesUrl
(
$sortCondition
);
//批量调接口获取数据
$data
=
Yohobuy
::
getMulti
(
$urlList
);
// 组织模板数据
$result
=
HelperSearch
::
getList
(
$data
,
$searchCondition
[
'options'
],
$searchCondition
[
'userInput'
]);
//调用接口获取list-index banner数据
$msort
=
isset
(
$searchCondition
[
'condition'
][
'msort'
])
?
$searchCondition
[
'condition'
][
'msort'
]
:
0
;
$misort
=
isset
(
$searchCondition
[
'condition'
][
'misort'
])
?
$searchCondition
[
'condition'
][
'misort'
]
:
0
;
$positionId
=
isset
(
$searchCondition
[
'options'
][
'positionId'
])
?
$searchCondition
[
'options'
][
'positionId'
]
:
''
;
$gender
=
$searchCondition
[
'condition'
][
'gender'
]
==
'2,3'
?
2
:
1
;
if
(
$msort
&&
$misort
&&
$positionId
)
{
$banner
=
array
();
$bannerData
=
SearchData
::
getBannerData
(
$positionId
,
$msort
,
$misort
,
$gender
);
if
(
isset
(
$bannerData
[
'code'
])
&&
$bannerData
[
'code'
]
==
200
&&
!
empty
(
$bannerData
[
'data'
]))
{
$banner
=
self
::
formatBanner
(
$bannerData
[
'data'
]);
}
$result
[
'sortIntro'
]
=
$banner
;
}
//广告数据
$adsId
=
$searchCondition
[
'options'
][
'adsId'
];
$ads
=
SearchData
::
getListAd
(
$msort
,
$misort
,
$adsId
);
if
(
isset
(
$ads
[
'code'
])
&&
$ads
[
'code'
]
==
200
&&
!
empty
(
$ads
[
'data'
]))
{
$res
=
array
();
foreach
(
$ads
[
'data'
]
as
$key
=>
$value
)
{
$res
[
'picLink'
][
'list'
][
$key
][
'href'
]
=
isset
(
$value
[
'ads_url'
])
?
$value
[
'ads_url'
]
:
''
;
$res
[
'picLink'
][
'list'
][
$key
][
'src'
]
=
isset
(
$value
[
'ads_image'
])
?
$value
[
'ads_image'
]
:
''
;
}
$result
[
'leftContent'
][]
=
$res
;
}
return
$result
;
}
/**
* 组织list-index banner数据
* @param $bannerData
* @return array() 处理后的banner格式
*/
public
static
function
formatBanner
(
$bannerData
)
{
$banner
=
array
();
$banner
[
'name'
]
=
$bannerData
[
'title'
];
$banner
[
'enName'
]
=
$bannerData
[
'subtitle'
];
$banner
[
'description'
]
=
$bannerData
[
'intro'
];
$banner
[
'img'
]
=
$bannerData
[
'logo'
];
foreach
(
$bannerData
[
'keyword'
]
as
$key
=>
$vo
){
$banner
[
'keyEntry'
][
$key
][
'name'
]
=
$vo
[
'word'
];
$banner
[
'keyEntry'
][
$key
][
'url'
]
=
$vo
[
'url'
];
}
return
$banner
;
}
}
<?php
namespace
Product
;
use
WebPlugin\HelperSearch
;
use
Product\SearchModel
;
use
LibModels\Web\Product\SearchData
;
use
Api\Yohobuy
;
use
Configs\WebCacheConfig
;
use
WebPlugin\Cache
;
use
WebPlugin\Helpers
;
/**
* list Index页模板数据模型
*
*/
class
IndexModel
{
/**
* 搜索list首页数据
* @param $customCondition array(
* 'brand' => int (品牌id,必传)
* 'folder_id' => string (搜索品牌系列参数)
* )
* @param $customOptions array(
'reviewNum' => int (底部浏览记录显示个数)
'positionId' => int (搜索banner 位置id)
'controller' => string (说明当前控制器名)
'action' => string (说明当前方法名)
* ) 排序条件
* @return array() (处理后的list首页数据)
*/
public
static
function
getIndexData
(
$customCondition
,
$customOptions
)
{
$searchCondition
=
SearchModel
::
searchCondition
(
$customCondition
,
$customOptions
);
// 组合搜索商品url
$urlList
[
'product'
]
=
SearchData
::
getProductUrl
(
$searchCondition
[
'condition'
]);
// 组合搜索分类url
$sortCondition
=
array
();
if
(
isset
(
$searchCondition
[
'condition'
][
'misort'
])
&&
!
empty
(
$searchCondition
[
'condition'
][
'misort'
]))
{
$sortCondition
[
'needSmallSort'
]
=
1
;
}
$urlList
[
'sort'
]
=
SearchData
::
getClassesUrl
(
$sortCondition
);
//批量调接口获取数据
$data
=
Yohobuy
::
getMulti
(
$urlList
);
// 组织模板数据
$result
=
HelperSearch
::
getList
(
$data
,
$searchCondition
[
'options'
],
$searchCondition
[
'userInput'
]);
//调用接口获取list-index banner数据
$msort
=
isset
(
$searchCondition
[
'condition'
][
'msort'
])
?
$searchCondition
[
'condition'
][
'msort'
]
:
0
;
$misort
=
isset
(
$searchCondition
[
'condition'
][
'misort'
])
?
$searchCondition
[
'condition'
][
'misort'
]
:
0
;
$positionId
=
isset
(
$searchCondition
[
'options'
][
'positionId'
])
?
$searchCondition
[
'options'
][
'positionId'
]
:
''
;
// $gender = $searchCondition['condition']['gender'] == '2,3' ? 2 : 1;
$gender
=
isset
(
$searchCondition
[
'condition'
][
'gender'
])
?
$searchCondition
[
'condition'
][
'gender'
]
:
''
;
if
(
$msort
&&
$misort
&&
$positionId
)
{
$banner
=
array
();
$bannerData
=
SearchData
::
getBannerData
(
$positionId
,
$msort
,
$misort
,
$gender
);
if
(
isset
(
$bannerData
[
'code'
])
&&
$bannerData
[
'code'
]
==
200
&&
!
empty
(
$bannerData
[
'data'
]))
{
$banner
=
self
::
formatBanner
(
$bannerData
[
'data'
]);
}
$result
[
'sortIntro'
]
=
$banner
;
}
//广告数据
$adsId
=
$searchCondition
[
'options'
][
'adsId'
];
$ads
=
SearchData
::
getListAd
(
$msort
,
$misort
,
$adsId
);
if
(
isset
(
$ads
[
'code'
])
&&
$ads
[
'code'
]
==
200
&&
!
empty
(
$ads
[
'data'
]))
{
$res
=
array
();
foreach
(
$ads
[
'data'
]
as
$key
=>
$value
)
{
$res
[
'picLink'
][
'list'
][
$key
][
'href'
]
=
isset
(
$value
[
'ads_url'
])
?
$value
[
'ads_url'
]
:
''
;
$res
[
'picLink'
][
'list'
][
$key
][
'src'
]
=
isset
(
$value
[
'ads_image'
])
?
$value
[
'ads_image'
]
:
''
;
}
$result
[
'leftContent'
][]
=
$res
;
}
return
$result
;
}
/**
* 组织list-index banner数据
* @param $bannerData
* @return array() 处理后的banner格式
*/
public
static
function
formatBanner
(
$bannerData
)
{
$banner
=
array
();
$banner
[
'name'
]
=
$bannerData
[
'title'
];
$banner
[
'enName'
]
=
$bannerData
[
'subtitle'
];
$banner
[
'description'
]
=
$bannerData
[
'intro'
];
$banner
[
'img'
]
=
$bannerData
[
'logo'
];
foreach
(
$bannerData
[
'keyword'
]
as
$key
=>
$vo
){
$banner
[
'keyEntry'
][
$key
][
'name'
]
=
$vo
[
'word'
];
$banner
[
'keyEntry'
][
$key
][
'url'
]
=
$vo
[
'url'
];
}
return
$banner
;
}
}
...
...
Please
register
or
login
to post a comment