Toggle navigation
Toggle navigation
This project
Loading...
Sign in
chenchao
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to dashboard
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
0fb7401d58d7bcb126fc75f78e9101084d6e2258
1 parent
5323e058
do home select channel
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
385 additions
and
286 deletions
library/Action/AbstractAction.php
library/Api/Yohobuy.php
library/LibModels/Wap/Home/IndexData.php
library/LibModels/Wap/Product/NewsaleData.php
yohobuy/m.yohobuy.com/application/controllers/Boys.php
yohobuy/m.yohobuy.com/application/controllers/Girls.php
yohobuy/m.yohobuy.com/application/controllers/Index.php
yohobuy/m.yohobuy.com/application/controllers/Kids.php
yohobuy/m.yohobuy.com/application/controllers/Lifestyle.php
yohobuy/m.yohobuy.com/application/modules/Passport/controllers/Back.php
yohobuy/m.yohobuy.com/application/modules/Passport/controllers/Reg.php
yohobuy/m.yohobuy.com/application/modules/Product/controllers/Newsale.php
yohobuy/m.yohobuy.com/application/modules/Product/controllers/Recom.php
yohobuy/m.yohobuy.com/configs/routes.ini
library/Action/AbstractAction.php
View file @
0fb7401
...
...
@@ -293,8 +293,8 @@ class AbstractAction extends Controller_Abstract
// 未登录
else
{
$footer
[
'pageFooter'
]
=
array
();
$footer
[
'pageFooter'
][
'loginUrl'
]
=
''
;
// 登录链接
$footer
[
'pageFooter'
][
'signupUrl'
]
=
''
;
// 注册链接
$footer
[
'pageFooter'
][
'loginUrl'
]
=
'/signin.html'
;
// 登录链接
$footer
[
'pageFooter'
][
'signupUrl'
]
=
'/login.html'
;
// 注册链接
}
$this
->
_view
->
assign
(
'footer'
,
$footer
);
...
...
library/Api/Yohobuy.php
View file @
0fb7401
...
...
@@ -95,24 +95,23 @@ class Yohobuy
*
* @param string $url 接口URL
* @param array $data 参数列表
* @param mixed $cache 控制是否启用接口数据的缓存 如3600表示缓存1小时, false表示不缓存
* @param bool $returnJson 控制是否返回json格式数据
* @param int $timeout 超时时间
* @return mixed
*/
public
static
function
get
(
$url
,
$data
=
array
(),
$
cache
=
false
,
$
returnJson
=
false
,
$timeout
=
5
)
public
static
function
get
(
$url
,
$data
=
array
(),
$returnJson
=
false
,
$timeout
=
5
)
{
// 代表是否开启缓存
$useCache
=
$cache
&&
isset
(
$data
[
'client_secret'
]);
/* 先尝试获取一级缓存(master), 有数据则直接返回 */
if
(
$useCache
)
{
$key
=
md5
(
$url
.
$data
[
'client_secret'
]);
$result
=
Cache
::
get
(
$key
,
'master'
);
if
(
!
empty
(
$result
))
{
return
$result
;
}
}
// // 代表是否开启缓存
// $useCache = $cache && isset($data['client_secret']);
//
// /* 先尝试获取一级缓存(master), 有数据则直接返回 */
// if ($useCache) {
// $key = md5($url . $data['client_secret']);
// $result = Cache::get($key, 'master');
// if (!empty($result)) {
// return $result;
// }
// }
// 销毁私钥参数
if
(
isset
(
$data
[
'private_key'
]))
{
...
...
@@ -133,17 +132,17 @@ class Yohobuy
curl_close
(
$ch
);
$data
=
array
();
/* 设置一级二级缓存 或 获取二级缓存(slave) */
if
(
$useCache
)
{
// 如果接口异常没数据返回,则获取二级缓存
if
(
empty
(
$result
))
{
$result
=
Cache
::
get
(
$key
,
'slave'
);
}
// 如果接口正常有数据返回,则设置数据缓存
else
{
Cache
::
set
(
$key
,
$result
);
}
}
// /* 设置一级二级缓存 或 获取二级缓存(slave) */
// if ($useCache) {
// // 如果接口异常没数据返回,则获取二级缓存
// if (empty($result)) {
// $result = Cache::get($key, 'slave');
// }
// // 如果接口正常有数据返回,则设置数据缓存
// else {
// Cache::set($key, $result);
// }
// }
return
$result
;
}
...
...
@@ -298,7 +297,6 @@ class Yohobuy
try
{
$result
=
call_user_func_array
(
array
(
$client
,
$method
),
$parameters
);
}
catch
(
\Exception
$e
)
{
var_dump
(
$e
);
$result
=
array
();
}
...
...
library/LibModels/Wap/Home/IndexData.php
View file @
0fb7401
<?php
namespace
LibModels\Wap\Home
;
use
Api\Yohobuy
;
...
...
@@ -15,35 +16,39 @@ use Api\Sign;
*/
class
IndexData
{
/**
* 获取启动轮播图
*
* @return array 轮播图有关数据
*/
/**
* 获取启动轮播图
*
* @return array 轮播图有关数据
*/
public
static
function
getBannerStart
()
{
// 构建必传参数
$param
=
Yohobuy
::
param
();
$param
[
'content_code'
]
=
'7ba9118028f9b22090b57341487567eb'
;
// 构建必传参数
$param
=
Yohobuy
::
param
();
$param
[
'content_code'
]
=
'7ba9118028f9b22090b57341487567eb'
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
$response
=
Yohobuy
::
get
(
Yohobuy
::
SERVICE_URL
.
'operations/api/v5/resource/get'
,
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
SERVICE_URL
.
'operations/api/v5/resource/get'
,
$param
);
$result
=
''
;
if
(
isset
(
$response
[
'data'
][
0
][
'data'
][
'list'
][
0
][
'src'
]))
{
$result
=
$response
[
'data'
][
0
][
'data'
][
'list'
][
0
][
'src'
];
}
return
$result
;
}
/**
* 获取启动封面图
*
* @return array 封面图有关数据
*/
/**
* 获取启动封面图
*
* @return array 封面图有关数据
*/
public
static
function
getCoverStart
()
{
// 构建必传参数
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.cover.getCoverStart'
;
// 构建必传参数
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.cover.getCoverStart'
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
...
...
@@ -55,13 +60,12 @@ class IndexData
*/
public
static
function
getUserProfile
(
$uid
)
{
// 构建必传参数
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.passport.profile'
;
$param
[
'uid'
]
=
$uid
;
// 构建必传参数
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.passport.profile'
;
$param
[
'uid'
]
=
$uid
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
...
...
@@ -76,15 +80,15 @@ class IndexData
*/
public
static
function
getUserChannelData
(
$uid
,
$gender
,
$contentCode
,
$limit
=
20
,
$page
=
1
)
{
$param
=
Yohobuy
::
param
();
$param
[
'uid'
]
=
$uid
;
$param
[
'gender'
]
=
$gender
;
$param
[
'content_code'
]
=
$contentCode
;
$param
[
'page'
]
=
$page
;
$param
[
'limit'
]
=
$limit
;
$param
=
Yohobuy
::
param
();
$param
[
'uid'
]
=
$uid
;
$param
[
'gender'
]
=
$gender
;
$param
[
'content_code'
]
=
$contentCode
;
$param
[
'page'
]
=
$page
;
$param
[
'limit'
]
=
$limit
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
SERVICE_URL
.
'operations/api/v5/resource/home'
,
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
SERVICE_URL
.
'operations/api/v5/resource/home'
,
$param
);
}
}
...
...
library/LibModels/Wap/Product/NewsaleData.php
View file @
0fb7401
...
...
@@ -3,7 +3,6 @@ namespace LibModels\Wap\Product;
use
Api\Yohobuy
;
use
Api\Sign
;
use
Plugin\Helpers
;
/**
* 新品到着,折扣专区接口操作类
...
...
yohobuy/m.yohobuy.com/application/controllers/Boys.php
View file @
0fb7401
...
...
@@ -3,33 +3,34 @@
use
Action\AbstractAction
;
use
LibModels\Wap\Home\IndexData
;
use
Plugin\DataProcess\FloorProcess
;
/**
* 男生首页
*/
class
BoysController
extends
AbstractAction
{
public
function
indexAction
()
{
// 显示侧边栏
$this
->
setNavSide
();
public
function
indexAction
()
{
// 设置网站标题
$this
->
setTitle
(
'男生首页'
);
// 显示侧边栏
$this
->
setNavSide
();
// 显示顶部下载
// 显示顶部下载
$this
->
setHeaderDownload
();
// 设置顶部信息(搜索)
$this
->
setHomeChannelHeader
();
$data
=
array
(
'boysHomePage'
=>
true
);
$data
=
array
(
'boysHomePage'
=>
true
);
// 频道数据
$channelData
=
IndexData
::
getUserChannelData
(
0
,
'1,3'
,
'201504091403001'
);
if
(
isset
(
$channelData
[
'code'
])
&&
$channelData
[
'code'
]
==
200
)
{
$data
[
'content'
]
=
FloorProcess
::
getContent
(
$channelData
[
'data'
]);
}
// 频道数据
$channelData
=
IndexData
::
getUserChannelData
(
0
,
'1,3'
,
'201504091403001'
);
$channels
=
array
();
if
(
$channelData
[
'code'
]
==
200
)
{
$data
[
'content'
]
=
FloorProcess
::
getContent
(
$channelData
[
'data'
]);
}
$this
->
_view
->
display
(
'index'
,
$data
);
}
$this
->
_view
->
assign
(
'title'
,
'首页'
);
$this
->
_view
->
display
(
'index'
,
$data
);
}
}
\ No newline at end of file
}
...
...
yohobuy/m.yohobuy.com/application/controllers/Girls.php
View file @
0fb7401
...
...
@@ -3,14 +3,17 @@
use
Action\AbstractAction
;
use
LibModels\Wap\Home\IndexData
;
use
Plugin\DataProcess\FloorProcess
;
/**
* 女生首页
*/
class
GirlsController
extends
AbstractAction
{
public
function
indexAction
()
{
public
function
indexAction
()
{
// 设置网站标题
$this
->
setTitle
(
'女生首页'
);
// 显示侧边栏
$this
->
setNavSide
();
...
...
@@ -19,30 +22,15 @@ class GirlsController extends AbstractAction
// 设置顶部信息(搜索)
$this
->
setHomeChannelHeader
();
$data
=
array
(
'grilsHomePage'
=>
true
);
// 频道数据
$channelData
=
IndexData
::
getUserChannelData
(
0
,
'2,3'
,
'201504091403002'
);
$channels
=
array
();
if
(
$channelData
[
'code'
]
==
200
)
{
$data
[
'content'
]
=
FloorProcess
::
getContent
(
$channelData
[
'data'
],
2
);
}
/*// 也许喜欢
$maybeLikeData = RecomData::mayLike('2,3', 2, false);
$maybeLike = array();
if($maybeLikeData['code'] == 200)
{
$maybeLike = FloorProcess::maybeLike($maybeLikeData['data']['product_list']);
$num = count($data['content']);
$data['content'][] = array('maybeLike' =>$maybeLike);
}*/
$this
->
_view
->
assign
(
'title'
,
'YOHO!有货'
);
$this
->
_view
->
display
(
'index'
,
$data
);
}
$data
=
array
(
'grilsHomePage'
=>
true
);
// 频道数据
$channelData
=
IndexData
::
getUserChannelData
(
0
,
'2,3'
,
'201504091403002'
);
if
(
isset
(
$channelData
[
'code'
])
&&
$channelData
[
'code'
]
==
200
)
{
$data
[
'content'
]
=
FloorProcess
::
getContent
(
$channelData
[
'data'
],
2
);
}
$this
->
_view
->
display
(
'index'
,
$data
);
}
}
...
...
yohobuy/m.yohobuy.com/application/controllers/Index.php
View file @
0fb7401
...
...
@@ -19,19 +19,17 @@ class IndexController extends AbstractAction
// 背景图获取
$banner
=
IndexData
::
getBannerStart
();
if
(
$banner
[
'code'
]
==
200
)
{
foreach
(
$banner
[
'data'
]
as
$item
)
{
foreach
(
$item
[
'data'
][
'list'
]
as
$val
)
{
$data
[
'background'
]
=
Helpers
::
getImageUrl
(
$val
[
'src'
],
640
,
800
,
1
);
}
}
if
(
$banner
)
{
$data
[
'background'
]
=
Helpers
::
getImageUrl
(
$banner
,
640
,
800
,
1
);
}
echo
'<pre>'
;
print_r
(
$data
);
exit
;
$this
->
_view
->
assign
(
'title'
,
'YOHO!有货'
);
// 设置底部导航信息
$this
->
setNavFooter
();
// 生成HTML (index.html)
$this
->
_view
->
html
(
'index'
);
// 渲染模板
$this
->
_view
->
display
(
'index'
,
$data
);
}
...
...
yohobuy/m.yohobuy.com/application/controllers/Kids.php
View file @
0fb7401
...
...
@@ -3,6 +3,7 @@
use
Action\AbstractAction
;
use
LibModels\Wap\Home\IndexData
;
use
Plugin\DataProcess\FloorProcess
;
/**
* 儿童首页
*/
...
...
@@ -11,7 +12,8 @@ class KidsController extends AbstractAction
public
function
indexAction
()
{
// 设置网站标题
$this
->
setTitle
(
'潮童首页'
);
// 显示侧边栏
$this
->
setNavSide
();
...
...
@@ -20,18 +22,15 @@ class KidsController extends AbstractAction
// 设置顶部信息(搜索)
$this
->
setHomeChannelHeader
();
$data
=
array
(
'kidsHomePage'
=>
true
);
$data
=
array
(
'kidsHomePage'
=>
true
);
// 频道数据
$channelData
=
IndexData
::
getUserChannelData
(
0
,
''
,
'e9875682c1599a886bfbdb965b740022'
);
$channels
=
array
();
if
(
$channelData
[
'code'
]
==
200
)
{
if
(
isset
(
$channelData
[
'code'
])
&&
$channelData
[
'code'
]
==
200
)
{
$data
[
'content'
]
=
FloorProcess
::
getContent
(
$channelData
[
'data'
],
3
);
}
$this
->
_view
->
assign
(
'title'
,
'YOHO!有货'
);
$this
->
_view
->
display
(
'index'
,
$data
);
}
}
\ No newline at end of file
}
...
...
yohobuy/m.yohobuy.com/application/controllers/Lifestyle.php
View file @
0fb7401
...
...
@@ -12,6 +12,8 @@ class LifestyleController extends AbstractAction
public
function
indexAction
()
{
// 设置网站标题
$this
->
setTitle
(
'创意生活首页'
);
// 显示侧边栏
$this
->
setNavSide
();
...
...
@@ -20,28 +22,15 @@ class LifestyleController extends AbstractAction
// 设置顶部信息(搜索)
$this
->
setHomeChannelHeader
();
$data
=
array
(
'lifestyleHomePage'
=>
true
);
$data
=
array
(
'lifestyleHomePage'
=>
true
);
// 频道数据
$channelData
=
IndexData
::
getUserChannelData
(
0
,
''
,
'9aa25f5133f011ec96c2045eb15ae425'
);
$channels
=
array
();
if
(
$channelData
[
'code'
]
==
200
)
{
if
(
isset
(
$channelData
[
'code'
])
&&
$channelData
[
'code'
]
==
200
)
{
$data
[
'content'
]
=
FloorProcess
::
getContent
(
$channelData
[
'data'
],
4
);
}
/*// 也许喜欢
$maybeLikeData = RecomData::mayLike('2,3', 2, false);
$maybeLike = array();
if($maybeLikeData['code'] == 200)
{
$maybeLike = FloorProcess::maybeLike($maybeLikeData['data']['product_list']);
$num = count($data['content']);
$data['content'][] = array('maybeLike' =>$maybeLike);
}*/
$this
->
_view
->
assign
(
'title'
,
'YOHO!有货'
);
$this
->
_view
->
display
(
'index'
,
$data
);
}
}
\ No newline at end of file
}
...
...
yohobuy/m.yohobuy.com/application/modules/Passport/controllers/Back.php
View file @
0fb7401
...
...
@@ -206,7 +206,7 @@ class BackController extends AbstractAction
$code
=
$this
->
get
(
'code'
,
''
);
$data
=
array
(
'backUrl'
=>
'/
passport/login/index
'
,
'backUrl'
=>
'/
signin.html
'
,
'headerText'
=>
'找回密码'
,
'isPassportPage'
=>
true
,
'backNewPwd'
=>
true
,
...
...
yohobuy/m.yohobuy.com/application/modules/Passport/controllers/Reg.php
View file @
0fb7401
...
...
@@ -228,7 +228,7 @@ class RegController extends AbstractAction
*/
public
function
setpasswordAction
()
{
$data
=
array
(
'code'
=>
400
,
'message'
=>
'密码格式不正确
!
'
,
'data'
=>
''
);
$data
=
array
(
'code'
=>
400
,
'message'
=>
'密码格式不正确'
,
'data'
=>
''
);
do
{
/* 判断是不是AJAX请求 */
...
...
yohobuy/m.yohobuy.com/application/modules/Product/controllers/Newsale.php
View file @
0fb7401
<?php
use
Action\AbstractAction
;
use
LibModels\
wap\Product\NewsaleData
as
Newsale
;
use
LibModels\
Wap\Product\NewsaleData
;
use
Plugin\DataProcess\NewSaleProcess
;
/**
* 新品到着
*/
class
NewsaleController
extends
AbstractAction
{
public
function
indexAction
()
{
$data
=
array
(
'newArrival'
=>
true
,
'header'
=>
array
(
'title'
=>
'新品到着'
)
);
// 新品到着顶部焦点图
$focusData
=
Newsale
::
getNewsaleFocus
(
'a7989369aa86681c678bc40f171b8f1d'
);
// 处理返回的数据
$focus
=
array
();
if
(
$focusData
[
'code'
]
==
200
)
{
$focus
=
$focusData
[
'data'
];
}
// 批量获取新品到着商品数据
$products
=
Newsale
::
getNewProducts
(
'1,3'
,
1
,
60
);
// 添加商品数据
$data
+=
NewSaleProcess
::
newSaleData
(
$focus
,
$products
);
/*echo '<pre>';
print_r($data);exit;*/
$this
->
_view
->
assign
(
'title'
,
'新品到着'
);
$this
->
_view
->
display
(
'new'
,
$data
);
}
/**
* Ajax方式筛选新品到着、折扣专区商品
*
* @return array 根据指定条件筛选之后的商品
*/
public
function
selectNewSaleAction
()
{
/*if($this->isAjax())
{*/
$gender
=
$this
->
get
(
'gender'
,
'1,3'
);
$brand
=
$this
->
get
(
'brand'
,
null
);
$sort
=
$this
->
get
(
'sort'
,
null
);
$color
=
$this
->
get
(
'color'
,
null
);
$size
=
$this
->
get
(
'size'
,
null
);
$price
=
$this
->
get
(
'price'
,
null
);
$p_d
=
$this
->
get
(
'p_d'
,
null
);
$channel
=
$this
->
get
(
'channel'
,
'1'
);
$dayLimit
=
$this
->
get
(
'dayLimit'
,
'1'
);
$limit
=
$this
->
get
(
'limit'
,
50
);
$page
=
$this
->
get
(
'page'
,
1
);
$data
=
Newsale
::
selectNewSaleProducts
(
$gender
,
$brand
,
$sort
,
$color
,
$size
,
$price
,
$p_d
,
$channel
,
$dayLimit
,
$limit
,
$page
);
$result
=
NewSaleProcess
::
selectData
(
$data
);
$this
->
_view
->
display
(
'product'
,
$result
);
// $this->returnJson(200, '获取成功', $data);
// }
}
/**
* 折扣专区
*/
public
function
discountAction
()
{
$data
=
array
(
'discount'
=>
true
,
'header'
=>
array
(
'title'
=>
'SALE'
)
);
// 折扣专区顶部焦点图
$focusData
=
Newsale
::
getNewsaleFocus
(
'e9c9be32d72e2906d404a72ee24cb523'
);
// 处理返回的数据
$focus
=
array
();
if
(
$focusData
[
'code'
]
==
200
)
{
$focus
=
$focusData
[
'data'
];
}
// 折扣专区商品数据
$products
=
Newsale
::
getSaleProducts
(
'1,3'
,
1
);
// 更新tabs
$tabs
=
array
();
foreach
(
array_keys
(
$products
)
as
$key
=>
$value
)
{
$tabItem
=
array
();
$tabItem
[
'title'
]
=
$value
;
if
(
$key
===
0
)
{
$tabItem
[
'focus'
]
=
true
;
}
$tabs
[]
=
$tabItem
;
}
$data
+=
array
(
'tabs'
=>
$tabs
);
// 添加商品数据
$data
+=
NewSaleProcess
::
newSaleData
(
$focus
,
$products
);
/*echo '<pre>';
print_r($data);exit;*/
$this
->
_view
->
assign
(
'title'
,
'折扣专区'
);
$this
->
_view
->
display
(
'sale'
,
$data
);
}
}
\ No newline at end of file
public
function
indexAction
()
{
$this
->
setTitle
(
'新品到着'
);
$data
=
array
(
'newArrival'
=>
true
,
'header'
=>
array
(
'title'
=>
'新品到着'
)
);
// 新品到着顶部焦点图
$focusData
=
NewsaleData
::
getNewsaleFocus
(
'a7989369aa86681c678bc40f171b8f1d'
);
// 处理返回的数据
$focus
=
array
();
if
(
isset
(
$focusData
[
'code'
])
&&
$focusData
[
'code'
]
==
200
)
{
$focus
=
$focusData
[
'data'
];
}
// 批量获取新品到着商品数据
$products
=
NewsaleData
::
getNewProducts
(
'1,3'
,
1
,
60
);
// 添加商品数据
$data
+=
NewSaleProcess
::
newSaleData
(
$focus
,
$products
);
$this
->
_view
->
display
(
'new'
,
$data
);
}
/**
* Ajax方式筛选新品到着、折扣专区商品
*
* @return array 根据指定条件筛选之后的商品
*/
public
function
selectNewSaleAction
()
{
if
(
$this
->
isAjax
())
{
$gender
=
$this
->
get
(
'gender'
,
'1,3'
);
$brand
=
$this
->
get
(
'brand'
,
null
);
$sort
=
$this
->
get
(
'sort'
,
null
);
$color
=
$this
->
get
(
'color'
,
null
);
$size
=
$this
->
get
(
'size'
,
null
);
$price
=
$this
->
get
(
'price'
,
null
);
$p_d
=
$this
->
get
(
'p_d'
,
null
);
$channel
=
$this
->
get
(
'channel'
,
'1'
);
$dayLimit
=
$this
->
get
(
'dayLimit'
,
'1'
);
$limit
=
$this
->
get
(
'limit'
,
50
);
$page
=
$this
->
get
(
'page'
,
1
);
$data
=
NewsaleData
::
selectNewSaleProducts
(
$gender
,
$brand
,
$sort
,
$color
,
$size
,
$price
,
$p_d
,
$channel
,
$dayLimit
,
$limit
,
$page
);
$result
=
NewSaleProcess
::
selectData
(
$data
);
$this
->
_view
->
display
(
'product'
,
$result
);
}
}
/**
* 折扣专区
*/
public
function
discountAction
()
{
$this
->
setTitle
(
'折扣专区'
);
$data
=
array
(
'discount'
=>
true
,
'header'
=>
array
(
'title'
=>
'SALE'
)
);
// 折扣专区顶部焦点图
$focusData
=
NewsaleData
::
getNewsaleFocus
(
'e9c9be32d72e2906d404a72ee24cb523'
);
// 处理返回的数据
$focus
=
array
();
if
(
isset
(
$focusData
[
'code'
])
&&
$focusData
[
'code'
]
==
200
)
{
$focus
=
$focusData
[
'data'
];
}
// 折扣专区商品数据
$products
=
NewsaleData
::
getSaleProducts
(
'1,3'
,
1
);
// 更新tabs
$tabs
=
array
();
foreach
(
array_keys
(
$products
)
as
$key
=>
$value
)
{
$tabItem
=
array
();
$tabItem
[
'title'
]
=
$value
;
if
(
$key
===
0
)
{
$tabItem
[
'focus'
]
=
true
;
}
$tabs
[]
=
$tabItem
;
}
$data
[
'tabs'
]
=
$tabs
;
// 添加商品数据
$data
+=
NewSaleProcess
::
newSaleData
(
$focus
,
$products
);
/* echo '<pre>';
print_r($data);exit; */
$this
->
_view
->
display
(
'sale'
,
$data
);
}
}
...
...
yohobuy/m.yohobuy.com/application/modules/Product/controllers/Recom.php
View file @
0fb7401
...
...
@@ -2,53 +2,181 @@
use
Action\AbstractAction
;
use
LibModels\Wap\Product\RecomData
;
use
Plugin\Helpers
;
/**
* 商品推荐相关
*
* @name RecomController
* @package Product
* @copyright yoho.inc
* @version 1.0 (2015-10-8 14:43:52)
* @author fei.hong <fei.hong@yoho.cn>
* 推荐相关的控制器
*/
class
RecomController
extends
AbstractAction
{
/**
* 你可能喜欢的
* 你可能喜欢的
BOYS或GIRLS的商品列表
*
* 备注:
* 调用位于男生(BOYS),女生(GIRLS),潮童(KIDS),创意生活(LifeStyle)页面的底部.
* 调用方式为AJAX,需要用JS遍历该数据集,替换图片URL地址中的{width},{height},{mode}.
* JS替换示例: str.replace("{width}", 300).replace("{height}", 300).replace("{mode}", 2);
*
* @param string gender "1,3"表示男, "2,3"表示女, 当channel为3时该参数可不传
* @param string channel 1表示男, 2表示女, 3表示潮童
* @return json
* @param string gender 1,3表示男, 2,3表示女
* @param int page 分页的页码
* @return html
*/
public
function
maylikeAction
()
{
if
(
$this
->
isAjax
())
{
$data
=
''
;
do
{
/* 判断是否是AJAX请求 */
if
(
!
$this
->
isAjax
())
{
break
;
}
/* 判断分页参数是否有效 */
$page
=
$this
->
get
(
'page'
,
1
);
if
(
!
is_numeric
(
$page
))
{
break
;
}
/* 取可能喜欢的数据 */
$recom
=
array
();
$gender
=
$this
->
get
(
'gender'
,
'1,3'
);
$channel
=
$this
->
get
(
'channel'
,
'1'
);
switch
(
strval
(
$channel
))
{
case
'1'
:
// 男(Boys)
case
'2'
:
// 女(Girls)
$data
=
RecomData
::
mayLike
(
$gender
,
$channel
);
break
;
case
'3'
:
// 潮童(Kids)
$data
=
RecomData
::
mayLikeKids
();
break
;
case
'4'
:
// 创意生活(LifeStyle)
$data
=
RecomData
::
mayLikeLifestyle
();
break
;
}
$this
->
echoJson
(
$data
);
// 女
if
(
$gender
===
'2,3'
)
{
$recom
=
RecomData
::
mayLike
(
'2,3'
,
2
);
}
// 男
else
{
$recom
=
RecomData
::
mayLike
(
'1,3'
,
1
);
}
/* 判断是否有内容返回 */
if
(
empty
(
$recom
[
'data'
][
'product_list'
]))
{
break
;
}
/* 构建商品数据 */
$data
=
array
();
foreach
(
$recom
[
'data'
][
'product_list'
]
as
$value
)
{
$data
[
'goods'
][]
=
Helpers
::
formatProduct
(
$value
,
true
);
}
$this
->
_view
->
display
(
'maylike'
,
$data
);
}
while
(
false
);
echo
' '
;
}
/**
* 你可能喜欢的潮童的商品列表
*
* @param int page 分页的页码
* @return html
*/
public
function
maylikeKidsAction
()
{
do
{
/* 判断是否是AJAX请求 */
if
(
!
$this
->
isAjax
())
{
break
;
}
/* 判断分页参数是否有效 */
$page
=
$this
->
get
(
'page'
,
1
);
if
(
!
is_numeric
(
$page
))
{
break
;
}
/* 取可能喜欢的数据 */
$recom
=
RecomData
::
mayLikeKids
();
if
(
empty
(
$recom
[
'data'
][
'product_list'
]))
{
break
;
}
/* 构建模板需要的商品数据 */
$data
=
array
();
foreach
(
$recom
[
'data'
][
'product_list'
]
as
$value
)
{
$data
[
'goods'
][]
=
Helpers
::
formatProduct
(
$value
,
true
);
}
$this
->
_view
->
display
(
'maylike'
,
$data
);
}
while
(
false
);
echo
' '
;
}
/**
* 你可能喜欢的创意生活的新品到着和人气单品列表
*
* @return html
*/
public
function
maylikeLifeAction
()
{
do
{
/* 判断是否是AJAX请求 */
if
(
!
$this
->
isAjax
())
{
break
;
}
/* 取可能喜欢的数据 */
$recom
=
RecomData
::
mayLikeLifestyle
();
if
(
empty
(
$recom
[
'data'
][
'product_list'
]))
{
break
;
}
/* 构建模板需要的商品数据 */
$data
=
array
();
$build
=
array
();
if
(
!
empty
(
$recom
[
'data'
][
'product_list'
][
'top'
]))
{
$build
=
array
();
$build
[
'show'
]
=
true
;
foreach
(
$recom
[
'data'
][
'product_list'
][
'top'
]
as
$value
)
{
$build
[
'goods'
][]
=
Helpers
::
formatProduct
(
$value
,
true
);
}
$data
[
'goodsContainer'
][]
=
$build
;
}
if
(
!
empty
(
$recom
[
'data'
][
'product_list'
][
'new'
]))
{
$build
=
array
();
foreach
(
$recom
[
'data'
][
'product_list'
][
'new'
]
as
$value
)
{
$build
[
'show'
]
=
false
;
$build
[
'goods'
][]
=
Helpers
::
formatProduct
(
$value
,
true
);
}
$data
[
'goodsContainer'
][]
=
$build
;
}
$this
->
_view
->
display
(
'maylikelife'
,
$data
);
}
while
(
false
);
echo
' '
;
}
// /**
// * 你可能喜欢的
// *
// * 备注:
// * 调用位于男生(BOYS),女生(GIRLS),潮童(KIDS),创意生活(LifeStyle)页面的底部.
// * 调用方式为AJAX,需要用JS遍历该数据集,替换图片URL地址中的{width},{height},{mode}.
// * JS替换示例: str.replace("{width}", 300).replace("{height}", 300).replace("{mode}", 2);
// *
// * @param string gender "1,3"表示男, "2,3"表示女, 当channel为3时该参数可不传
// * @param string channel 1表示男, 2表示女, 3表示潮童
// * @return json
// */
// public function maylikeAction()
// {
// if ($this->isAjax()) {
// $data = '';
// $gender = $this->get('gender', '1,3');
// $channel = $this->get('channel', '1');
//
// switch (strval($channel)) {
// case '1': // 男(Boys)
// case '2': // 女(Girls)
// $data = RecomData::mayLike($gender, $channel);
// break;
// case '3': // 潮童(Kids)
// $data = RecomData::mayLikeKids();
// break;
// case '4': // 创意生活(LifeStyle)
// $data = RecomData::mayLikeLifestyle();
// break;
// }
//
// $this->echoJson($data);
// }
// }
}
...
...
yohobuy/m.yohobuy.com/configs/routes.ini
View file @
0fb7401
...
...
@@ -48,4 +48,3 @@ routes.emailback.route.controller = Back
routes.emailback.route.action
=
Email
...
...
Please
register
or
login
to post a comment