Authored by xuqi

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

... ... @@ -32,14 +32,14 @@ class IndexData
* @param string $client_type
* @return array
*/
public static function getResourceData($content_code, $client_type = 'android')
public static function getResourceData($content_code, $client_type = 'web')
{
// 构建必传参数
$params = Yohobuy::param();
$params['content_code'] = $content_code;
$params['client_type'] = $client_type;
$params['private_key'] = Yohobuy::$privateKeyList[$client_type];
$params['client_secret'] = Sign::getSign($params);
return Yohobuy::get(Yohobuy::SERVICE_URL . self::URL_OPERATIONS_RESOURCE_GET, $params);
}
}
\ No newline at end of file
... ...
... ... @@ -19,8 +19,8 @@ class SaleData
* 获取专区信息
* @param $specialId 专区ID
*/
public static function getSpecial($specialsaleId) {
public static function getSpecial($specialsaleId)
{
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_SALE_SPECIAL, 'getOneSpecial', array($specialsaleId));
}
... ...
... ... @@ -19,12 +19,9 @@ class SearchData extends \LibModels\Wap\Product\SearchData
case 'release':
if($type == 'sort'){
return 'http://100.98.132.63/yohosearch/sortgroup.json';
}elseif($type == 'discount'){
return 'http://100.98.132.63/yohosearch/discount.json';
}elseif($type == 'recent'){
return 'http://100.98.132.63/yohosearch/recent.json';
}elseif($type == 'review'){
}
elseif($type == 'suggest'){
return 'http://100.98.132.63/yohosearch/suggest.json';
}
return 'http://100.98.132.63/yohosearch/search.json';
case 'test':
... ... @@ -34,14 +31,10 @@ class SearchData extends \LibModels\Wap\Product\SearchData
if($type == 'sort'){
return 'http://101.200.31.165/yohosearch/sortgroup.json';
}
elseif($type == 'discount'){
return 'http://101.200.31.165/yohosearch/discount.json';
}
elseif($type == 'recent'){
return 'http://101.200.31.165/yohosearch/recent.json';
}elseif($type == 'review'){
return 'http://itemapi.yohobuy.com/item/item/recentreview';
elseif($type == 'suggest'){
return 'http://101.200.31.165/yohosearch/suggest.json';
}
return 'http://101.200.31.165/yohosearch/search.json';
}
}
... ... @@ -116,36 +109,19 @@ class SearchData extends \LibModels\Wap\Product\SearchData
}
/**
* 获取折扣区间
*/
public static function getDiscount(){
return Yohobuy::get(self::getUrl('discount'));
}
/**
* 获取最新上架
*/
public static function recentShelve(){
return Yohobuy::get(self::getUrl('recent'));
}
/**
* 搜索品牌店铺信息
* @param array $params 参数
* 获取搜索提示
* @param $param
* @param $cache
* @return array
*/
public static function getShop(array $params)
{
return Yohobuy::get(self::$shopsUrl,$params);
}
/**
* 获取最近浏览记录
* @param int $limit
* @return json
*/
public static function getRecentReview($limit = 0)
public static function getSuggest($param, $cache = false)
{
if (empty($param['query'])) {
return array();
}
if (empty($param['size'])) {
$param['size'] = 10;
}
return Yohobuy::get(self::getUrl('suggest'),$param, $cache);
}
}
\ No newline at end of file
... ...
<?php
namespace Plugin;
use Plugin\Paging;
use LibModels\Web\Product\BrandData;
use Api\Yohobuy;
use Api\Sign;
/**
* 搜索辅助类
*/
... ... @@ -110,12 +112,16 @@ class HelperSearch
$result['leftContent'][]['allSort'] = isset($data['sort']) ? self::groupSort($data['sort']['sort']) : array();
//一周新品上架
$result['leftContent'][]['newSales'] = isset($data['recent']) ? self::recentShelve($data['recent']['recent']) : array();
//总记录数
//全部折扣
$result['leftContent'][]['allDiscount'] = isset($data['discount']) ? self::getDiscount($data['discount']['discount']) : array();
//品牌banner
$result['brandBanner'] = isset($data['banner']) && isset($data['brand']) ? self::getBannerFormat($data['banner'],$data['brand']) : array();
//总记录数
$result['totalCount'] = $data['product']['total'];
//品牌店铺信息
$result['shopEntry'] = isset($data['shop']) && !empty($data['shop']) ? self::shop($data['shop'], $data['sort']['sort']) : array();
//分页
$result['pager'] = self::pager($result['totalCount'],$options['viewNum']);
$result['pager'] = self::pager($result['totalCount'],$options['viewNum']-1);
//选中条件
if (self::getSelected()) {
$result['filters']['checkedConditions']['conditions'] = self::getSelected();
... ... @@ -1224,6 +1230,36 @@ class HelperSearch
return Yohobuy::httpBuildQuery(self::getUrl('recent'), $param);
}
/**
* 并行调接口url获取(获取品牌数据)
*/
public static function getBrandUrl($customOptions = array())
{
// 构建必传参数
$param = Yohobuy::param();
$param['brand_id'] = $customOptions['brandId'];
$param['uid'] = $customOptions['uid'];
$param['method'] = 'app.brand.getBrandIntro';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);
}
/**
* 并行调接口url获取(获取品牌banner数据)
*/
public static function getBannerUrl($customOptions = array())
{
// 构建必传参数
$param = Yohobuy::param();
$param['brand_id'] = $customOptions['brandId'];
$param['method'] = 'app.brand.banner';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);
}
/**
* 并行调接口url获取(获取用户浏览记录)
*/
... ... @@ -1292,4 +1328,36 @@ class HelperSearch
return 'http://101.200.31.165/yohosearch/search.json';
}
}
/**
* 获取品牌首页banner条
*
* @return array 品牌banner条数据
*/
public static function getBannerFormat($banner, $brand)
{
// 根据品牌Id获取品牌banner图
if (isset($banner['banner'])) {
$bannerImg = Helpers::getImageUrl($banner['banner'], '', 150);
}
$is_favorite = false;
$shopName = false;
if(isset($brand)){
// 获取是否收藏
if ($brand['is_favorite'] == 'Y') {
$is_favorite = true;
} elseif ($brand['is_favorite'] == 'N') {
$is_favorite = false;
}
}
// 返回banner数据
return array(
'bannerHeight' => '150',
'coled' => $is_favorite,
'banner' => $bannerImg
);
}
}
... ...
... ... @@ -303,6 +303,7 @@ $basicBtnC:#eb0313;
font-size: pxToRem(24px);
float: right;
color: #d0021b;
margin-right: 1.4rem;
h1 {
display: inline-block;
line-height: pxToRem(88px);
... ...
... ... @@ -12,14 +12,14 @@
<script src="http://static.buy.test.yoho.cn/dist/yohobuy/{{version}}/index-debug.js"></script>
{{/if}}
{{#if devEnv}}
<script src="http://localhost:8000/static/js/sea.js?nowrap"></script>
<script src="http://localhost:8001/static/js/sea.js?nowrap"></script>
<script>
seajs.config({
base: 'http://localhost:8000/'
base: 'http://localhost:8001/'
});
</script>
{{/if}}
{{> layout/use}}
{{> layout/analysis}}
</body>
</html>
\ No newline at end of file
</html>
... ...
... ... @@ -5,8 +5,10 @@
<div class="sort-container">
<ul class="sort-child-list new-sale">
<li>
<a href="{{href}}">全部折扣</a>
<span>{{updateNum}}</span>
<h2>
<a href="{{href}}">全部折扣</a>
<span>{{updateNum}}</span>
</h2>
</li>
{{#each list}}
<li {{#if active}}class="active"{{/if}}>
... ...
... ... @@ -1483,308 +1483,308 @@ require("js/product/sort-pager");
require("js/product/product");
});
define("js/product/filter", ["jquery"], function(require, exports, module){
/**
* 商品筛选逻辑
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/12/4
*/
var $ = require("jquery");
var checkUnicode = {
unchecked: '&#xe613;',
checked: '&#xe612;'
},
moreUnicode = {
up: '&#xe610;',
down: '&#xe600;'
};
//品牌相关变量
var $brandDefault = $('.brand .default'),
$brandPanel = $('.brand .brand-panel'),
$brandAttrs = $('.brand .attr'),
$brandMore = $('#brand-more'),
$brandMulti = $('#brand-multi');
var $brandMoreTxt, $brandMoreIcon;
//价格相关变量
var $udPrice = $('.ud-price-range'),
interReg = /^\d+$/,
$limit, $min, $max, $btn;
//分类相关变量
var $sortSub = $('.sort-sub-wrap');
//高级选项相关变量
var $seniorSubWrap = $('.senior-sub-wrap'),
$seniorAttrWrap = $('.senior-attr-wrap');
var seniorHoverTime, hoveredIndex;
//清除checkbox选中状态
function clearChecked($checkbox) {
$checkbox.removeClass('checked').html(checkUnicode.unchecked);
}
//显示更多品牌面板
function brandShowMore() {
$brandDefault.addClass('hide');
$brandPanel.removeClass('hide');
}
//隐藏更多品牌面板
function brandHideMore() {
$brandPanel.addClass('hide');
$brandDefault.removeClass('hide');
}
//url构造&跳转
function uriLoc(attr, val) {
var href = decodeURIComponent(window.location.search),
query = attr + '=' + val,
newHref;
if (href === '') {
newHref = '?' + query;
} else {
newHref = href + '&' + query;
}
window.location.href = newHref;
}
//隐藏高级选项面板
function hideSeniorPanel(index) {
$seniorSubWrap.children('.senior-sub:eq(' + hoveredIndex + ')').addClass('hide');
$seniorAttrWrap.children('.attr:eq(' + hoveredIndex + ')').removeClass('hover');
hoveredIndex = -1;
}
//屏蔽筛选项双击文字选中
$('.filter-box').on('selectstart', '.attr, .brands-index span', function() {
return false;
});
//【分类】
$('.sort-pre').on('click', 'li', function() {
var $this = $(this),
index = $this.index();
$this.siblings('.active').removeClass('active');
$this.addClass('active');
$sortSub.children(':not(.hide)').addClass('hide');
$sortSub.children(':eq(' + index + ')').removeClass('hide');
});
//【品牌】
if ($brandMore.length > 0) {
$brandMoreTxt = $brandMore.children('em');
$brandMoreIcon = $brandMore.children('.iconfont');
}
//【品牌】多选
$brandMulti.click(function() {
if ($brandPanel.css('display') === 'none') {
//显示品牌面板
brandShowMore();
}
$brandPanel.addClass('multi'); //显示出checkbox
$(this).addClass('hide');
});
//【品牌】更多
$brandMore.click(function() {
var $this = $(this);
if ($this.hasClass('more')) {
brandHideMore();
$brandMoreTxt.text('更多');
$brandMoreIcon.html(moreUnicode.down);
} else {
brandShowMore();
$brandMoreTxt.text('收起');
$brandMoreIcon.html(moreUnicode.up);
}
$(this).toggleClass('more');
});
//【品牌】索引
$('.brands-index').on('click', 'span', function() {
var $this = $(this),
index = $this.data('index');
if ($this.index() === 0) {
//全部
$brandAttrs.removeClass('hide');
} else {
$brandAttrs.addClass('hide').filter('[data-index=' + index + ']').removeClass('hide');
}
});
//【品牌】搜索
$('#brand-search-input').keyup(function() {
var val = $(this).val().toLowerCase();
if (val === '') {
$brandAttrs.removeClass('hide');
} else {
$brandAttrs.addClass('hide').filter('[data-key*="' + val + '"]').removeClass('hide');
}
});
//【品牌】多选确定
$('#brand-multi-ok').click(function() {
var val = '';
if ($(this).hasClass('dis')) {
return;
}
$brandPanel.find('.checked').each(function() {
var id = $(this).data('id');
val += (val === '') ? id : (',' + id);
});
uriLoc('brand', val);
});
//【品牌/高级选项】多选取消
$('.multi-select-cancel').click(function() {
var $panel = $(this).closest('.multi');
if ($panel.hasClass('brand-panel')) {
brandHideMore();
$brandMulti.removeClass('hide'); //显示多选按钮
}
$panel.removeClass('multi');
clearChecked($panel.find('.checkbox.checked')); //清除选中状态
});
//【品牌/高级选项】checkbox
$('.check-container').on('click', '.attr', function() {
var $this = $(this),
$check = $this.find('.checkbox'),
$btnOk = $this.parent('.check-container').next('.btns').find('.multi-select-ok');
$check.toggleClass('checked');
if ($check.hasClass('checked')) {
$check.html(checkUnicode.checked);
} else {
$check.html(checkUnicode.unchecked);
}
//更新按钮状态
if ($check.hasClass('checked') ||
$this.siblings('.attr').find('.checked').length > 0) {
$btnOk.removeClass('dis');
} else {
$btnOk.addClass('dis');
}
});
//【品牌/高级选项】当多选时阻止链接默认跳转
$('.brand, .senior').on('click', '.attr > a', function(e) {
if ($(this).closest('.multi').length > 0) {
e.preventDefault();
}
});
//【价格】用户定义价格处理
if ($udPrice.length > 0) {
$limit = $udPrice.find('.limit');
$min = $limit.filter('.min');
$max = $limit.filter('.max');
$btn = $udPrice.find('.price-sure');
//【价格】输入
$limit.keyup(function() {
var min = $.trim($min.val()),
max = $.trim($max.val()),
isMinInt = interReg.test(min),
isMaxInt = interReg.test(max);
if (isMaxInt && (min === '' || isMinInt) ||
isMinInt && (max === '' || isMaxInt)
) {
$btn.removeClass('hide');
} else {
$btn.addClass('hide');
}
});
//【价格】多项查询
$btn.click(function() {
var min = $.trim($min.val()),
max = $.trim($max.val()),
tmp;
//对于min大于max的情况,交换位置
if (min !== '' && max !== '' && +min > +max) {
tmp = max;
max = min;
min = tmp;
}
uriLoc('price', min + ',' + max);
});
}
//【高级选项】鼠标移入显示子项
$seniorAttrWrap.on('mouseenter', '.attr', function() {
var $this = $(this);
var index = $this.index();
$this.addClass('hover').siblings().removeClass('hover');
$seniorSubWrap.children('.senior-sub:eq(' + index + ')').removeClass('hide').siblings().addClass('hide');
}).on('mouseleave', '.attr', function() {
var $this = $(this),
index = $this.index();
hoveredIndex = index;
seniorHoverTime = setTimeout(function() {
hideSeniorPanel();
}, 100);
});
//【高级选项】多选
$('.senior-sub').on('click', '.multi-select', function() {
$(this).closest('.senior-sub').addClass('multi');
}).on('click', '.multi-select-ok', function() {
var $btn = $(this),
$sub = $btn.closest('.senior-sub'),
val = '';
if ($btn.hasClass('dis')) {
return;
}
$sub.find('.checked').each(function() {
var id = $(this).data('id');
val += (val === '') ? id : (',' + id);
});
uriLoc($sub.data('attr'), val);
}).on('mouseenter', function() {
clearTimeout(seniorHoverTime);
}).on('mouseleave', function() {
hideSeniorPanel();
});
/**
* 商品筛选逻辑
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/12/4
*/
var $ = require("jquery");
var checkUnicode = {
unchecked: '&#xe613;',
checked: '&#xe612;'
},
moreUnicode = {
up: '&#xe610;',
down: '&#xe600;'
};
//品牌相关变量
var $brandDefault = $('.brand .default'),
$brandPanel = $('.brand .brand-panel'),
$brandAttrs = $('.brand .attr'),
$brandMore = $('#brand-more'),
$brandMulti = $('#brand-multi');
var $brandMoreTxt, $brandMoreIcon;
//价格相关变量
var $udPrice = $('.ud-price-range'),
interReg = /^\d+$/,
$limit, $min, $max, $btn;
//分类相关变量
var $sortSub = $('.sort-sub-wrap');
//高级选项相关变量
var $seniorSubWrap = $('.senior-sub-wrap'),
$seniorAttrWrap = $('.senior-attr-wrap');
var seniorHoverTime, hoveredIndex;
//清除checkbox选中状态
function clearChecked($checkbox) {
$checkbox.removeClass('checked').html(checkUnicode.unchecked);
}
//显示更多品牌面板
function brandShowMore() {
$brandDefault.addClass('hide');
$brandPanel.removeClass('hide');
}
//隐藏更多品牌面板
function brandHideMore() {
$brandPanel.addClass('hide');
$brandDefault.removeClass('hide');
}
//url构造&跳转
function uriLoc(attr, val) {
var href = decodeURIComponent(window.location.search),
query = attr + '=' + val,
newHref;
if (href === '') {
newHref = '?' + query;
} else {
newHref = href + '&' + query;
}
window.location.href = newHref;
}
//隐藏高级选项面板
function hideSeniorPanel(index) {
$seniorSubWrap.children('.senior-sub:eq(' + hoveredIndex + ')').addClass('hide');
$seniorAttrWrap.children('.attr:eq(' + hoveredIndex + ')').removeClass('hover');
hoveredIndex = -1;
}
//屏蔽筛选项双击文字选中
$('.filter-box').on('selectstart', '.attr, .brands-index span', function() {
return false;
});
//【分类】
$('.sort-pre').on('click', 'li', function() {
var $this = $(this),
index = $this.index();
$this.siblings('.active').removeClass('active');
$this.addClass('active');
$sortSub.children(':not(.hide)').addClass('hide');
$sortSub.children(':eq(' + index + ')').removeClass('hide');
});
//【品牌】
if ($brandMore.length > 0) {
$brandMoreTxt = $brandMore.children('em');
$brandMoreIcon = $brandMore.children('.iconfont');
}
//【品牌】多选
$brandMulti.click(function() {
if ($brandPanel.css('display') === 'none') {
//显示品牌面板
$brandMore.trigger('click');
}
$brandPanel.addClass('multi'); //显示出checkbox
$(this).addClass('hide');
});
//【品牌】更多
$brandMore.click(function() {
var $this = $(this);
if ($this.hasClass('more')) {
brandHideMore();
$brandMoreTxt.text('更多');
$brandMoreIcon.html(moreUnicode.down);
} else {
brandShowMore();
$brandMoreTxt.text('收起');
$brandMoreIcon.html(moreUnicode.up);
}
$(this).toggleClass('more');
});
//【品牌】索引
$('.brands-index').on('click', 'span', function() {
var $this = $(this),
index = $this.data('index');
if ($this.index() === 0) {
//全部
$brandAttrs.removeClass('hide');
} else {
$brandAttrs.addClass('hide').filter('[data-index=' + index + ']').removeClass('hide');
}
});
//【品牌】搜索
$('#brand-search-input').keyup(function() {
var val = $(this).val().toLowerCase();
if (val === '') {
$brandAttrs.removeClass('hide');
} else {
$brandAttrs.addClass('hide').filter('[data-key*="' + val + '"]').removeClass('hide');
}
});
//【品牌】多选确定
$('#brand-multi-ok').click(function() {
var val = '';
if ($(this).hasClass('dis')) {
return;
}
$brandPanel.find('.checked').each(function() {
var id = $(this).data('id');
val += (val === '') ? id : (',' + id);
});
uriLoc('brand', val);
});
//【品牌/高级选项】多选取消
$('.multi-select-cancel').click(function() {
var $panel = $(this).closest('.multi');
if ($panel.hasClass('brand-panel')) {
$brandMulti.removeClass('hide'); //显示多选按钮
$brandMore.trigger('click');
}
$panel.removeClass('multi');
clearChecked($panel.find('.checkbox.checked')); //清除选中状态
});
//【品牌/高级选项】checkbox
$('.check-container').on('click', '.attr', function() {
var $this = $(this),
$check = $this.find('.checkbox'),
$btnOk = $this.parent('.check-container').next('.btns').find('.multi-select-ok');
$check.toggleClass('checked');
if ($check.hasClass('checked')) {
$check.html(checkUnicode.checked);
} else {
$check.html(checkUnicode.unchecked);
}
//更新按钮状态
if ($check.hasClass('checked') ||
$this.siblings('.attr').find('.checked').length > 0) {
$btnOk.removeClass('dis');
} else {
$btnOk.addClass('dis');
}
});
//【品牌/高级选项】当多选时阻止链接默认跳转
$('.brand, .senior').on('click', '.attr > a', function(e) {
if ($(this).closest('.multi').length > 0) {
e.preventDefault();
}
});
//【价格】用户定义价格处理
if ($udPrice.length > 0) {
$limit = $udPrice.find('.limit');
$min = $limit.filter('.min');
$max = $limit.filter('.max');
$btn = $udPrice.find('.price-sure');
//【价格】输入
$limit.keyup(function() {
var min = $.trim($min.val()),
max = $.trim($max.val()),
isMinInt = interReg.test(min),
isMaxInt = interReg.test(max);
if (isMaxInt && (min === '' || isMinInt) ||
isMinInt && (max === '' || isMaxInt)
) {
$btn.removeClass('hide');
} else {
$btn.addClass('hide');
}
});
//【价格】多项查询
$btn.click(function() {
var min = $.trim($min.val()),
max = $.trim($max.val()),
tmp;
//对于min大于max的情况,交换位置
if (min !== '' && max !== '' && +min > +max) {
tmp = max;
max = min;
min = tmp;
}
uriLoc('price', min + ',' + max);
});
}
//【高级选项】鼠标移入显示子项
$seniorAttrWrap.on('mouseenter', '.attr', function() {
var $this = $(this);
var index = $this.index();
$this.addClass('hover').siblings().removeClass('hover');
$seniorSubWrap.children('.senior-sub:eq(' + index + ')').removeClass('hide').siblings().addClass('hide');
}).on('mouseleave', '.attr', function() {
var $this = $(this),
index = $this.index();
hoveredIndex = index;
seniorHoverTime = setTimeout(function() {
hideSeniorPanel();
}, 100);
});
//【高级选项】多选
$('.senior-sub').on('click', '.multi-select', function() {
$(this).closest('.senior-sub').addClass('multi');
}).on('click', '.multi-select-ok', function() {
var $btn = $(this),
$sub = $btn.closest('.senior-sub'),
val = '';
if ($btn.hasClass('dis')) {
return;
}
$sub.find('.checked').each(function() {
var id = $(this).data('id');
val += (val === '') ? id : (',' + id);
});
uriLoc($sub.data('attr'), val);
}).on('mouseenter', function() {
clearTimeout(seniorHoverTime);
}).on('mouseleave', function() {
hideSeniorPanel();
});
});
define("js/product/sort-pager", ["jquery"], function(require, exports, module){
... ... @@ -2658,6 +2658,13 @@ require("js/common/logo-brand");
require("js/common/accordion");
$(document).on('mouseenter', '.imgopacity a img', function() {
$(this).css('opacity', 0.8);
});
$(document).on('mouseout', '.imgopacity a img', function() {
$(this).css('opacity', 1);
});
if (homePage === 'brands') {
require("js/home/brands");
}
... ... @@ -3586,235 +3593,235 @@ $brand.hover(function() {
});
define("js/common/new-arrivls", ["jquery","lazyload","handlebars","source-map"], function(require, exports, module){
var $ = require("jquery"),
lazyload = require("lazyload");
var Handlebars = require("handlebars");
function InfiniteLoad(options) {
var defaults = {
index: 0,
isload: true,//是否正在加载
isrun: true,//判断是否执行
offset: {
height: null,
width: null
}
};
this.registerEvent = {
before: [],
change: [],
after: []
};
this.options = $.extend(true, {}, defaults, options);
return this;
}
InfiniteLoad.prototype.on = function(name, callback) {
var g = this;
var _e = g.registerEvent[name];
if (_e) {
_e.push(callback);
}
return _e;
};
InfiniteLoad.prototype.exect = function(key, params) {
var g = this;
var e;
if (g.registerEvent[key] && g.registerEvent[key].length > 0) {
for (e in g.registerEvent[key]) {
if (g.registerEvent[key].hasOwnProperty(e)) {
g.registerEvent[key][e](params);
}
}
}
};
InfiniteLoad.prototype.init = function() {
var g = this;
var p = this.options;
function __loadMore() {
if (p.isrun && p.isload && g.__directionCalculation()) {
p.isload = false;
p.index++;
g.exect('after', p);
}
g.exect('change', p);
}
g.exect('before', p);
$(window).scroll(__loadMore);
};
InfiniteLoad.prototype.emit = function() {
var p = this.options;
p.isload = true;
};
InfiniteLoad.prototype.stop = function() {
var p = this.options;
p.isrun = false;
p.isload = false;
};
InfiniteLoad.prototype.__directionCalculation = function() {
var p = this.options;
if (p.offset.height && p.offset.height() > 0 && $(window).scrollTop() + $(window).height() >= p.offset.height()) {
return true;
}
return false;
};
module.exports = function(data) {
var $container = $('#newarrivals .goods-container');
var $load = $('.loading a');
var load = new InfiniteLoad({
index: 1,
isload: false,
offset: {
height: function() {
return parseFloat($container.offset().top) + parseFloat($container.height()) - 200;
}
}
});
var loadAjax;
var url = data.url,
count = data.count,
rows = data.rows;
data.pageIndex = 0;
delete data.url;
delete data.count;
delete data.rows;
loadAjax = function(url, data, count) {
var options = {
type: 'POST',
url: url,
success: function(result) {
var code = result.code;
var myTemplate,len,pos;
if (code === 200) {
len = result.goods.length % count;
pos = result.goods.length - len - 1;
result.goods.splice(pos, len);
myTemplate = Handlebars.compile(load.tpl);
$container.append(myTemplate(result.goods));
data.pageIndex = data.pageIndex + result.goods.length;
//懒加载插件貌似有点问题,图片先直接展示
lazyload($container.find('img.lazy'));
load.emit();
} else {
load.stop();
$load.html('查看更多');
}
},
error: function() {
load.stop();
$load.html('网络断开连接了~');
}
};
options.data = data;
$.ajax(options);
};
load.on('after', function(p) {
data.pageCount = count * rows[1];
loadAjax(url, data);
});
load.on('before', function(p) {
load.tpl = '{{#each this}}';
load.tpl += '<div class="good-info" data-skn="{{skn}}">';
load.tpl += ' <div class="tag-container clearfix">';
load.tpl += ' {{# tags}}';
load.tpl += ' {{# isNew}}';
load.tpl += ' <span class="good-tag new-tag">NEW</span>';
load.tpl += ' {{/ isNew}}';
load.tpl += ' {{# isReNew}}';
load.tpl += ' <span class="good-tag renew-tag">再到着</span>';
load.tpl += ' {{/ isReNew}}';
load.tpl += ' {{# isSale}}';
load.tpl += ' <span class="good-tag sale-tag">SALE</span>';
load.tpl += ' {{/ isSale}}';
load.tpl += ' {{# isNewFestival}}';
load.tpl += ' <span class="good-tag new-festival-tag">新品节</span>';
load.tpl += ' {{/ isNewFestival}}';
load.tpl += ' {{# isLimit}}';
load.tpl += ' <span class="good-tag limit-tag">限量商品</span>';
load.tpl += ' {{/ isLimit}}';
load.tpl += ' {{# isYearEndPromotion}}';
load.tpl += ' <span class="good-tag yep-tag">年终大促</span>';
load.tpl += ' {{/ isYearEndPromotion}}';
load.tpl += ' {{# isYearMidPromotion}}';
load.tpl += ' <span class="good-tag ymp-tag">年中热促</span>';
load.tpl += ' {{/ isYearMidPromotion}}';
load.tpl += ' {{/ tags}}';
load.tpl += ' </div>';
load.tpl += ' <div class="good-detail-img">';
load.tpl += ' <a class="good-thumb" href="{{url}}" target= "_blank">';
load.tpl += ' <img class="lazy" data-original="{{thumb}}">';
load.tpl += ' </a>';
load.tpl += ' {{# isFew}}';
load.tpl += ' <p class="few-tag">即将售罄</p>';
load.tpl += ' {{/ isFew}}';
load.tpl += ' {{#if showColBtn}}';
load.tpl += ' <span class="col-btn iconfont{{#if coled}} coled{{/if}}">&#xe616;</span>';
load.tpl += ' {{/if}}';
load.tpl += ' </div>';
load.tpl += ' <div class="good-detail-text">';
load.tpl += ' <a href="{{url}}" target= "_blank">{{name}}</a>';
load.tpl += ' <p class="price">';
load.tpl += ' <span class="sale-price{{#unless marketPrice}}prime-cost{{/unless}}">';
load.tpl += ' ¥{{salePrice}}';
load.tpl += ' </span>';
load.tpl += ' {{# marketPrice}}';
load.tpl += ' <span class="market-price">¥{{.}}</span>';
load.tpl += ' {{/ marketPrice}}';
load.tpl += ' </p>';
load.tpl += ' </div>';
load.tpl += '</div>';
load.tpl += '{{/each}}';
data.pageCount = count * rows[0];
loadAjax(url, data, data.count);
//load.emit();
});
load.init();
var $ = require("jquery"),
lazyload = require("lazyload");
var Handlebars = require("handlebars");
function InfiniteLoad(options) {
var defaults = {
index: 0,
isload: true,//是否正在加载
isrun: true,//判断是否执行
offset: {
height: null,
width: null
}
};
this.registerEvent = {
before: [],
change: [],
after: []
};
this.options = $.extend(true, {}, defaults, options);
return this;
}
InfiniteLoad.prototype.on = function(name, callback) {
var g = this;
var _e = g.registerEvent[name];
if (_e) {
_e.push(callback);
}
return _e;
};
InfiniteLoad.prototype.exect = function(key, params) {
var g = this;
var e;
if (g.registerEvent[key] && g.registerEvent[key].length > 0) {
for (e in g.registerEvent[key]) {
if (g.registerEvent[key].hasOwnProperty(e)) {
g.registerEvent[key][e](params);
}
}
}
};
InfiniteLoad.prototype.init = function() {
var g = this;
var p = this.options;
function __loadMore() {
if (p.isrun && p.isload && g.__directionCalculation()) {
p.isload = false;
p.index++;
g.exect('after', p);
}
g.exect('change', p);
}
g.exect('before', p);
$(window).scroll(__loadMore);
};
InfiniteLoad.prototype.emit = function() {
var p = this.options;
p.isload = true;
};
InfiniteLoad.prototype.stop = function() {
var p = this.options;
p.isrun = false;
p.isload = false;
};
InfiniteLoad.prototype.__directionCalculation = function() {
var p = this.options;
if (p.offset.height && p.offset.height() > 0 && $(window).scrollTop() + $(window).height() >= p.offset.height()) {
return true;
}
return false;
};
module.exports = function(data) {
var $container = $('#newarrivals .goods-container');
var $load = $('.loading a');
var load = new InfiniteLoad({
index: 1,
isload: false,
offset: {
height: function() {
return parseFloat($container.offset().top) + parseFloat($container.height()) - 200;
}
}
});
var loadAjax;
var url = data.url,
count = data.count,
rows = data.rows;
data.pageIndex = 0;
delete data.url;
delete data.count;
delete data.rows;
loadAjax = function(url, data, count) {
var options = {
type: 'POST',
url: url,
success: function(result) {
var code = result.code;
var myTemplate,len,pos;
if (code === 200) {
len = result.goods.length % count;
pos = result.goods.length - len - 1;
result.goods.splice(pos, len);
myTemplate = Handlebars.compile(load.tpl);
$container.append(myTemplate(result.goods));
data.pageIndex = data.pageIndex + result.goods.length;
//懒加载插件貌似有点问题,图片先直接展示
lazyload($container.find('img.lazy'));
load.emit();
} else {
load.stop();
$load.html('查看更多');
}
},
error: function() {
load.stop();
$load.html('网络断开连接了~');
}
};
options.data = data;
$.ajax(options);
};
load.on('after', function(p) {
data.pageCount = count * rows[1];
loadAjax(url, data);
});
load.on('before', function(p) {
load.tpl = '{{#each this}}';
load.tpl += '<div class="good-info imgopacity" data-skn="{{skn}}">';
load.tpl += ' <div class="tag-container clearfix">';
load.tpl += ' {{# tags}}';
load.tpl += ' {{# isNew}}';
load.tpl += ' <span class="good-tag new-tag">NEW</span>';
load.tpl += ' {{/ isNew}}';
load.tpl += ' {{# isReNew}}';
load.tpl += ' <span class="good-tag renew-tag">再到着</span>';
load.tpl += ' {{/ isReNew}}';
load.tpl += ' {{# isSale}}';
load.tpl += ' <span class="good-tag sale-tag">SALE</span>';
load.tpl += ' {{/ isSale}}';
load.tpl += ' {{# isNewFestival}}';
load.tpl += ' <span class="good-tag new-festival-tag">新品节</span>';
load.tpl += ' {{/ isNewFestival}}';
load.tpl += ' {{# isLimit}}';
load.tpl += ' <span class="good-tag limit-tag">限量商品</span>';
load.tpl += ' {{/ isLimit}}';
load.tpl += ' {{# isYearEndPromotion}}';
load.tpl += ' <span class="good-tag yep-tag">年终大促</span>';
load.tpl += ' {{/ isYearEndPromotion}}';
load.tpl += ' {{# isYearMidPromotion}}';
load.tpl += ' <span class="good-tag ymp-tag">年中热促</span>';
load.tpl += ' {{/ isYearMidPromotion}}';
load.tpl += ' {{/ tags}}';
load.tpl += ' </div>';
load.tpl += ' <div class="good-detail-img">';
load.tpl += ' <a class="good-thumb" href="{{url}}" target= "_blank">';
load.tpl += ' <img class="lazy" data-original="{{thumb}}">';
load.tpl += ' </a>';
load.tpl += ' {{# isFew}}';
load.tpl += ' <p class="few-tag">即将售罄</p>';
load.tpl += ' {{/ isFew}}';
load.tpl += ' {{#if showColBtn}}';
load.tpl += ' <span class="col-btn iconfont{{#if coled}} coled{{/if}}">&#xe616;</span>';
load.tpl += ' {{/if}}';
load.tpl += ' </div>';
load.tpl += ' <div class="good-detail-text">';
load.tpl += ' <a href="{{url}}" target= "_blank">{{name}}</a>';
load.tpl += ' <p class="price">';
load.tpl += ' <span class="sale-price{{#unless marketPrice}}prime-cost{{/unless}}">';
load.tpl += ' ¥{{salePrice}}';
load.tpl += ' </span>';
load.tpl += ' {{# marketPrice}}';
load.tpl += ' <span class="market-price">¥{{.}}</span>';
load.tpl += ' {{/ marketPrice}}';
load.tpl += ' </p>';
load.tpl += ' </div>';
load.tpl += '</div>';
load.tpl += '{{/each}}';
data.pageCount = count * rows[0];
loadAjax(url, data, data.count);
//load.emit();
});
load.init();
};
});
define("js/passport/entry", ["jquery","jquery.placeholder"], function(require, exports, module){
... ... @@ -3859,7 +3866,9 @@ var $pwdIntensity = $('.pwd-intensity'),
//signup验证
var $region = $('#country-code'),
$regionSelect = $('#region');
$regionSelect = $('#region'),
isPwd = false,
pwdVal;
setTimeout(function() {
$pn.val('');
... ... @@ -3873,10 +3882,13 @@ setTimeout(function() {
$ca.attr('maxlength', caCount);
//密码规则提示
$pwd.focus(function() {
$pwd.focus(function(event) {
$pwdTips.removeClass('hide');
isPwd = true;
pwdVal = $(this).val();
}).blur(function() {
$pwdTips.addClass('hide');
isPwd = false;
});
... ... @@ -4339,6 +4351,23 @@ exports.init = function(page) {
});
});
// 防止粘贴密码
/*$('#pwd, #repwd').keydown(function (event) {
console.log(event.ctrlKey);
console.log(isPwd);
console.log(event.keyCode);
if (event.ctrlKey && isPwd && event.keyCode === 86) {
$(this).val(pwdVal);
}
});*/
$pwd[0].onpaste = function() {
return false;
};
//ajax表单提交
$registerBtn.click(function() {
... ...
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
... ... @@ -56,7 +56,7 @@ gulp.task('compass-watch', function() {
// start spm server
gulp.task('spm-doc', function() {
var sd = cp.exec('spm doc');
var sd = cp.exec('spm doc watch --port 8001'); // pc用8001,h5用8000, 跑两个服务器,不冲突
// sd.stdout.on('data', function(data) {
// console.log(data);
... ... @@ -197,4 +197,4 @@ gulp.task('business', ['libs'], function() {
gulp.task('script', function() {
gulp.src('plugin/page/**/*')
.pipe(gulp.dest(rootDist));
});
\ No newline at end of file
});
... ...
... ... @@ -9,6 +9,7 @@
&:first-child {
border-top: none;
background: #eaeceb;
padding: 5px 15px;
}
}
... ... @@ -62,11 +63,15 @@
.checked-conditions {
line-height: 30px;
.title {
margin-top: 5px;
}
.tag {
display: block;
float: left;
padding: 0 10px;
margin-right: 30px;
margin: 5px 30px 5px 0;
background: #000;
color: #fff;
cursor: pointer;
... ... @@ -80,6 +85,7 @@
}
.clear-checked {
margin-top: 5px;
color: #999;
float: right;
}
... ...
... ... @@ -73,6 +73,12 @@
&.new-sale {
display: block;
}
h2 a {
color: #000;
padding-left: 0;
}
li {
color: #bbb;
... ... @@ -80,6 +86,7 @@
padding-left: 5px;
}
}
a {
color: #666;
padding-left: 10px;
... ...
... ... @@ -71,7 +71,7 @@ class Bootstrap extends Bootstrap_Abstract
$controller = 'Index';
$action = 'Index';
// 二级域名
if (2 === $level) {
if (3 === $level) {
$subDomain = strval($hostParts[0]);
switch (strtolower($subDomain)) {
case 'www': // 主站
... ... @@ -79,8 +79,8 @@ class Bootstrap extends Bootstrap_Abstract
case 'dev': // 开发环境
break;
case 'search': // 搜索
$controller = 'Search';
$action = 'List';
$searchRequest = new Yaf\Request\Http('/product/search/index');
$dispatcher->setRequest($searchRequest);
break;
case 'guang': // 逛
$module = 'Guang';
... ...
... ... @@ -2,138 +2,95 @@
namespace Product;
use Plugin\Helpers;
use Api\Yohobuy;
use Plugin\HelperSearch;
use LibModels\Web\Product\BrandData;
use LibModels\Wap\Product\SearchData;
use LibModels\Web\Product\SearchData as WebProduct;
use Product\SearchModel;
/**
* 品牌首页模板数据模型
*
* @author Administrator
*/
class BrandsModel {
const URL_BRAND_INDEX = '/product/index/brand';
public static $shopName;
public static $home;
class BrandsModel
{
/**
* 搜索品牌数据
*
* @param $condition array
* 搜索数据的条件
* @param $condition array 搜索数据的条件
* @param $options array
* @return array
*/
public static function getBrandSearchData($condition, $options, $domain, $uid, $brandId,$node) {
// 调用商品搜索接口
$data = SearchData::searchElasticByCondition($condition);
//获取品牌banner数据
$banner = self::getBannerByDomain($domain, $brandId, $uid = '');
$brandName = self::$shopName;
$options['brandName'] = $brandName;
public static function getBrandSearchData($condition, $options)
{
// 并行调用品牌相关接口并封装数据
$data = self::getBrandData($condition, $options);
if (isset($data['code']) && $data['code'] === 200) {
//获取分类列表数据
$param = array();
$param['brand'] = $condition['brand'];
$classes = WebProduct::getClassesData($param);
if (isset($classes['code']) && $classes['code'] === 200) {
$data['data']['filter']['group_sort'] = $classes['data']['sort'];
}
//用户浏览记录
// 组织模板数据
$list = HelperSearch::getList($data, $options);
//合并商品搜索数据与品牌banner数据
$list = array_merge_recursive($list,$banner);
$data = array(
//初始化js
'productListPage' => true,
'list' => $list
);
} else {
$data = array();
}
//获取品牌系列数据
$adNav = self::getAdNav($condition['brand']);
$data['list']['leftContent'][] = array('picLink' => $adNav);
$adNav = self::getAdNav($options['brandId']);
$data['leftContent'][] = array('picLink' => $adNav);
//获取静态内容(20141219-100447)
if($node){
$nodeContent = HelperSearch::formatNodeContent($node);
$data['list']['leftContent'][]['picLink']['list'] = $nodeContent;
//获取静态内容(eg:20141219-100447)
if($options['node']){
$nodeContent = HelperSearch::formatNodeContent($options['node']);
$data['leftContent'][]['picLink']['list'] = $nodeContent;
}
return $data;
}
/**
* 获取品牌首页banner条
* @string $domain 品牌域名
* @int $brandId 品牌id
* @int $uid 用户id
*
* @return array 品牌banner条数据
*/
public static function getBannerByDomain($domain, $brandId, $uid = '') {
// 构造品牌主页url
self::$home = Helpers::url('', '', $domain) . self::URL_BRAND_INDEX;
// 根据品牌Id获取品牌banner图
$bannerImg = BrandData::getBrandBanner($brandId);
if (isset($bannerImg['data'])) {
$bannerImg = Helpers::getImageUrl($bannerImg['data']['banner'], '', 150);
}
// 根据品牌Id获取品牌(简介)、收藏
$intro = BrandData::getBrandIntro($brandId, $uid);
$is_favorite = false;
$shopName = false;
if(isset($intro['data'])){
// 获取是否收藏
if ($intro['data']['is_favorite'] == 'Y') {
$is_favorite = true;
} elseif ($intro['data']['is_favorite'] == 'N') {
$is_favorite = false;
}
// 获取品牌名
self::$shopName = $intro['data']['brand_name'];
}
// 返回banner数据
return array(
'brandBanner' => array(
'bannerHeight' => '150',
'coled' => $is_favorite,
'banner' => $bannerImg
)
);
}
//获取品牌系列数据
public static function getAdNav($brandId, $status = 1) {
public static function getAdNav($brandId, $status = 1)
{
//调用接口获得数据
$advNav = BrandData::getFolderByBrand($brandId, $status);
$result = array();
if (isset($advNav['data']) && $advNav['code'] === 200) {
foreach ($advNav['data'] as $key => $value) {
$result['list'][$key]['href'] = self::$home . '?folder_id=' . $value['id'];
$result['list'][$key]['href'] = '?folder_id=' . $value['id'];
$result['list'][$key]['src'] = $value['brand_sort_ico'];
}
$result['picTitle'] = '经典系列';
}
$result['picTitle'] = '经典系列';
return $result;
}
/**
* 根据条件获取搜索数据
* @param array $customCondition
* @param array $customOptions
* @return array
*/
public static function getBrandData($customCondition = array(), $customOptions = array())
{
$urlList = array();
//获取$condition和$option 筛选条件和排序条件
$searchCondition = SearchModel::searchCondition($customCondition, $customOptions);
// 组合搜索商品url
$urlList['product'] = HelperSearch::getProductUrl($searchCondition['condition']);
// 组合搜索分类url
$urlList['sort'] = HelperSearch::getClassesUrl($searchCondition['condition']);
//组合搜索品牌url
$urlList['brand'] = HelperSearch::getBrandUrl($customOptions);
//组合获取品牌banner url
$urlList['banner'] = HelperSearch::getBannerUrl($customOptions);
//组合用户浏览记录url
//$urlList['reviewUrl'] = HelperSearch::getReviewUrl($searchCondition['condition']);
//批量调接口
$result = Yohobuy::getMulti($urlList, array(), true);
//组织模板数据格式
$data = HelperSearch::getList($result, $searchCondition['options']);
return $data;
}
}
... ...
... ... @@ -24,7 +24,7 @@ class SearchModel
* @param $option
* @return mixed
*/
public static function searchCondition($param, $option)
public static function searchCondition($param = array(), $option = array())
{
/* 过滤请求参数 */
$condition = filter_input_array(INPUT_GET, array(
... ... @@ -120,6 +120,7 @@ class SearchModel
$options = array_merge($options, $option);
$data['condition'] = $condition;
$data['options'] = $options;
return $data;
}
... ... @@ -196,4 +197,14 @@ class SearchModel
}
echo json_encode($data);
}
/**
* 查询搜索提示
* @param $query
*/
public static function getSuggest($query)
{
$result = SearchData::getSuggest();
return $result;
}
}
\ No newline at end of file
... ...
... ... @@ -4,7 +4,7 @@ use LibModels\Web\Passport\RegData;
use Plugin\Helpers;
use Plugin\Cache;
use Passport\PassportModel;
use LibModels\Web\Passport\BindData;
use LibModels\Wap\Passport\BindData;
class RegisterController extends WebAction
{
/**
... ...
<?php
use Action\WebAction;
use LibModels\Web\Product\BrandData;
class IndexController extends WebAction
{
/**
* 品牌首页
*/
... ... @@ -24,80 +24,26 @@ class IndexController extends WebAction
$this->go(SITE_MAIN);
}
/* 过滤请求参数 */
//品牌ID参数
$condition = array();
$condition = filter_input_array(INPUT_GET, array(
//'query' => FILTER_SANITIZE_STRING,
'sort' => FILTER_VALIDATE_INT,
'msort' => FILTER_VALIDATE_INT,
'misort' => FILTER_VALIDATE_INT,
'color' => FILTER_VALIDATE_INT,
'size' => FILTER_VALIDATE_INT,
'style' => FILTER_DEFAULT,
'price' => FILTER_DEFAULT,
'gender' => FILTER_DEFAULT,
'p_d' => FILTER_DEFAULT,
'shelve_time' => FILTER_DEFAULT,
'isNew' => FILTER_DEFAULT,
'specialoffer' => FILTER_DEFAULT,
'limited' => FILTER_DEFAULT,
'order' => FILTER_DEFAULT,
'viewNum' => FILTER_VALIDATE_INT,
'rowNum' => FILTER_VALIDATE_INT,
'page' => FILTER_VALIDATE_INT,), false);
//字符转码
if (!empty($condition)) {
foreach ($condition as &$value) {
$value = rawurldecode($value);
}
}
//传品牌ID参数
$condition['brand'] = $brandId;
//获取性别数据
$gender = $this->get('gender') ? ($this->get('gender') == '2,3' ? 2 : 1) : (!isset($_COOKIE['_Gender']) ? '3' : ($_COOKIE['_Gender']=='2,3' ? 2 : 1));
$condition['gender'] = $gender;
//$options参数数组
$options = array();
$options['brandName'] = $domain;
$options['uid'] = $uid;
$options['brandId'] = $brandId;
$options['node'] = $node;
//每页显示商品数
if (!isset($condition['viewNum']) || empty($condition['viewNum'])) {
$condition['viewNum'] =60;
}
$view_num_arr = array(60, 100, 200);
if (!in_array($condition['viewNum'], $view_num_arr)) {
$condition['viewNum'] = 60;
}
//每行显示的商品数量
if (!isset($condition['rowNum']) || empty($condition['rowNum'])) {
$condition['rowNum'] =5;
}
if ($condition['rowNum'] == 6) {
$imgSize = array(195, 260);
$minImgSize = array(50, 67);
} else {
$condition['rowNum'] = 5;
$imgSize = array(235, 314);
$minImgSize = array(60, 80);
}
//搜索词
//$query = $this->get('query');
$condition['needFilter'] = 1;
$options = array(
'imgSize' => $imgSize,
'minImgSize' => $minImgSize,
'gender' => $gender,
'needPd' => 'Y',
'rowNum' => $condition['rowNum'],
'viewNum' => $condition['viewNum'],
//调用模型获得数据
$data = Product\BrandsModel::getBrandSearchData($condition, $options);
$data = array(
//初始化js
'searchListPage' => true,
'list' => $data
);
$params = $condition + $_GET;
$params = array_filter($params);
//每页记录数减1,下一页占位
$params['viewNum'] = $params['viewNum'] - 1;
$data = Product\BrandsModel::getBrandSearchData($params,$options,$domain,$uid,$brandId,$node);
$cate = array('boys','girls','kids','lifestyle');
$this->setWebNavHeader($cate[$gender-1]);
$this->setWebNavHeader();
//渲染模板
$this->_view->display('list',$data);
}
... ...
... ... @@ -27,6 +27,7 @@ class ListController extends WebAction
'productListPage' => true,
'list' => $list
);
$this->setWebNavHeader();
$this->_view->display('list', $data);
}
... ...
... ... @@ -15,4 +15,13 @@ class SearchController extends WebAction
$this->setWebNavHeader();
$this->_view->display('search', $data);
}
public function suggest()
{
$query = rawurldecode($this->get('query'));
if ($query) {
$param['query'] = $query;
$result = SearchModel::getSuggest($param);
}
}
}
\ No newline at end of file
... ...