Authored by Rock Zhang

Merge branch 'feature/wap323' into 'feature/wap323'

1.有货币页面改造 2.品牌一览页面增加顶部导航。 code review by Zhang Zhen

See merge request !90
... ... @@ -13,6 +13,7 @@ var swiper,
$fixTitleBar,
$brandList = $('.brand-list'),
$icon = $('.search-icon'),
$genderItem = $('.genderNav li'),
hotBrandsSwiper;
var searchH = $('.newbrand-search').outerHeight(),
... ... @@ -177,3 +178,11 @@ if ($('.brand-search-page').length) {
});
}
if ($genderItem.length > 0) {
$genderItem.on('touchstart', function() {
$('.genderNav ul .active').removeClass('active');
$(this).addClass('active');
window.location.search = 'channel=' + ($(this).data('id') + 1);
});
}
... ...
... ... @@ -193,4 +193,4 @@ exports.set = function(c) {
});
};
require('./maybe-like');
\ No newline at end of file
require('./maybe-like')();
... ...
... ... @@ -4,146 +4,157 @@
* @date: 2015/10/12
*/
var $ = require('jquery'),
Hammer = require('yoho.hammer'),
tip = require('../plugin/tip'),
loading = require('../plugin/loading'),
lazyLoad = require('yoho.lazyload');
var navHammer,
winH = $(window).height(),
$goodList = $('#goods-list'),
searching = false,
page = 0,
gender = null,
kidsType = $('.mobile-wrap').hasClass('kids-wrap') ? true : false,
lifestyleType = $('.mobile-wrap').hasClass('lifestyle-wrap') ? true : false,
num,
url;
var $curNav,
index,
$navList = $('#maybe-like-nav');
//ajax url
if (kidsType) {
url = '/product/recom/maylikekids';
} else if (lifestyleType) {
url = '/product/recom/maylikelife';
} else {
gender = $('.mobile-wrap').hasClass('boys-wrap') ? '1,3' : '2,3',
url = '/product/recom/maylike?gender=' + gender;
}
$curNav = $navList.children('.focus');
if (lifestyleType) {
navHammer = new Hammer($navList[0]);
navHammer.on('tap', function(e) {
var $this = $(e.target).closest('li'),
$goods = $('.goods-list'),
$content;
e.preventDefault();
if ($this.hasClass('focus')) {
return;
}
module.exports = function(specificGender) {
var $ = require('jquery'),
Hammer = require('yoho.hammer'),
tip = require('../plugin/tip'),
loading = require('../plugin/loading'),
lazyLoad = require('yoho.lazyload');
var navHammer,
winH = $(window).height(),
$goodList = $('#goods-list'),
searching = false,
page = 0,
gender = null,
num,
url;
//The kidsType can be specified by the parameter. Add by @ZhaoBiao
var kidsType = specificGender === 'kids' || $('.mobile-wrap').hasClass('kids-wrap') ? true : false,
lifestyleType = specificGender === 'lifestyle' ||
$('.mobile-wrap').hasClass('lifestyle-wrap') ? true : false;
var $curNav,
index,
$navList = $('#maybe-like-nav');
//ajax url
if (kidsType) {
url = '/product/recom/maylikekids';
} else if (lifestyleType) {
url = '/product/recom/maylikelife';
} else {
gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ?
'1,3' : '2,3',
url = '/product/recom/maylike?gender=' + gender;
}
$curNav = $navList.children('.focus');
index = $this.index();
if (lifestyleType) {
navHammer = new Hammer($navList[0]);
navHammer.on('tap', function(e) {
var $this = $(e.target).closest('li'),
$goods = $('.goods-list'),
$content;
$this.addClass('focus');
$curNav.removeClass('focus');
e.preventDefault();
if ($this.hasClass('focus')) {
return;
}
$goods.not('.hide').addClass('hide');
$content = $goods.eq(index);
$content.removeClass('hide');
index = $this.index();
$curNav = $this;
$this.addClass('focus');
$curNav.removeClass('focus');
$(document).trigger('scroll'); //Trigger lazyLoad
e.srcEvent.stopPropagation();
});
}
$goods.not('.hide').addClass('hide');
$content = $goods.eq(index);
$content.removeClass('hide');
loading.init($('.maybe-like'));
$curNav = $this;
function search() {
if (searching) {
return;
$(document).trigger('scroll'); //Trigger lazyLoad
e.srcEvent.stopPropagation();
});
}
searching = true;
loading.showLoadingMask();
//num = $goodList.find('.good-info').length;
$.ajax({
type: 'GET',
url: url,
data: {
page: page + 1
},
success: function(data) {
if (data === ' ') {
searching = false;
loading.hideLoadingMask();
if (gender) {
if (gender === '1,3') {
url = '/boys/bottomBanner';
} else {
url = '/girls/bottomBanner';
}
$.ajax({
type: 'GET',
url: url,
success: function(data) {
if (data && data.img) {
$('#load-more-img').show();
$('#load-more-img a').attr('href', data.url);
$('#load-more-img a > img').attr('src', data.img);
}
},
error: function() {
loading.init($('.maybe-like'));
function search() {
if (searching) {
return;
}
searching = true;
loading.showLoadingMask();
//num = $goodList.find('.good-info').length;
$.ajax({
type: 'GET',
url: url,
data: {
page: page + 1
},
success: function(data) {
if (data === ' ') {
searching = false;
loading.hideLoadingMask();
if (gender) {
if (gender === '1,3') {
url = '/boys/bottomBanner';
} else {
url = '/girls/bottomBanner';
}
});
$.ajax({
type: 'GET',
url: url,
success: function(data) {
if (data && data.img) {
$('#load-more-img').show();
$('#load-more-img a').attr('href', data.url);
$('#load-more-img a > img').attr('src', data.img);
}
},
error: function() {
}
});
}
return;
}
return;
}
num = $goodList.find('.good-info').length;
num = $goodList.find('.good-info').length;
$goodList.append(data);
$goodList.append(data);
// 2015/10/31 fei.hong: 修复第一页分页不显示图片的问题
if (num === 0) {
lazyLoad($goodList.find('.good-info').find('img.lazy'));
} else {
lazyLoad($goodList.find('.good-info:gt(' + (num - 1) + ')').find('img.lazy'));
}
// 2015/10/31 fei.hong: 修复第一页分页不显示图片的问题
if (num === 0) {
lazyLoad($goodList.find('.good-info').find('img.lazy'));
} else {
lazyLoad($goodList.find('.good-info:gt(' + (num - 1) + ')').find('img.lazy'));
searching = false;
loading.hideLoadingMask();
page++;
},
error: function() {
tip.show('网络断开连接了~');
searching = false;
loading.hideLoadingMask();
}
});
}
searching = false;
loading.hideLoadingMask();
page++;
},
error: function() {
tip.show('网络断开连接了~');
searching = false;
loading.hideLoadingMask();
}
$('.maybe-like p').on('touchstart', function(e) {
search();
});
}
$('.maybe-like p').on('touchstart', function(e) {
search();
});
function scrollHandler() {
if ($(window).scrollTop() + winH >= $(document).height() - 200) {
search();
}
}
function scrollHandler() {
if ($(window).scrollTop() + winH >= $(document).height() - 200) {
// 优惠券页面直接加载你可能喜欢。add by @zhaobiao
if (specificGender) {
search();
}
}
//srcoll to load more
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
\ No newline at end of file
//srcoll to load more
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
};
... ...
/**
* 新有货币界面
* @author: 赵彪<bill.zhao@yoho.cn>
* @date: 2015/12/30
*/
function getGender() {
return window.cookie('_Channel');
}
require('../home/maybe-like')(getGender());
... ...
... ... @@ -19,3 +19,4 @@ require('./logistic');
require('./pay');
require('./personal-details');
require('./currency');
require('./currency-new');
... ...
.brand-page {
.re-pos-search {
top: 170rem / $pxConvertRem !important;
}
.genderNav {
display: block;
width: 100%;
height: 80rem / $pxConvertRem;
line-height: 80rem / $pxConvertRem;
overflow: hidden;
color: #aeaeae;
z-index: 3;
position: fixed;
top: 90rem / $pxConvertRem;
border-bottom: 1px solid #e1e1e1;
background-color: #fff;
ul{
width: 100%;
height: 90%;
overflow: hidden;
li{
width: 25%;
height: 100%;
overflow: hidden;
float: left;
text-align: center;
position: relative;
font-size: 28rem / $pxConvertRem;
i{
width: 100%;
height: 40%;
overflow: hidden;
display: block;
}
span:not(.split-border){
width: 100%;
height: auto;
overflow: hidden;
display: block;
//line-height: 40rem / $pxConvertRem;
}
.split-border {
display: inline-block;
width: 2px;
height: 1rem;
background-color: #e1e1e1;
position: absolute;
top: 30%;
right: 0;
}
}
li:last-child {
.split-border {
display: none;
}
}
li.active {
color: #444;
}
}
}
.newbrand-search {
width: 93.75%;
height: 60rem / $pxConvertRem;
... ...
{{> layout/header}}
<div class="brand-page yoho-page">
{{# channel}}
<div class="newbrand-search">
<div class="genderNav">
<ul>
{{# channels}}
<li {{#if active}}class="active"{{/if}} data-id="{{@index}}">
<span>{{name}}</span>
<span class="split-border"></span>
</li>
{{/channels}}
</ul>
</div>
<div class="newbrand-search re-pos-search">
<div class="search-box clearfix">
<a href="{{searchUrl}}" >
<input type="text" class="search-input" placeholder="查找品牌" readonly="true">
... ...
{{> layout/header}}
<div class="yoho-coin-new-page yoho-page">
<div class="coin">
{{# yohoCoin}}
<p class="coin-num">
7876
{{coinNum}}
</p>
<p class="info">
<span class="dollar"></span>
YOHO
</p>
<a href="" class="more">查看明细</a>
<a href="/home/currencyDetail" class="more">查看明细</a>
<div class="coin-tip">
<span class="icon">!</span>
您有300个YOHO币即将于20171231日过期,请尽快使用
{{notice}}
</div>
{{/ yohoCoin}}
</div>
<div class="banner">
<a href="">
{{#banner}}
<a href="{{url}}">
{{!-- 演示图片 --}}
<img src="http://temp.im/640x200" alt="">
<img src="{{img}}" alt="img">
</a>
{{/banner}}
</div>
{{> home/maybe_like}}
... ...
... ... @@ -81,7 +81,7 @@
优惠券
<span class="iconfont num">{{coupon_num}} &#xe604;</span>
</a>
<a class="list-item" href="/home/currencyDetail">
<a class="list-item" href="/home/currency">
<span class="iconfont icon">&#xe635;</span>
YOHO
<span class="iconfont num">{{yoho_coin_num}} &#xe604;</span>
... ...
... ... @@ -334,3 +334,9 @@
seajs.use('js/me/currency');
</script>
{{/if}}
{{#if currencyPage}}
<script>
seajs.use('js/me/currency-new');
</script>
{{/if}}
... ...
... ... @@ -264,8 +264,9 @@ class HomeController extends AbstractAction
// banenr数据
$currency['banner'] = UserModel::getYohoCoinBanner();
$currency['pageFooter'] = true;
$currency['currencyPage'] = true;
$this->_view->display('currency', $currency);
$this->_view->display('currency-new', $currency);
}
/**
... ...
... ... @@ -8,7 +8,7 @@ use Plugin\Helpers;
/**
* 品牌相关的模板数据模型
*
*
* @name BrandModel
* @package Models/Category
* @copyright yoho.inc
... ... @@ -29,7 +29,7 @@ class BrandModel
/**
* 根据频道获取品牌一览数据
*
*
* @param int $channel 1表示男生频道, 2表示女生频道, 3表示潮童频道, 4表示创意生活频道
* @return array
*/
... ... @@ -40,20 +40,20 @@ class BrandModel
// 设置品牌一览顶部频道导航
$channels = array(
1 => array(
'name' => 'Boy'
array(
'name' => 'Boy'
),
2 => array(
'name' => 'Girl'
array(
'name' => 'Girl'
),
3 => array(
'name' => 'Kid'
array(
'name' => 'Kid'
),
4 => array(
'name' => 'Lifestyle'
array(
'name' => 'Lifestyle'
)
);
$channels[$channel]['active'] = true;
$channels[$channel-1]['active'] = true;
$result['channels'] = $channels;
/* 根据频道调用接口 */
... ... @@ -109,7 +109,7 @@ class BrandModel
/**
* 获取搜索的品牌列表
*
*
* @param int $channel 1表示男生频道, 2表示女生频道, 3表示潮童频道, 4表示创意生活频道
* @return array
*/
... ...