Authored by 梁志锋

Merge branch 'develop' of git.dev.yoho.cn:web/yohobuy into develop

framework @ 75bbc3b0
Subproject commit 119c247f5cf929aa1e059e40609bb16dd6b58f05
Subproject commit 75bbc3b075de19f239532f60c5995d06c5f814e2
... ...
<?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);
}
}
... ...
... ... @@ -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'] . '_'
... ...
... ... @@ -7,8 +7,6 @@ var $ = require('jquery');
var $footer = $('#yoho-footer');
var FOOTERHEIGHT = 120; //footer height
function cookie(name) {
var cookies = document.cookie,
cookieVal,
... ... @@ -100,7 +98,7 @@ function rePosFooter() {
return;
}
if ($('body').height() < $(window).height() - FOOTERHEIGHT) {
if ($('body').height() <= $(window).height()) {
$footer.addClass('bottom');
} else {
$footer.removeClass('bottom');
... ... @@ -113,7 +111,7 @@ function rePosFooter() {
var user = getUser();
if ($('body').height() < $(window).height() - FOOTERHEIGHT) {
if ($('body').height() <= $(window).height()) {
$footer.addClass('bottom');
}
... ... @@ -146,7 +144,10 @@ function rePosFooter() {
var uid = getUid();
uid = uid === 0 ? '' : uid;
window._yas(1 * new Date(), '1.0.8', 'yohobuy_m', uid, '');
if (window._yas) {
window._yas(1 * new Date(), '1.0.8', 'yohobuy_m', uid, '');
}
}());
... ...
... ... @@ -86,9 +86,7 @@ likeHammer.on('tap', function(e) {
if (data.code === 200) {
$this.toggleClass('like');
} else if (data.code === 400 || data.code === 412) {
//code:412 用户ID不正确,即未登录
tip.show('未登录');
location.href = data.data; //未登录跳转登录页面
} else {
tip.show(data.message);
}
... ...
... ... @@ -10,6 +10,7 @@ var $ = require('jquery'),
$mobileWrap = $('.mobile-wrap'),
$overlay = $('.overlay'),
$sideNav = $('.side-nav'),
$subNav = $('.sub-nav'),
bannerSwiper,
recommendSwiper,
hotBrandsSwiper,
... ... @@ -40,7 +41,7 @@ navHammer.on('tap', function(event) {
//设置boy高宽,页面不能上下滑动
$('body').css({
height: $(window).height(),
width: '100%',
width: $(window).width(),
overflow: 'hidden'
});
... ... @@ -48,8 +49,7 @@ navHammer.on('tap', function(event) {
return false;
});
mobileWrapHammer = new Hammer($('.mobile-wrap')[0]);
mobileWrapHammer.on('tap', function(e) {
function hideSideBar() {
if ($mobileWrap.hasClass('menu-open')) {
$mobileWrap.removeClass('menu-open');
$overlay.css('opacity', 0);
... ... @@ -62,28 +62,40 @@ mobileWrapHammer.on('tap', function(e) {
setTimeout(function() {
$('.overlay').hide();
}, 300);
e.srcEvent.stopPropagation();
return false;
}
}
mobileWrapHammer = new Hammer($('.mobile-wrap')[0]);
mobileWrapHammer.on('tap', function(e) {
hideSideBar();
e.srcEvent.stopPropagation();
return false;
});
//点击一级导航,弹出二级导航
$sideNav.on('touchend', 'li', function () {
$sideNav.on('touchend', 'li', function (e) {
if ($(this).find('.sub-nav').size() > 0) {
$('.sub-nav').removeClass('show');
$(this).find('.sub-nav').addClass('show');
}
return false;
e.stopPropagation();
if (e.target.pathname === location.pathname) {
hideSideBar();
return false;
}
});
//返回一级导航,收起二级导航
$('.sub-nav').each(function () {
$subNav.each(function () {
$(this).find('li').eq(0).on('touchend', function (e) {
$('.sub-nav').removeClass('show');
e.stopPropagation();
return false;
});
}).on('touchend', function() {
$('.sub-nav').find('li').removeClass('current');
}).on('touchend', function(e) {
if (e.currentTarget !== e.target) {
$subNav.find('li').removeClass('current');
}
});
//头部banner轮播
... ...
... ... @@ -104,6 +104,8 @@ function initFilter(opt) {
var $this = $(e.target),
$cur;
e.preventDefault();//防止透点
if ($this.closest('.filter-body').length > 0) {
$cur = $this.closest('.sub-item');
if ($cur.length > 0) {
... ...
... ... @@ -401,7 +401,7 @@ if ($brandHeader.length > 0) {
if (data.code === 200) {
$this.toggleClass('coled');
} else if (data.code === 400 || data.code === 412) {
tip.show('未登录');
location.href = data.data;//未登录跳转登录页
} else {
tip.show(data.message);
}
... ...
... ... @@ -72,9 +72,10 @@
height: 158rem / $pxConvertRem;
.img-box {
display: table-cell;
vertical-align: middle;
width: 100%;
height: 100%;
height: 158rem / $pxConvertRem;
}
}
}
... ...
.side-nav {
// display: none;
display: block;
background: #fff;
position: fixed;
top: 0;
right: 100rem / $pxConvertRem;
bottom: 0;
left: 0;
z-index: 1;
// left: 0;
right: 640rem / $pxConvertRem;
width: 540rem / $pxConvertRem;
z-index: -1;
overflow: hidden;
@include transform(translateX(-540rem / $pxConvertRem));
@include transition(all .3s ease-out);
@include transition(right .3s);
ul {
background: #f0f0f0;
... ... @@ -107,8 +107,8 @@
}
.side-nav.on {
// display: block;
@include transform(translateX(0rem / $pxConvertRem));
right: 100rem / $pxConvertRem;
z-index: 3;
}
.sub-nav {
... ... @@ -117,10 +117,9 @@
bottom: 0;
top: 0;
left: 0;
// right: 100rem / $pxConvertRem;
width: 100%;
width: 540rem / $pxConvertRem;
background: #fff !important;
// z-index: 2;
overflow: hidden;
@include transform(translateX(540rem / $pxConvertRem));
@include transition(transform 0.3s);
... ...
.search-page {
.search-input {
position: relative;
padding: 7px 46px 7px 15px;
padding: 7px 98px 7px 15px;
background: #f8f8f8;
.search-icon {
... ... @@ -16,7 +16,7 @@
height: 30px;
width: 100%;
border-radius: 15px;
text-indent: 26px;
padding: 0 26px;
background: #fff;
border: none;
}
... ... @@ -41,6 +41,10 @@
.search-items {
padding: 20px 10px;
a {
color: #000;
}
h3 {
font-size: 12px;
margin-bottom: 10px;
... ...
... ... @@ -184,10 +184,19 @@
color: #999;
}
.nav-txt {
display: inline-block;
height: 100%;
box-sizing: border-box;
}
.active > a {
border-bottom: 2px solid #000;
color: #000;
.nav-txt {
border-bottom: 2px solid #000;
}
.iconfont {
color: #999;
... ...
... ... @@ -15,18 +15,6 @@
<div class="swiper-pagination"></div>
</div>
{{# authorInfo}}
<div id="author-infos" class="editor-header clearfix" data-id={{id}}>
<div class="avatar">
<img src="{{avatar}}">
</div>
<div class="text">
<p class="name">{{name}}</p>
<p class="info">{{info}}</p>
</div>
</div>
{{/ authorInfo}}
<ul id="guang-nav" class="guang-nav clearfix">
{{# navs}}
<li class="guang-nav-item {{#focus}}focus{{/focus}}" data-type={{typeId}}>
... ...
{{> layout/header}}
<div class="guang-list-page guang-page yoho-page">
{{# guang}}
{{# author}}
{{# authorInfo}}
<div id="author-infos" class="editor-header clearfix" data-id={{id}}>
<div class="avatar">
<img src="{{avatar}}">
... ... @@ -11,7 +11,7 @@
<p class="info">{{info}}</p>
</div>
</div>
{{/ author}}
{{/ authorInfo}}
<div id="info-list" class="info-list">
{{# infos}}
... ...
... ... @@ -27,16 +27,4 @@
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<script type="text/javascript">
(function(w,d,s,j,f){
w['YohoAcquisitionObject']=f;
w[f]=function(){w[f].p=arguments;};
var a=d.createElement(s);
var m=d.getElementsByTagName(s)[0];
a.async=1;
a.src=j;
m.parentNode.insertBefore(a,m);
})(window,document,'script','http://cdn.yoho.cn/yas-jssdk/1.0.8/yas.js','_yas');
</script>
\ No newline at end of file
... ...
... ... @@ -20,7 +20,20 @@
<script>seajs.config({base: 'http://localhost:8000/'});</script>
{{/if}}
{{> layout/analysis}}
<script type="text/javascript">
(function(w,d,s,j,f){
w['YohoAcquisitionObject']=f;
w[f]=function(){w[f].p=arguments;};
var a=d.createElement(s);
var m=d.getElementsByTagName(s)[0];
a.async=1;
a.src=j;
m.parentNode.insertBefore(a,m);
})(window,document,'script','http://cdn.yoho.cn/yas-jssdk/1.0.8/yas.js','_yas');
</script>
{{> layout/use}}
{{> layout/analysis}}
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -52,13 +52,13 @@
<ul id="list-nav" class="list-nav clearfix">
<li class="new active">
<a href="javascript:void(0);">
最新
<span class="nav-txt">最新</span>
<span class="iconfont cur">&#xe616;</span>
</a>
</li>
<li class="price">
<a href="javascript:void(0);">
价格
<span class="nav-txt">价格</span>
<span class="icon">
<i class="iconfont up">&#xe615;</i>
<i class="iconfont down cur">&#xe616;</i>
... ... @@ -67,7 +67,7 @@
</li>
<li class="discount">
<a href="javascript:void(0);">
折扣
<span class="nav-txt">折扣</span>
<span class="icon">
<i class="iconfont up">&#xe615;</i>
<i class="iconfont down cur">&#xe616;</i>
... ... @@ -76,7 +76,7 @@
</li>
<li class="filter">
<a href="javascript:void(0);">
筛选
<span class="nav-txt">筛选</span>
<span class="iconfont">&#xe613;</span>
</a>
</li>
... ...
... ... @@ -19,7 +19,7 @@ class HomeController extends AbstractAction
public function indexAction()
{
// 目前跳到老站
$this->go(OLD_MAIN . '/home');
// $this->go(OLD_MAIN . '/home');
}
}
... ...
... ... @@ -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;
... ...
... ... @@ -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');
}
}
... ...
... ... @@ -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);
// }
// }
}
... ...