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
hf
9 years ago
Commit
b55a691ddf7e0e0ff48efbb3d841ee2e5637c9fe
1 parent
820ff827
code review by hf: do format channel choose code
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
33 deletions
library/Configs/CacheConfig.php
library/LibModels/Wap/Home/IndexData.php
yohobuy/m.yohobuy.com/application/controllers/Index.php
yohobuy/m.yohobuy.com/application/models/Index/Home.php
library/Configs/CacheConfig.php
View file @
b55a691
...
...
@@ -18,6 +18,8 @@ class CacheConfig
const
KEY_ACTION_GIRLS_INDEX
=
'key_action_girls_index'
;
// 女生首页
const
KEY_ACTION_KIDS_INDEX
=
'key_action_kids_index'
;
// 潮童首页
const
KEY_ACTION_LIFESTYLE_INDEX
=
'key_action_lifestyle_index'
;
// 创意生活首页
const
KEY_ACTION_INDEX_CONFIG
=
'key_action_index_config'
;
// 频道配置
const
KEY_ACTION_BOYS_BOTTOM_BANNER
=
'key_action_boys_bottom_banner'
;
// 男生首页底部banner
const
KEY_ACTION_GRILS_BOTTOM_BANNER
=
'key_action_girls_bottom_banner'
;
// 女生首页底部banner
...
...
@@ -51,6 +53,6 @@ class CacheConfig
const
KEY_ACTION_GUANG_DETAIL_DATA
=
'key_action_guang_detail_data'
;
// 逛内容详情
const
KEY_ACTION_GUANG_RSS_DATA
=
'key_action_guang_detail_data'
;
// 逛订阅内容
const
KEY_ACTION_ADDRESS_LIST_DATA
=
'key_action_address_list_data'
;
// 地址树数据
const
KEY_ACTION_ADDRESS_LIST_DATA
=
'key_action_address_list_data'
;
// 地址树数据
}
...
...
library/LibModels/Wap/Home/IndexData.php
View file @
b55a691
...
...
@@ -77,7 +77,8 @@ class IndexData
{
$param
=
Yohobuy
::
param
();
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
SERVICE_URL
.
'operations/api/v5/entrance/getEntrance'
,
$param
,
3600
);
return
Yohobuy
::
get
(
Yohobuy
::
SERVICE_URL
.
'operations/api/v5/entrance/getEntrance'
,
$param
);
}
}
...
...
yohobuy/m.yohobuy.com/application/controllers/Index.php
View file @
b55a691
...
...
@@ -23,12 +23,14 @@ class IndexController extends AbstractAction
// 设置浏览器缓存5分钟
$this
->
setExpires
(
300
);
}
$result
=
Index\HomeModel
::
getChannel
();
$result
[
'background'
]
=
Index\HomeModel
::
getBgImage
();
$result
[
'channelPage'
]
=
true
;
$result
[
'showDownloadApp'
]
=
true
;
$result
[
'searchUrl'
]
=
Helpers
::
url
(
''
,
null
,
'search'
);
$result
[
'pageFooter'
]
=
true
;
// 渲染模板
$this
->
_view
->
display
(
'index'
,
$result
);
}
...
...
yohobuy/m.yohobuy.com/application/models/Index/Home.php
View file @
b55a691
...
...
@@ -20,6 +20,7 @@ use Configs\CacheConfig;
class
HomeModel
{
/* 频道选择页取背景图片的位置码 */
const
CODE_BG
=
'7ba9118028f9b22090b57341487567eb'
;
/* 男生楼层资源的位置码 */
...
...
@@ -70,7 +71,8 @@ class HomeModel
/**
* 设置选择的频道保存到浏览器COOKIE
*
* (已废弃,改成JS设置)
*
* @param string $cookie
* @return void
*/
...
...
@@ -99,10 +101,10 @@ class HomeModel
// 调用接口获取数据
$banner
=
IndexData
::
getBannerStart
(
self
::
CODE_BG
);
if
(
isset
(
$banner
[
'code'
])
&&
$banner
[
'code'
]
==
200
&&
!
empty
(
$banner
[
'data'
]))
{
$imgArr
=
$banner
[
'data'
][
0
][
'data'
];
if
(
isset
(
$banner
[
'data'
][
0
][
'data'
][
'list'
]))
{
$imgArr
=
$banner
[
'data'
][
0
][
'data'
][
'list'
];
}
$imgArr
=
$banner
[
'data'
][
0
][
'data'
];
if
(
isset
(
$banner
[
'data'
][
0
][
'data'
][
'list'
]))
{
$imgArr
=
$banner
[
'data'
][
0
][
'data'
][
'list'
];
}
$result
=
Helpers
::
getImageUrl
(
$imgArr
[
0
][
'src'
],
640
,
800
,
2
);
}
...
...
@@ -128,7 +130,7 @@ class HomeModel
public
static
function
getBottomBanner
(
$channel
)
{
$result
=
false
;
if
(
$channel
==
2
)
{
if
(
$channel
==
2
)
{
$resource
=
self
::
CODE_NAME_GIRLS_BOTTOM_BANNER
;
$cache
=
CacheConfig
::
KEY_ACTION_GRILS_BOTTOM_BANNER
;
}
else
{
...
...
@@ -324,45 +326,65 @@ class HomeModel
*
* @return array
*/
public
static
function
getChannel
(){
public
static
function
getChannel
()
{
$result
=
array
();
$result
[
'showYohood'
]
=
false
;
$data
=
IndexData
::
channelData
();
if
(
USE_CACHE
)
{
$key
=
CacheConfig
::
KEY_ACTION_INDEX_CONFIG
;
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result
=
Cache
::
get
(
$key
,
'master'
);
if
(
!
empty
(
$result
))
{
return
$result
;
}
}
$channelList
=
array
();
if
(
isset
(
$data
[
'data'
][
'list'
])){
foreach
(
$data
[
'data'
][
'list'
]
as
$key
=>
$value
){
switch
(
$value
[
'channel_id'
])
{
case
5
:
$result
[
'showYohood'
]
=
true
;
$result
[
'yohoodHref'
]
=
'/yohood'
;
break
;
$data
=
IndexData
::
channelData
();
if
(
!
empty
(
$data
[
'data'
][
'list'
]))
{
$build
=
array
();
foreach
(
$data
[
'data'
][
'list'
]
as
$value
)
{
$build
=
array
();
switch
(
intval
(
$value
[
'channel_id'
]))
{
case
1
:
$channelList
[
$key
][
'href'
]
=
'/boys'
;
$channelList
[
$key
][
'title'
]
=
'男生'
;
$channelList
[
$key
][
'entitle'
]
=
'BOYS'
;
$build
[
'href'
]
=
'/boys'
;
$build
[
'title'
]
=
'男生'
;
$build
[
'entitle'
]
=
'BOYS'
;
break
;
case
2
:
$channelList
[
$key
][
'href'
]
=
'/girls'
;
$channelList
[
$key
][
'title'
]
=
'女生'
;
$channelList
[
$key
][
'entitle'
]
=
'GIRLS'
;
$build
[
'href'
]
=
'/girls'
;
$build
[
'title'
]
=
'女生'
;
$build
[
'entitle'
]
=
'GIRLS'
;
break
;
case
3
:
$channelList
[
$key
][
'href'
]
=
'/kids'
;
$channelList
[
$key
][
'title'
]
=
'潮童'
;
$channelList
[
$key
][
'entitle'
]
=
'KIDS'
;
$build
[
'href'
]
=
'/kids'
;
$build
[
'title'
]
=
'潮童'
;
$build
[
'entitle'
]
=
'KIDS'
;
break
;
case
4
:
$channelList
[
$key
][
'href'
]
=
'/lifestyle'
;
$channelList
[
$key
][
'title'
]
=
'创意生活'
;
$channelList
[
$key
][
'entitle'
]
=
'LIFESTYLE'
;
$build
[
'href'
]
=
'/lifestyle'
;
$build
[
'title'
]
=
'创意生活'
;
$build
[
'entitle'
]
=
'LIFESTYLE'
;
break
;
default
:
case
5
:
$result
[
'showYohood'
]
=
true
;
$result
[
'yohoodHref'
]
=
'http://yohood.cn'
;
break
;
default
:
continue
;
}
$result
[
'channelList'
][]
=
$build
;
}
}
if
(
USE_CACHE
)
{
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if
(
empty
(
$result
))
{
$result
=
Cache
::
get
(
$key
,
'slave'
);
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else
{
Cache
::
set
(
$key
,
$result
);
}
$result
[
'channelList'
]
=
$channelList
;
}
return
$result
;
...
...
Please
register
or
login
to post a comment