Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHO-ACTIVITY-PHP
·
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
Plain Diff
Browse Files
Authored by
xuqi
9 years ago
Commit
ba578a67f74fddb6bc9b8bd683de131cb539c449
2 parents
5b8fcbe5
9e0e3c4b
Merge branch 'develop' of
http://git.dev.yoho.cn/web/yohobuy
into develop
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
56 additions
and
82 deletions
library/Plugin/DataProcess/ListProcess.php
library/Plugin/Helpers.php
yohobuy/m.yohobuy.com/application/controllers/Home.php
yohobuy/m.yohobuy.com/application/models/Category/Brand.php
yohobuy/m.yohobuy.com/application/modules/Cart/controllers/Index.php
yohobuy/m.yohobuy.com/application/modules/Product/controllers/Recom.php
library/Plugin/DataProcess/ListProcess.php
View file @
ba578a6
<?php
namespace
Plugin\DataProcess
;
use
Plugin\Helpers
;
/**
...
...
@@ -19,8 +20,7 @@ class ListProcess
{
$result
=
array
();
if
(
isset
(
$data
[
'product_list'
]))
{
if
(
isset
(
$data
[
'product_list'
]))
{
$result
[
'new'
]
=
self
::
getProductData
(
$data
[
'product_list'
]);
}
if
(
$returnFilter
&&
isset
(
$data
[
'filter'
]))
{
...
...
@@ -28,7 +28,6 @@ class ListProcess
}
return
$result
;
}
/**
...
...
@@ -47,7 +46,6 @@ class ListProcess
}
return
$products
;
}
/**
...
...
@@ -60,23 +58,21 @@ class ListProcess
public
static
function
getFilterData
(
$data
,
$gender
=
'1,2,3'
)
{
// 过滤条件数据
$filters
=
array
(
'classify'
=>
array
());
$filters
=
array
(
'classify'
=>
array
());
// 返回数据中有没有gender时要添加gender
// $data['gender'] = array('2,3'=>'GIRLS','1,3'=>'BOYS');
$num
=
1
;
foreach
(
$data
as
$key
=>
$val
)
{
if
(
empty
(
$val
))
{
if
(
empty
(
$val
))
{
continue
;
}
if
(
!
is_callable
(
"self::
$key
"
))
{
continue
;
}
$build
=
self
::
$key
(
$val
,
$gender
);
if
(
$num
===
1
)
{
if
(
$num
===
1
)
{
$build
[
'active'
]
=
true
;
}
...
...
@@ -88,7 +84,6 @@ class ListProcess
self
::
sortArrByField
(
$filters
[
'classify'
],
'sort_col'
);
return
$filters
;
}
private
static
function
brand
(
$data
)
...
...
@@ -167,7 +162,7 @@ class ListProcess
foreach
(
$data
as
$key
=>
$one
)
{
$discount
=
array
();
$discount
[
'dataId'
]
=
$key
;
$discount
[
'name'
]
=
$one
[
'name'
]
.
'折商品'
;
$discount
[
'name'
]
=
$one
[
'name'
]
.
'折商品'
;
$result
[
'subs'
][]
=
$discount
;
}
...
...
@@ -200,7 +195,9 @@ class ListProcess
// 处理选中状态
foreach
(
$result
[
'subs'
]
as
&
$val
)
{
$val
[
'dataId'
]
===
$gender
&&
$val
[
'chosed'
]
=
true
;
if
(
$val
[
'dataId'
]
===
$gender
)
{
$val
[
'chosed'
]
=
true
;
}
}
return
$result
;
...
...
@@ -222,23 +219,24 @@ class ListProcess
)
);
$category
=
array
();
foreach
(
$data
as
$one
)
{
$category
=
array
();
$category
[
'dataId'
]
=
isset
(
$one
[
'relation_parameter'
])
?
$one
[
'relation_parameter'
][
'sort'
]
:
0
;
$category
[
'name'
]
=
$one
[
'category_name'
];
/*// 子品类(目前h5不支持二级)
if(isset($one['sub']))
{
$category['subs'] = array();
foreach ($one['sub'] as $single) {
$subitem = array();
$subitem['dataId'] = $single['category_id'];
$subitem['name'] = $single['category_name'];
/* // 子品类(目前h5不支持二级)
if(isset($one['sub']))
{
$category['subs'] = array();
foreach ($one['sub'] as $single) {
$subitem = array();
$subitem['dataId'] = $single['category_id'];
$subitem['name'] = $single['category_name'];
$category['subs'][] = $subitem;
}
}*/
$category['subs'][] = $subitem;
}
} */
$result
[
'subs'
][]
=
$category
;
}
...
...
@@ -262,8 +260,9 @@ class ListProcess
)
);
$price
=
array
();
foreach
(
$data
as
$key
=>
$one
)
{
$price
=
array
();
$price
[
'dataId'
]
=
$key
;
$price
[
'name'
]
=
$one
;
...
...
@@ -289,9 +288,10 @@ class ListProcess
)
);
$size
=
array
();
foreach
(
$data
as
$one
)
{
$size
=
array
();
$size
[
'dataId'
]
=
$one
[
'size_id'
];
$size
[
'dataId'
]
=
$one
[
'size_id'
];
$size
[
'name'
]
=
$one
[
'size_name'
];
$result
[
'subs'
][]
=
$size
;
...
...
@@ -307,7 +307,8 @@ class ListProcess
* @param string $field 字段名称
* @param boolean $desc 时候降序排列,默认为false
*/
private
static
function
sortArrByField
(
&
$array
,
$field
,
$desc
=
false
){
private
static
function
sortArrByField
(
&
$array
,
$field
,
$desc
=
false
)
{
$fieldArr
=
array
();
foreach
(
$array
as
$k
=>
$v
)
{
$fieldArr
[
$k
]
=
$v
[
$field
];
...
...
@@ -315,4 +316,5 @@ class ListProcess
$sort
=
$desc
==
false
?
SORT_ASC
:
SORT_DESC
;
array_multisort
(
$fieldArr
,
$sort
,
$array
);
}
}
...
...
library/Plugin/Helpers.php
View file @
ba578a6
...
...
@@ -201,7 +201,7 @@ class Helpers
$result
[
'product_id'
]
=
$productData
[
'product_id'
];
$result
[
'thumb'
]
=
Images
::
getImageUrl
(
$productData
[
'default_images'
],
$width
,
$height
);
$result
[
'name'
]
=
$productData
[
'product_name'
];
$result
[
'price'
]
=
$productData
[
'market_price'
]
.
'.00'
;
$result
[
'price'
]
=
empty
(
$productData
[
'market_price'
])
?
false
:
$productData
[
'market_price'
]
.
'.00'
;
$result
[
'salePrice'
]
=
$productData
[
'sales_price'
]
.
'.00'
;
$result
[
'is_soon_sold_out'
]
=
(
$productData
[
'is_soon_sold_out'
]
===
'Y'
);
$result
[
'url'
]
=
SITE_MAIN
.
'/product/pro_'
.
$productData
[
'product_id'
]
.
'_'
...
...
yohobuy/m.yohobuy.com/application/controllers/Home.php
View file @
ba578a6
...
...
@@ -19,7 +19,7 @@ class HomeController extends AbstractAction
public
function
indexAction
()
{
// 目前跳到老站
$this
->
go
(
OLD_MAIN
.
'/home'
);
//
$this->go(OLD_MAIN . '/home');
}
}
...
...
yohobuy/m.yohobuy.com/application/models/Category/Brand.php
View file @
ba578a6
...
...
@@ -123,7 +123,9 @@ class BrandModel
$list
=
array
();
$build
=
array
();
foreach
(
$brand
[
'data'
][
'brands'
]
as
$char
=>
$value
)
{
$build
=
array
();
foreach
(
$value
as
$row
)
{
$list
=
array
();
$list
[
'name'
]
=
$row
[
'brand_name'
];
$list
[
'isHot'
]
=
(
$row
[
'is_hot'
]
===
'Y'
)
?
true
:
false
;
$list
[
'isNew'
]
=
(
$row
[
'is_show_new'
]
===
'Y'
)
?
true
:
false
;
...
...
yohobuy/m.yohobuy.com/application/modules/Cart/controllers/Index.php
View file @
ba578a6
...
...
@@ -16,6 +16,6 @@ class IndexController extends AbstractAction
public
function
indexAction
()
{
// 跳转到老版
$this
->
go
(
OLD_MAIN
.
'/cart/index/index'
);
//
$this->go(OLD_MAIN . '/cart/index/index');
}
}
...
...
yohobuy/m.yohobuy.com/application/modules/Product/controllers/Recom.php
View file @
ba578a6
...
...
@@ -36,11 +36,11 @@ class RecomController extends AbstractAction
$gender
=
$this
->
get
(
'gender'
,
'1,3'
);
// 女
if
(
$gender
===
'2,3'
)
{
$recom
=
RecomData
::
mayLike
(
'2,3'
,
2
);
$recom
=
RecomData
::
mayLike
(
'2,3'
,
2
,
$page
);
}
// 男
else
{
$recom
=
RecomData
::
mayLike
(
'1,3'
,
1
);
$recom
=
RecomData
::
mayLike
(
'1,3'
,
1
,
$page
);
}
/* 判断是否有内容返回 */
...
...
@@ -58,10 +58,13 @@ class RecomController extends AbstractAction
foreach
(
$recom
[
'data'
][
'product_list'
]
as
$value
)
{
$data
[
'goods'
][]
=
Helpers
::
formatProduct
(
$value
,
true
,
true
,
true
,
276
,
366
);
}
$this
->
_view
->
display
(
'maylike'
,
$data
);
}
while
(
false
);
echo
' '
;
if
(
isset
(
$data
))
{
$this
->
_view
->
display
(
'maylike'
,
$data
);
}
else
{
echo
' '
;
}
}
/**
...
...
@@ -100,11 +103,13 @@ class RecomController extends AbstractAction
foreach
(
$recom
[
'data'
][
'product_list'
]
as
$value
)
{
$data
[
'goods'
][]
=
Helpers
::
formatProduct
(
$value
,
true
);
}
$this
->
_view
->
display
(
'maylike'
,
$data
);
}
while
(
false
);
echo
' '
;
if
(
isset
(
$data
))
{
$this
->
_view
->
display
(
'maylike'
,
$data
);
}
else
{
echo
' '
;
}
}
/**
...
...
@@ -119,23 +124,22 @@ class RecomController extends AbstractAction
if
(
!
$this
->
isAjax
())
{
break
;
}
/* 创意生活只有一页数据 */
$page
=
$this
->
get
(
'page'
,
1
);
if
(
intval
(
$page
)
>
1
)
{
break
;
}
}
/* 取可能喜欢的数据 */
$recom
=
RecomData
::
mayLikeLifestyle
();
/* 构建人气单品数据 */
if
(
empty
(
$recom
[
'top'
][
'data'
][
'product_list'
]))
{
break
;
}
$data
=
array
();
$build
=
array
();
$build
[
'show'
]
=
true
;
foreach
(
$recom
[
'top'
][
'data'
][
'product_list'
]
as
$value
)
{
...
...
@@ -177,47 +181,13 @@ class RecomController extends AbstractAction
// }
// $data['goodsContainer'][] = $build;
// }
$this
->
_view
->
display
(
'maylikelife'
,
$data
);
}
while
(
false
);
echo
' '
;
if
(
isset
(
$data
))
{
$this
->
_view
->
display
(
'maylikelife'
,
$data
);
}
else
{
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);
// }
// }
}
...
...
Please
register
or
login
to post a comment