Authored by 梁志锋

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

framework @ 75bbc3b0
Subproject commit 119c247f5cf929aa1e059e40609bb16dd6b58f05
Subproject commit 75bbc3b075de19f239532f60c5995d06c5f814e2
... ...
... ... @@ -15,6 +15,7 @@ namespace Action;
use Yaf\Controller_Abstract;
use Yaf\Dispatcher;
use Plugin\Cache;
use Plugin\Helpers;
class AbstractAction extends Controller_Abstract
{
... ... @@ -327,6 +328,24 @@ class AbstractAction extends Controller_Abstract
if (!empty($homeUrl)) {
$header['navHome'] = $homeUrl;
}
// 根据COOKIE记录的频道进行导航定位
$channel = Helpers::getChannelByCookie();
switch ($channel) {
default:
case 1:
$header['boys'] = true;
break;
case 2:
$header['girls'] = true;
break;
case 3:
$header['kids'] = true;
break;
case 4:
$header['lifeStyle'] = true;
break;
}
$this->_view->assign('pageHeader', $header);
}
... ...
... ... @@ -67,14 +67,43 @@ class RecomData
*/
public static function mayLikeLifestyle($page = 1, $limit = 50)
{
$param = Yohobuy::param();
$param['method'] = 'app.search.lifeStyle';
$param['page'] = $page;
$param['limit'] = $limit;
$param['yh_channel'] = '4';
$param['client_secret'] = Sign::getSign($param);
// $param = Yohobuy::param();
// $param['method'] = 'app.search.lifeStyle';
// $param['page'] = $page;
// $param['limit'] = $limit;
// $param['yh_channel'] = '4';
// $param['client_secret'] = Sign::getSign($param);
//
// return Yohobuy::get(Yohobuy::API_URL, $param);
// 人气单品
$param = array(
array(
'stocknumber' => 1,
'status' => 1,
'order' => 's_n_desc',
'viewNum' => $limit,
'msort' => '10',
),
'N', false
);
$result['top'] = Yohobuy::yarClient(Yohobuy::SERVICE_URL . '/search/service/v1/product', 'search', $param, 3600); // 缓存1小时
return Yohobuy::get(Yohobuy::API_URL, $param);
// 新品到着
$param = array(
array('status' => 1, 'stocknumber' => 1, 'gender' => ''),
array(
array('misort' => 103, 'viewNum' => 10), //数码3c
array('misort' => 266, 'viewNum' => 10), //居家
array('misort' => 280, 'viewNum' => 10), //玩具娱乐
array('misort' => 101, 'viewNum' => 10), //办公文具
array('misort' => 259, 'viewNum' => 10), //美妆
),
false
);
$result['new'] = Yohobuy::yarClient(Yohobuy::SERVICE_URL . '/search/service/v1/product', 'searchBySortList', $param, 3600); // 缓存1小时
return $result;
}
}
... ...
... ... @@ -17,7 +17,19 @@ use Api\Sign;
class SearchData
{
/**
* 阿里云外网
*
* @var string
*/
protected static $_searchurl = 'http://101.200.31.165/yohosearch/search.json';
// /**
// * 阿里云内网
// *
// * @var string
// */
// protected static $_searchurl = 'http://100.98.132.63/yohosearch/search.json';
/**
* 模糊搜索提供的关键词
... ...
... ... @@ -8,7 +8,6 @@ var $ = require('yoho.zepto'),
Swiper = require('yoho.iswiper');
var info = require('./info'),
setLazyLoadAndMellipsis = info.setLazyLoadAndMellipsis,
loadMore = info.loadMore;
var $loadMoreInfo = $('#load-more-info');
... ... @@ -45,10 +44,11 @@ info.initInfosEvt($infoList);
var gender = $('#gender').val();
$nav.children('.guang-nav-item').each(function() {
var type = $(this).data('type');
var type = $(this).data('type'),
focus = $(this).hasClass('focus');
state[type] = {
page: 1,
page: focus ? 1 : 0,
gender: gender,
type: type,
end: false
... ... @@ -65,6 +65,9 @@ $nav.delegate('.guang-nav-item', 'tap', function() {
return;
}
$curNav = $this;
curType = $this.data('type');
index = $this.index();
$this.addClass('focus');
... ... @@ -75,11 +78,7 @@ $nav.delegate('.guang-nav-item', 'tap', function() {
$content = $infos.eq(index);
$content.removeClass('hide');
//lazyload & mellipsis
setLazyLoadAndMellipsis($content.children('.guang-info'));
$curNav = $this;
curType = $this.data('type');
loadMore($content, state[curType]);
//重置当前Tab的load-more
if (state[curType].end) {
... ... @@ -93,6 +92,6 @@ $nav.delegate('.guang-nav-item', 'tap', function() {
$(document).scroll(function() {
if ($(window).scrollTop() + winH >= $(document).height() - loadMoreH) {
loadMore($infos, state[curType]);
loadMore($infos.not('hide'), state[curType]);
}
});
\ No newline at end of file
... ...
... ... @@ -9,12 +9,13 @@ var $ = require('yoho.zepto'),
lazyLoad = require('yoho.zeptolazyload');
var tip = require('../plugin/tip');
var loading = require('../plugin/loading');
var $loadMoreInfo = $('#load-more-info');
var $loading = $(''),
$noMore = $('');
var loading = false;
var searching = false;
ellipsis.init();
... ... @@ -84,7 +85,7 @@ function initInfosEvt($container) {
* 资讯LoadMore
*/
function loadMore($container, opt) {
if (loading) {
if (searching) {
return;
}
... ... @@ -92,7 +93,13 @@ function loadMore($container, opt) {
return;
}
loading = true;
if (opt.page === 0) {
//显示loading
loading.showLoadingMask();
}
searching = true;
$.ajax({
type: 'GET',
url: ' /guang/index/page',
... ... @@ -100,7 +107,7 @@ function loadMore($container, opt) {
success: function(data) {
if (data === ' ') {
opt.end = true;
loading = false;
searching = false;
//
$loading.addClass('hide');
... ... @@ -112,13 +119,17 @@ function loadMore($container, opt) {
setLazyLoadAndMellipsis($container.find('.guang-info'));
if (opt.page === 0) {
loading.hideLoadingMask();
}
opt.page++;
loading = false;
searching = false;
},
error: function() {
tip.show('网络断开连接了~');
loading = false;
searching = false;
}
});
}
... ...
... ... @@ -7,7 +7,7 @@
var $ = require('yoho.zepto');
var $filter = $('.filter-mask, .filter-body');
var $filter = $('.filter-mask');
var $classify = $filter.find('.classify'),
$subClassify = $filter.find('.sub-classify');
... ... @@ -33,9 +33,11 @@ function registerCbFn(cb) {
$classify.children(':first-child').addClass('active'); //T:不在HTML中使用{{#if @first}}active{{/if}}来初始化active为避免sub设置高度时的闪烁
//classify switch
$classify.delegate('.classify-item', 'tap', function() {
$classify.delegate('.classify-item', 'tap', function(e) {
var $this = $(this);
e.stopPropagation();
if ($this.hasClass('active')) {
return;
}
... ... @@ -46,7 +48,7 @@ $classify.delegate('.classify-item', 'tap', function() {
});
//点击Mask隐藏筛选界面
$filter.filter('.filter-mask').tap(function() {
$filter.tap(function() {
hideFilter();
});
... ...
... ... @@ -10,17 +10,14 @@ var $page = $('.yoho-page');
var $loading;
/**
* 初始化loading mask
* @param $container loading容器, position:relative
*/
function initLoadingMask() {
//初始化
(function() {
var html = '<div class="loading-mask hide"><div class="loading"></div></div>';
$page.append(html);
$loading = $page.children('.loading-mask');
}
}());
//显示loading
function showLoadingMask() {
... ... @@ -32,6 +29,5 @@ function hideLoadingMask() {
$loading.addClass('hide');
}
exports.initLoadingMask = initLoadingMask;
exports.showLoadingMask = showLoadingMask;
exports.hideLoadingMask = hideLoadingMask;
\ No newline at end of file
... ...
... ... @@ -209,7 +209,6 @@ function search(opt) {
lazyLoad($('.lazy'));
filter.registerCbFn(search);
loading.initLoadingMask();
//导航栏点击逻辑说明:
//1.点击非active项时切换active状态
... ...
.loading-mask {
position: absolute;
background: rgba(0,0,0,.3);
background: rgba(0,0,0,.1);
top: 0;
bottom: 0;
right: 0;
... ...
{{# filter}}
<div class="filter-mask hide"></div>
<div class="filter-body hide">
<ul class="classify">
{{#each classify}}
<li class="classify-item">
<p class="shower{{#if default}} default{{/if}}">
<span class="title">{{title}}:</span>
{{name}}
</p>
<ul class="sub-classify" data-type={{dataType}}>
{{# subs}}
<li {{#if chosed}}class=chosed{{/if}} data-id={{dataId}}>
{{name}}
<i class="iconfont chosed-icon">&#xe617;</i>
</li>
{{/ subs}}
</ul>
</li>
{{/each}}
</ul>
<div class="filter-mask hide">
<div class="filter-body">
<ul class="classify">
{{#each classify}}
<li class="classify-item">
<p class="shower{{#if default}} default{{/if}}">
<span class="title">{{title}}:</span>
{{name}}
</p>
<ul class="sub-classify" data-type={{dataType}}>
{{# subs}}
<li {{#if chosed}}class=chosed{{/if}} data-id={{dataId}}>
{{name}}
<i class="iconfont chosed-icon">&#xe617;</i>
</li>
{{/ subs}}
</ul>
</li>
{{/each}}
</ul>
</div>
</div>
{{/ filter}}
\ No newline at end of file
... ...
... ... @@ -91,7 +91,82 @@ class IndexModel
$data['guang']['gender'] = $gender;
$category = array();
return $data;
}
/**
* 获取逛首页分类内容列表
*
* @param string $gender "1,3"表示男, "2,3"表示女
* @param int channel APP客户端标识 1表示男,2:表示女,3:潮童,4:创意生活
* @param int type 分类ID 0:最新,1:话题,2:搭配,3:潮人,4:潮品,5:小贴士
* @param int $uid 用户ID
* @param string $udid 客户端唯一标识
* @param int $page 分页第几页, 默认第1页
* @return array
*/
public static function getArticle($gender, $type, $uid, $udid, $page = 1)
{
// 逛首页的分类名称列表
$category = ListData::category();
$article = array();
switch ($gender) {
case '1,3': // 男
$article = ListData::article('1,3', $type, $uid, $udid, $page);
break;
case '2,3': // 女
$article = ListData::article('2,3', $type, $uid, $udid, $page);
break;
default: // 其它所有
$article = ListData::article('1,2,3', $type, $uid, $udid, $page);
break;
}
$data = array();
$build = array();
// 模板中使用JS的标识
$data['guangHome'] = true;
// 顶部的分类列表
if (!empty($category['data'])) {
foreach ($category['data'] as $value) {
$build = array();
$build['typeId'] = $value['id'];
$build['type'] = $value['name'];
$build['focus'] = ($value['id'] == $type);
$data['navs'][] = $build;
$data['guang']['infos'][] = array(
'show' => $build['focus'],
'info' => array(),
);
}
}
// 广告列表
if (!empty($article['data']['list']['adlist'])) {
foreach ($article['data']['list']['adlist'] as $value) {
$build = array();
$build['url'] = Helpers::getFilterUrl($value['url']);
$build['img'] = Helpers::getImageUrl($value['src'], 830, 327);
$data['guang']['swiper'][] = $build;
}
}
// 内容列表
if (!empty($article['data']['list']['artlist'])) {
$type = intval($type);
foreach ($article['data']['list']['artList'] as $value) {
$data['guang']['infos'][$type]['info'] = Helpers::formatArticle($value, true, false, true);
}
}
$category = array();
$article = array();
return $data;
}
... ...
... ... @@ -35,7 +35,7 @@ class IndexController extends AbstractAction
// $this->setNavSide('all');
// }
$this->_view->display('index', Guang\IndexModel::getArticleGroup($gender, $type, $uid, $udid));
$this->_view->display('index', Guang\IndexModel::getArticle($gender, $type, $uid, $udid));
}
/**
... ... @@ -175,7 +175,7 @@ class IndexController extends AbstractAction
/* 获取资讯文章列表 */
$uid = $this->getUid();
$udid = $this->getUdid();
$page = intval($page) + 1;
//$page = intval($page) + 1;
$article = ListData::article($gender, $sortId, $uid, $udid, $page, $tag, $authorId);
if (empty($article['data']['list']['artList'])) {
break;
... ...
... ... @@ -31,6 +31,11 @@ class InfoController extends AbstractAction
$this->error();
}
// WAP上设置头部导航
if (null === $this->get('openby:yohobuy', null)) {
$this->setNavHeader('逛', true, SITE_MAIN);
}
$data = array();
$data['guangDetail'] = true; // 模板中使用JS的标识
$data['guang']['id'] = $id;
... ...
... ... @@ -85,7 +85,7 @@ class IndexController extends AbstractAction
if (!isset($brandIds[0])) {
$this->error();
}
// 当前的登录用户UID
$uid = $this->getUid();
// 存标题信息
... ... @@ -107,6 +107,7 @@ class IndexController extends AbstractAction
'gender' => FILTER_DEFAULT,
'p_d' => FILTER_DEFAULT,), false);
$condition['brand'] = $brandIds[0];
if (isset($condition['gender'])) {
$condition['gender'] = rawurldecode($condition['gender']);
}
... ... @@ -118,7 +119,7 @@ class IndexController extends AbstractAction
$data['goodList']['brandWay'] = false;
$data['goodList']['search']['default'] = $query;
$data['goodList']['search']['url'] = Helpers::url('', null, 'search');
}
}
// 品牌一览过来的展示品牌介绍和LOGO
else {
$data['brandHome'] = Product\ListModel::getBrandIntro($brandIds[0], $uid, $title);
... ...
... ... @@ -47,8 +47,8 @@ class RecomController extends AbstractAction
if (empty($recom['data']['product_list'])) {
break;
}
/* 判断是否已没有数据 */
/* 判断是否已没有数据 */
if (intval($page) > intval($recom['data']['page_total'])) {
break;
}
... ... @@ -59,7 +59,6 @@ class RecomController extends AbstractAction
$data['goods'][] = Helpers::formatProduct($value, true);
}
$this->_view->display('maylike', $data);
} while (false);
echo ' ';
... ... @@ -120,32 +119,65 @@ class RecomController extends AbstractAction
if (!$this->isAjax()) {
break;
}
/* 创意生活只有一页数据 */
$page = $this->get('page', 1);
if (intval($page) > 1) {
break;
}
/* 取可能喜欢的数据 */
$recom = RecomData::mayLikeLifestyle();
if (empty($recom['data']['product_list'])) {
/* 构建人气单品数据 */
if (empty($recom['top']['data']['product_list'])) {
break;
}
/* 构建模板需要的商品数据 */
$data = array();
$build = array();
$build['show'] = true;
foreach ($recom['top']['data']['product_list'] as $value) {
$build['goods'][] = Helpers::formatProduct($value, true, false, false);
}
$data['goodsContainer'][] = $build;
/* 构建新品到着数据 */
if (empty($recom['new']['data']['product_list'])) {
break;
}
$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;
$build['show'] = true;
foreach ($recom['new']['data']['product_list'] as $value) {
$build['goods'][] = Helpers::formatProduct($value, true, false, false);
}
$data['goodsContainer'][] = $build;
// 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);
... ...
... ... @@ -5,7 +5,7 @@ define('SITE_MAIN', 'http://buy.test.yoho.cn'); // 网站主域名
define('OLD_MAIN', 'http://m.yohobuy.com'); // 网站旧域名
define('COOKIE_DOMAIN', '.test.yoho.cn'); // COOKIE作用域
define('SUB_DOMAIN', '.test.yoho.cn'); // 子域名后缀
define('USE_CACHE', true); // 缓存的开关
define('USE_CACHE', false); // 缓存的开关
define('APPLICATION_PATH', dirname(__DIR__)); // 应用目录
define('ROOT_PATH', dirname(dirname(APPLICATION_PATH))); // 根目录
defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'testing');
... ...