Authored by 郝肖肖

Merge branch 'release/5.2' into feature/homeOptimization

... ... @@ -33,7 +33,7 @@ const index = (req, res, next) => {
updated: new Date(),
})
_.forEach(result, item => {
item.url = item.url.indexOf('http') > 0 ? item.url : 'http://'+item.url
item.url = item.url.indexOf('http') >= 0 ? item.url : 'http://'+item.url
feed.addItem({
title: item.title,
link: `${item.url}&ref=rss`,
... ... @@ -50,8 +50,29 @@ const index = (req, res, next) => {
return res.send(feed.render('rss-2.0'))
});
};
const rss = (req, res, next, gmt) => {
let gender = req.query.gender || '1,2,3',
items = [];
res.setHeader('Content-Type', 'text/xml; charset=utf-8');
return rssModel.getRssArticle(gender).then((result) => {
if (!result) {
return next();
}
_.forEach(result, item => {
item.url = item.url.indexOf('http') >= 0 ? item.url : 'http://'+item.url;
let time = new Date(item.publishTimeLong && parseFloat(item.publishTimeLong) || moment(item.publishTime, "MM月DD日 HH:mm"));
console.log(gmt)
let format = gmt ? time : moment(time).format('YYYY-MM-DD hh:mm:ss +0800');
item.publishTime = format;
});
return res.render('rss/index', {
layout: false,
items: result
});
});
};
module.exports = {
index
index,
rss
};
\ No newline at end of file
... ...
... ... @@ -54,6 +54,8 @@ router.get('/plustar', plustar.getListData); // 国际优选列表页
router.get('/plustar/brandinfo', plustar.getDetailData); // 国际优选详情页
router.post('/plustar/brandinfoAsync', plustar.getDetailDataAsync); // 国际优选详情页异步数据
router.get('/rss/new', (req, res, next) => rss.rss(req, res, next, '')); // 订阅资讯
router.get('/rss/new-gmt', (req, res, next) => rss.rss(req, res, next, 'gmt')); // 订阅资讯
router.get(/^\/rss(\/\w+)?(\/\w+)?/, rss.index); // 订阅资讯
router.get('/info/listData', index.listDynamicData);
... ...
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>有货逛</title>
<link>http://yohobuy.com</link>
<generator>http://m.yohobuy.com</generator>
<description>Yoho!Buy有货 | 年轻人潮流购物中心</description>
<atom:link href="http://guang.m.yohobuy.com/rss" rel="self"></atom:link>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/>
<language>zh-cn</language>
<copyright>2015 yoho.inc</copyright>
<lastBuildDate>{{time}}</lastBuildDate>
<ttl>50</ttl>
{{# items}}
<item>
<title><![CDATA[{{title}}]]></title>
<link>
<![CDATA[{{{url}}}&ref=rss]]>
</link>
<description>
<![CDATA[{{{intro}}}]]>
</description>
<pubDate>{{publishTime}}</pubDate>
<author>
<![CDATA[{{author.name}}]]>
</author>
<guid>
<![CDATA[{{{url}}}&ref=rss]]>
</guid>
<source>有货</source>
</item>
{{/items}}
</channel>
<?xml version='1.0' encoding='utf-8'?>
<rss version='2.0'>
<channel>
<language>zh-cn</language>
<title><![CDATA[有货逛]]></title>
<link><![CDATA[http://yohobuy.com]]></link>
<description><![CDATA[Yoho!Buy有货 | 年轻人潮流购物中心]]></description>
<generator><![CDATA[yohobuy.com]]></generator>
<image>
<title><![CDATA[有货逛]]></title>
<link><![CDATA[http://yohobuy.com]]></link>
<description><![CDATA[yohobuy.com]]></description>
</image>
{{# items}}
<item>
<title><![CDATA[{{title}}]]></title>
<link><![CDATA[{{{url}}}&ref=rss]]></link>
<description><![CDATA[{{{intro}}}]]></description>
<pubDate><![CDATA[{{publishTime}}]]></pubDate>
<source url="{{{url}}}&ref=rss"><![CDATA[有货逛]]></source>
<author>有货</author>
</item>
{{/items}}
</channel>
</rss>
\ No newline at end of file
... ...
... ... @@ -276,6 +276,7 @@ exports.check = (req, res, next) => {
code: 200,
redirect,
newer: true,
registerCode: r1.data.code
});
return;
... ... @@ -329,7 +330,7 @@ exports.password = (req, res, next) => {
let mobile = _.get(req.session, 'smsLogin.mobile');
let area = _.get(req.session, 'smsLogin.area');
let password = (req.body.password || '').trim();
let smsCode = +req.body.smsCode || 0;
let registerCode = +req.body.registerCode || 0;
if (!password) {
data.message = PASSWORD_REQUIRED;
... ... @@ -349,7 +350,7 @@ exports.password = (req, res, next) => {
let shoppingKey = cookie.getShoppingKey(req);
RegService.regMobileAes(area, mobile, password, shoppingKey, smsCode).then(result => {
RegService.regMobileAes(area, mobile, password, shoppingKey, registerCode).then(result => {
if (!result.code || result.code !== 200) {
return Promise.reject(result);
}
... ...
... ... @@ -184,7 +184,7 @@ const search = (req, res, next) => {
params.isApp = req.yoho.isApp;
searchModel.getSearchData(params).then((result) => {
if (result.list.length > 0) {
if (result.list && result.list.length > 0) {
res.render('search/page', {
layout: false,
new: result.list,
... ...
{{#if singleOne}}
{{#data}}
<div class="banner-list">
<a href="{{url}}">
<img src="{{image src 640 200}}" alt="">
</a>
</div>
{{/data}}
{{else}}
<div class="banner-center banner-center-swiper">
{{#if singleOne}}
<ul class="banner-list swiper-wrapper clearfix">
{{#data}}
<div class="banner-list">
<a href="{{url}}">
<img src="{{image src 640 200}}" alt="">
</a>
</div>
<li class="swiper-slide">
<a href="{{url}}">
<img src="{{image src 640 200}}" alt="">
</a>
</li>
{{/data}}
{{else}}
<ul class="banner-list swiper-wrapper clearfix">
{{#data}}
<li class="swiper-slide">
<a href="{{url}}">
<img src="{{image src 640 200}}" alt="">
</a>
</li>
{{/data}}
</ul>
{{/if}}
</ul>
<div class="swiper-pagination" {{#unless singleOne}}style="display:block"{{/unless}}>
<div class="pagination-inner">
</div>
</div>
</div>
{{/if}}
... ...
{{#data}}
<div style="background-image:url({{src}})" class="divide-image"></div>
<div style="background-image:url({{image src 640 26}})" class="divide-image"></div>
{{/data}}
\ No newline at end of file
... ...
... ... @@ -2,7 +2,7 @@
<div class="hot-single">
{{> common/floor-header-more}}
{{> resources/new-floor-banner}}
<div class="hot-single-goods-list" {{#background}}style="background-image: url({{src}})"{{/background}}>
<div class="hot-single-goods-list" {{#background}}style="background-image: url({{image src 640 330}})"{{/background}}>
<ul>
{{#list}}
<li class="hot-single-goods">
... ...
{{#appIconList}}
<div class="icons-wrapper" style="background-image:url({{back_image}})">
<div class="icons-wrapper" style="background-image:url({{image back_image 640 360}})">
<ul class="icons-list clearfix">
{{#data}}
<li class="icons-item item-{{../number}}"><a href="{{url}}" class="imagebar"><img src="{{image src 98 98}}" alt=""></a><a href="{{url}}" class="linkbar">{{title}}</a></li>
... ...
{{#if banner_image.[1]}}
<div class="banner-center banner-center-swiper" style="border: 0;">
{{#if banner_image.[1]}}
<ul class="banner-list swiper-wrapper clearfix">
{{#banner_image}}
<li class="swiper-slide">
... ... @@ -9,17 +9,17 @@
</li>
{{/banner_image}}
</ul>
{{else}}
{{#banner_image}}
<div class="banner-list">
<a href="{{url}}">
<img src="{{image src 640 200}}" alt="">
</a>
</div>
{{/banner_image}}
{{/if}}
<div class="swiper-pagination" {{#if banner_image.[1]}}style="display:block"{{/if}}>
<div class="pagination-inner">
</div>
</div>
</div>
\ No newline at end of file
</div>
{{else}}
{{#banner_image}}
<div class="banner-list single-one">
<a href="{{url}}">
<img src="{{image src 640 200}}" alt="">
</a>
</div>
{{/banner_image}}
{{/if}}
\ No newline at end of file
... ...
... ... @@ -3,7 +3,7 @@
{{> common/floor-header-more}}
<div class="new-user-icon">新人专享</div>
{{> resources/new-floor-banner}}
<div class="new-user-goods-container" {{#background}} style="background-image: url({{src}})" {{/background}}>
<div class="new-user-goods-container" {{#background}} style="background-image: url({{image src 640 213}})" {{/background}}>
<ul>
{{#list}}
<li class="new-user-good">
... ...
... ... @@ -4,7 +4,7 @@
{{> resources/new-floor-banner}}
<div class="vip-only-goods-list" {{#background}} style="background-image: url({{src}})" {{/background}}>
<div class="vip-only-goods-list" {{#background}} style="background-image: url({{image src 640 330}})" {{/background}}>
<ul>
{{#list}}
<a href="//m.yohobuy.com/product/show_{{product_skn}}">
... ...
... ... @@ -115,16 +115,22 @@ if ($('.banner-swiper').find('li').size() > 1) {
}
// single_image的轮播
if ($('.banner-center-swiper').find('li').size() > 1) {
new Swiper('.banner-center-swiper', {
loop: true,
autoplay: 3000,
autoplayDisableOnInteraction: false,
paginationClickable: true,
slideElement: 'li',
pagination: '.banner-center .pagination-inner'
});
}
$('.banner-center-swiper').each(function() {
if ($(this).find('li').size() > 1) {
new Swiper('.banner-center-swiper', {
loop: true,
autoplay: 3000,
autoplayDisableOnInteraction: false,
paginationClickable: true,
slideElement: 'li',
pagination: '.banner-center .pagination-inner',
});
} else {
$(this).unbind();
}
});
// 异步获取首屏其余楼层
var getResourceContent = function() {
... ... @@ -273,6 +279,7 @@ var checkShop = function() {
$('.recom-shop').each(function() {
shopIds.push($(this).attr('shopId'));
});
shopIds.length &&
$.ajax({
type: 'POST',
url: '/channel/shopRecom',
... ...
... ... @@ -35,7 +35,8 @@ $pwd.bind('input', function() {
});
$btnSure.toggleClass('disable', !bool);
});
})
qs = window.queryString;
... ... @@ -131,3 +132,9 @@ $btnSure.on('touchstart', function() {
$('.agreement-detail').on('click', function() {
$(this).attr('href', '//m.yohobuy.com/passport/agreement' + window.location.search);
});
// 如果有值, 立刻校验
if ($pwd.val()) {
$pwd.triggerHandler('input');
}
\ No newline at end of file
... ...
... ... @@ -146,7 +146,7 @@ page = {
checkPoint('YB_MOBILE_LOGIN_C'); // 埋点
if (res.newer) {
res.redirect = res.redirect + '&smsCode=' + code;
res.redirect = res.redirect + '&registerCode=' + res.registerCode;
}
location.href = res.redirect;
... ...
... ... @@ -154,6 +154,6 @@ require('./detail/page-render')(function() {
$(function() {
if ($('#product-coupon-switch').val() === 'true') {
require(['./detail/brand-coupon']); // amd
require('./detail/brand-coupon'); // amd
}
});
... ...
/* global define */
// amd
define(function(require) {
'use strict';
/**
* 商品详情: 品牌券
*/
var tip = require('plugin/tip');
var $ = require('yoho-jquery');
var $body = $(document.body);
var brandCoupon = {
skn: null,
brandId: null,
$entry: null,
$couponDrawer: null,
template: require('product/detail/coupon-list.hbs'),
init: function(skn, brandId) {
var self = this;
this.skn = skn;
this.brandId = brandId;
if (!(skn && brandId)) {
return;
}
'use strict';
this.fetchCoupons(this.skn, this.brandId)
.done(function(data) {
if (data.length) {
self.render(data);
self.domInit();
self.bindEvents();
self.$entry.removeClass('hide');
}
})
.fail();
},
domInit: function() {
this.$entry = $('.brand-coupon').removeClass('hide');
},
bindEvents: function() {
var self = this;
this.$entry.on('click', function() {
self.toggleDrawer(true);
});
this.$couponDrawer
.on('click', '.coupon-drawer-mask', $.proxy(this.toggleDrawer, this, false))
.on('click', '.coupon-btn-valid', $.proxy(this.saveCouponHandler, this));
},
render: function(data) {
this.$couponDrawer = $(this.template({
coupons: data
}));
this.$couponDrawer.appendTo('.good-detail-page');
return this;
},
// 获取 品牌券
fetchCoupons: function(skn, brandId) {
return $.get('/product/detail/coupon.json', {
skn: skn,
brandId: brandId
});
},
saveCoupon: function(couponId, callback) {
$.post('/product/detail/coupon/save.json', {
couponId: couponId
}).done(function(res) {
tip.show(res.message);
if (res.code === 200) {
callback(); // eslint-disable-line
} else {
tip.show(
res.message || '抱歉,您不符合领用条件'
);
if (res.redirect) {
setTimeout(function() {
location.href = res.redirect;
}, 1000);
}
}
}).fail(function() {
tip.show('网络异常,请稍后再试');
});
},
// 收藏 品牌券
saveCouponHandler: function(event) {
var $btn = $(event.target);
var couponId = $btn.closest('.coupon').data('coupon');
this.saveCoupon(couponId, function() {
$btn.prop('disabled', true)
.removeClass('coupon-btn-valid')
.text('已领取');
});
event.stopPropagation();
},
toggleDrawer: function(bool) {
this.$couponDrawer.toggleClass('open', bool);
$body.toggleClass('coupon-drawer-open', bool);
/**
* 商品详情: 品牌券
*/
var tip = require('plugin/tip');
var $ = require('yoho-jquery');
var $body = $(document.body);
var brandCoupon = {
skn: null,
brandId: null,
$entry: null,
$couponDrawer: null,
template: require('product/detail/coupon-list.hbs'),
init: function(skn, brandId) {
var self = this;
this.skn = skn;
this.brandId = brandId;
if (!(skn && brandId)) {
return;
}
};
brandCoupon.init(
$('#productSkn').val(),
$('#brand-id').val()
);
});
this.fetchCoupons(this.skn, this.brandId)
.done(function(data) {
if (data.length) {
self.render(data);
self.domInit();
self.bindEvents();
self.$entry.removeClass('hide');
}
})
.fail();
},
domInit: function() {
this.$entry = $('.brand-coupon').removeClass('hide');
},
bindEvents: function() {
var self = this;
this.$entry.on('click', function() {
self.toggleDrawer(true);
});
this.$couponDrawer
.on('click', '.coupon-drawer-mask', $.proxy(this.toggleDrawer, this, false))
.on('click', '.coupon-btn-valid', $.proxy(this.saveCouponHandler, this));
},
render: function(data) {
this.$couponDrawer = $(this.template({
coupons: data
}));
this.$couponDrawer.appendTo('.good-detail-page');
return this;
},
// 获取 品牌券
fetchCoupons: function(skn, brandId) {
return $.get('/product/detail/coupon.json', {
skn: skn,
brandId: brandId
});
},
saveCoupon: function(couponId, callback) {
$.post('/product/detail/coupon/save.json', {
couponId: couponId
}).done(function(res) {
tip.show(res.message);
if (res.code === 200) {
callback(); // eslint-disable-line
} else {
tip.show(
res.message || '抱歉,您不符合领用条件'
);
if (res.redirect) {
setTimeout(function() {
location.href = res.redirect;
}, 1000);
}
}
}).fail(function() {
tip.show('网络异常,请稍后再试');
});
},
// 收藏 品牌券
saveCouponHandler: function(event) {
var $btn = $(event.target);
var couponId = $btn.closest('.coupon').data('coupon');
this.saveCoupon(couponId, function() {
$btn.prop('disabled', true)
.removeClass('coupon-btn-valid')
.text('已领取');
});
event.stopPropagation();
},
toggleDrawer: function(bool) {
this.$couponDrawer.toggleClass('open', bool);
$body.toggleClass('coupon-drawer-open', bool);
}
};
brandCoupon.init(
$('#productSkn').val(),
$('#brand-id').val()
);
... ...
/**
* 品牌店铺首页
*/
var $ = require('yoho-jquery'),
IScroll = require('yoho-iscroll/build/iscroll-probe'),
lazyLoad = require('yoho-jquery-lazyload'),
Swiper = require('yoho-swiper');
var bannerSwiper,
multiSwiper,
myScroll,
imgH,
nav1H,
main1H,
main1oH,
nav2H,
main2oH,
scH,
$nav1 = $('#pos-nav'),
$nav2 = $('#pos-list'),
sTop,
toTop = false;
var tip = require('../plugin/tip'),
filter = require('../plugin/filter'),
loading = require('../plugin/loading');
var $subNav = $('.home-sub-nav'),
$collect = $('#collect'),
$goodsContainer = $('#goods-container'),
$goodsChildren = $goodsContainer.children(),
$ngc = $($goodsChildren.get(0)),
$pgc = $($goodsChildren.get(1)),
$dgc = $($goodsChildren.get(2)),
shopId = $('input[name="shop_id"]').val(),
appVersion = $('input[name="app_version"]').val(),
brand = $('input[name="brand"]').val(),
coverChannel = $('input[name="coverChannel"]').val(),
favId = $('input[name="favId"]').val(),
uid = $('input[name="uid"]').val();
var winH = $(window).height(),
noResult = '<p class="no-result">未找到相关搜索结果</p>';
require('../common');
// 默认筛选条件
var defaultOpt = require('../common/query-param');
// pagecache判断app设置cookie,判断是否收藏
(function() {
var param = location.search;
var isApp = param.indexOf('app_version') > -1 || param.indexOf('appVersion') > -1;
//不阻塞字体文件加载
setTimeout(function() {
if (isApp) {
$.ajax({
type: 'GET',
url: '/product/index/shopAppCookie',
xhrFields: {
withCredentials: true
},
error: function() {
tip.show('网络断开连接了~');
}
});
}
$.ajax({
type: 'GET',
url: '/product/index/shopFav',
xhrFields: {
withCredentials: true
},
data: {
shopId: $('.shopid').val(),
},
success: function(data) {
if (data.collect) {
$collect.attr('class', 'already-collect');
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
if ($('.popularity-title').data('skns')) {
$.ajax({
type: 'GET',
url: '/product/new/shop/hotlist',
xhrFields: {
withCredentials: true
},
data: {
skns: $('.popularity-title').data('skns'),
},
success: function(data) {
$('.product-warp>.goods-container').html(data)
},
error: function() {
tip.show('网络断开连接了~');
}
});
}
$.ajax({
type: 'GET',
url: '/product/search/filter',
data: {
shop_id: $('.shopid').val(),
type: 'default',
order: '0',
channel: defaultOpt.channel
},
success: function(data) {
$goodsContainer.append(data);
// 初始化filter&注册filter回调
filter.initFilter({
fCbFn: search,
hCbFn: function() {
// 切换active状态到$pre上
$pre.addClass('active');
$pre.siblings('.filter').removeClass('active');
}
});
}
});
}, 0)
}());
var $listNav = $('#list-nav'),
// 导航数据信息
navInfo = {
new: {
order: 1,
reload: true,
page: 1,
end: false
},
hot: {
order: 1,
reload: true,
page: 1,
end: false
},
newest: {
order: 0,
reload: true,
page: 0,
end: false
},
price: {
order: 1,
reload: true,
page: 0,
end: false
},
discount: {
order: 1,
reload: true,
page: 0,
end: false
}
},
$pre = $listNav.find('.active'), // 纪录进入筛选前的active项,初始为选中项
searching;
var viewType = 1, // 1-首页,2-上新,3-人气
listCount = $('.category-list li').length,
listModValue = 4 - listCount % 4,
listIndex;
// $('.main-wrap').css({
// position: 'static'
// });
// 焦点效果
if ($('.banner-swiper').find('li').size() > 1) {
bannerSwiper = new Swiper('.banner-swiper', {
lazyLoading: true,
lazyLoadingInPrevNext: true,
loop: true,
autoplay: 3000,
autoplayDisableOnInteraction: false,
paginationClickable: true,
slideElement: 'li',
pagination: '.banner-top .pagination-inner'
});
}
if ($('.multi-browse').find('li').size() > 1) {
multiSwiper = new Swiper('.multi-browse', {
lazyLoading: true,
lazyLoadingInPrevNext: true,
lazyLoadingOnTransitionStart: true,
grabCursor: true,
slidesPerView: 'auto',
slideElement: 'li',
watchSlidesVisibility: true
});
}
// 根据热门品类的个数来改变样式展示
//
if ($('.category-list li').length % 4 !== 0) {
$('.category-list li:last-child').addClass('category-list-last-li');
}
if ($('.category-list li').length < 4) {
$('.category-list').addClass('category-list-top-board');
$('.category-list').find('.buriedpoint').addClass('category-list-only-one-row');
} else if ($('.category-list li').length >= 5) {
for (listIndex = listModValue; listIndex >= 0; listIndex--) {
$('.category-list li').eq(listCount - 4 + listIndex - 1).addClass('category-list-last-full-row');
}
}
function getPageGoods(info) {
var nav, navType;
if (searching) {
return;
}
navType = info.data.type;
nav = navInfo[navType];
// 不需要重新加载并且数据请求结束
if (nav.end && toTop) {
toTop = false;
return;
}
if (info.data && coverChannel) {
info.data.coverChannel = coverChannel;
}
searching = true;
$.ajax({
type: 'GET',
url: info.url,
data: info.data,
success: function(data) {
nav.end = true;
info.callBack(data);
},
error: function() {
tip.show('网络断开连接了~');
searching = false;
}
});
}
function getParam(req) {
if (brand) {
req.data.brand = brand;
}
if (shopId) {
req.data.shop_id = shopId;
}
}
function newData(callback) {
var req = {};
req.url = '/product/search/search';
req.data = {
type: 'new',
order: '0',
page: navInfo.new.page,
tagNew: '1',
appVersion: appVersion
};
getParam(req);
req.callBack = function(data) {
$('#new-arrival').append(data);
navInfo.new.page++;
lazyLoad($('#new-arrival .lazy'));
scH = $('#scroller').outerHeight();
searching = false;
callback && $.isFunction(callback) && callback();
};
var result = getPageGoods(req);
if (!result) {
callback && callback();
}
}
function hotData(callback) {
var req = {};
req.url = '/product/search/search';
req.data = {
type: 'hot',
order: '1',
page: navInfo.hot.page,
showTag: '1',
appVersion: appVersion
};
getParam(req);
req.callBack = function(data) {
$('#popularity').append(data);
navInfo.hot.page++;
lazyLoad($('#popularity .lazy'));
scH = $('#scroller').outerHeight();
searching = false;
callback && $.isFunction(callback) && callback();
};
var result = getPageGoods(req);
if (!result) {
callback && callback();
}
}
function tabChange(dom, index) {
var li = dom.eq(index);
dom.removeClass('active color');
li.addClass('active color');
}
// 首页导航
(function(nav, posNav, main) {
var scrollToNav1 = function() {
window.scrollTo(0, $('#nav').offset().top + 5)
}
$(nav + ' li, ' + posNav + ' li').not('li.all-goods').on('touchstart', function() {
var index = $(this).index(),
activeTab = $(this).attr('tab');
if ($('.filter-mask').length && !$('.filter-mask').hasClass('hide')) {
return;
}
$nav1.removeClass('fixed-top');
tabChange($(nav + ' li'), index);
tabChange($(posNav + ' li'), index);
$(main).hide();
$('#' + activeTab).fadeIn();
if (activeTab === 'new-arrival') {
toTop = true;
newData(scrollToNav1);
viewType = 2;
} else if (activeTab === 'popularity') {
toTop = true;
hotData(scrollToNav1);
viewType = 3;
} else if (activeTab === 'home-page') {
$nav1.removeClass('fixed-top absolute');
$nav2.removeClass('fixed-top absolute');
viewType = 1;
scrollToNav1();
}
scH = $('#scroller').outerHeight();
});
}('#nav', '#pos-nav', '.main'));
function scrollHandler() {
var scrollCall,
sTop = $(document).scrollTop(),
scH = $('#scroller').outerHeight(),
nav1OffsetTop = $('#nav').length ? $('#nav').offset().top : 0,
nav2OffsetTop = $('#list-nav').length ? $('#list-nav').offset().top : 0;
var tra;
//分页加载店铺商品列表
if (sTop + winH > scH - 0.25 * $goodsContainer.height() - 50) {
if ($pre !== undefined) {
search({
type: 'shop_id',
id: shopId,
brand: brand,
url: '/product/search/search',
nextPage: true
});
}
}
//分页加载“上新”和“人气”商品数据
if (sTop + winH * 2 > scH) {
switch (viewType) {
case 2:
newData();
break;
case 3:
hotData();
break;
}
}
if (sTop > nav2OffsetTop && $('#list-nav').length) {
if ($('#home-page').is(':hidden')) {
return false;
}
$nav2.removeClass('hide');
$nav1.addClass('hide');
} else if (sTop > nav1OffsetTop && $('#nav').length) {
$nav1.removeClass('hide');
$nav2.addClass('hide');
} else {
$nav1.addClass('hide');
$nav2.addClass('hide');
}
}
document.addEventListener('touchmove', function(e) {
// sub classify不阻止默认事件
if ($(e.target).closest('.sub-classify').length === 0) {
//e.preventDefault();
}
if ($('.filter-mask').length && !$('.filter-mask').hasClass('hide')) {
e.preventDefault();
}
}, false);
/* if (!isIphone) {
return;
}*/
// window ready 后重新refresh iscroll
$(window).ready(function() {
// myScroll && myScroll.refresh();
imgH = $('#nav-top').outerHeight();
nav1H = $('#nav').outerHeight();
main1H = $('#nav-main').height();
main1oH = $('#nav-main').outerHeight(true);
nav2H = $('#list-nav').outerHeight(true);
main2oH = $('#goods-container').outerHeight(true);
setTimeout(function() {
scH = $('#scroller').outerHeight();
}, 500);
$(document).scroll(scrollHandler)
lazyLoad($('img.lazy'));
});
function bindGoodThumbClick() {
$(document).trigger('rebindBpEvent');
}
function search(opt, callback) {
var setting = {},
ext,
att,
nav, navType,
page;
if (searching) {
return;
}
if (!opt.url) {
opt.url = '/product/search/search';
}
$pre = $listNav.find('.active').eq(0);
if (!opt.nextPage) {
// 筛选项变更则重置reload为true
for (att in navInfo) {
if (navInfo.hasOwnProperty(att)) {
navInfo[att].reload = true;
}
}
$listNav.children('.active').removeClass('active');
$pre.addClass('active');
if (opt.hasOwnProperty('id')) {
switch (opt.type) {
case 'shop_id':
ext = {
shop_id: opt.id
};
break;
case 'gender':
ext = {
gender: opt.id
};
ext.coverChannel = opt.id;
break;
case 'brand':
ext = {
brand: opt.id
};
break;
case 'sort':
ext = {
sort: opt.id
};
break;
case 'color':
ext = {
color: opt.id
};
break;
case 'size':
ext = {
size: opt.id
};
break;
case 'price':
ext = {
price: opt.id
};
break;
case 'discount':
ext = {
discount: opt.id
};
break;
case 'ageLevel':
ext = {
age_level: opt.id
};
break;
default:
break;
}
$.extend(defaultOpt, ext); // 扩展筛选项
}
}
// 导航类别
if ($pre.hasClass('new')) {
navType = 'newest';
} else if ($pre.hasClass('price')) {
navType = 'price';
} else if ($pre.hasClass('discount')) {
navType = 'discount';
}
nav = navInfo[navType];
page = nav.page + 1;
if (nav.reload) {
page = 1;
} else if (nav.end) {
// 不需要重新加载并且数据请求结束
return;
}
// 封面图,defaultOpt对象也有可能包含coverChannel,但defaultOpt优先级高
if (coverChannel) {
setting.coverChannel = coverChannel;
}
$.extend(setting, defaultOpt, {
type: navType,
order: nav.order,
page: page,
appVersion: appVersion
});
if (brand) {
setting.brand = brand;
}
if (shopId) {
setting.shop_id = shopId;
}
searching = true;
loading.showLoadingMask();
$.ajax({
type: 'GET',
url: opt.url ? opt.url : '',
data: setting,
success: function(data) {
var $container,
num;
switch (navType) {
case 'newest':
$container = $ngc;
break;
case 'price':
$container = $pgc;
break;
case 'discount':
$container = $dgc;
break;
default:
break;
}
if (data === '') {
nav.end = true;
if (nav.reload) {
$container.html(noResult);
}
} else {
if (nav.reload) {
$container.html(data);
lazyLoad($container.find('.lazy'));
} else {
num = $container.find('.good-info').length;
$container.append(data);
lazyLoad($container.find('.good-info:gt(' + (num - 1) + ') .lazy'));
}
}
scH = $('#scroller').outerHeight();
nav.reload = false;
nav.page = page;
searching = false;
loading.hideLoadingMask();
window.rePosFooter();
// myScroll && myScroll.refresh();
// reNav1Pos();
bindGoodThumbClick();
callback && callback();
},
error: function() {
tip.show('网络断开连接了~');
searching = false;
loading.hideLoadingMask();
callback && callback();
}
});
}
$listNav.bind('contextmenu', function(e) {
return false;
});
$subNav.on('touchend touchcancel', function(e) {
var $this = $(e.target).closest('li'),
cname,
nav,
navType,
$active;
var bpIdData = $this.attr('data-bp-id') || '';
e.preventDefault();
$(document).trigger('shouldSendBpData', [bpIdData]);
if (typeof $this === 'undefined' || $this.length === 0) {
return;
}
if ($this.hasClass('filter')) {
// 筛选面板切换状态
if ($this.hasClass('active') && !$('.filter-mask').hasClass('hide')) {
$('.home-sub-nav>li.filter').removeClass('active');
$this.removeClass('active');
filter.hideFilter();
} else {
$('.home-sub-nav>li.filter').addClass('active');
$this.addClass('active');
filter.showFilter();
if ($this.closest('.pos-list').length > 0) {
$('.filter-mask').addClass('call-by-fix').css('top', '');
} else {
$('.filter-mask').removeClass('call-by-fix').css('top', $this.offset().top + nav1H);
}
}
window.scrollTo(0, $('#list-nav').offset().top + 5)
} else {
filter.hideFilter();// 隐藏面板
if ($this.hasClass('new')) {
cname = '.new';
navType = 'newest';
} else if ($this.hasClass('price')) {
cname = '.price';
navType = 'price';
} else if ($this.hasClass('discount')) {
cname = '.discount';
navType = 'discount';
}
nav = navInfo[navType];
if ($this.hasClass('active')) {
// 最新无排序切换
if ($this.hasClass('new')) {
return;
}
if ($this.hasClass('price') || $this.hasClass('discount')) {
$this = $subNav.find(cname);
// 价格/折扣切换排序状态
$this.find('.icon > .iconfont').toggleClass('cur');
nav.reload = true; // 重置reload,HTML会被替换为逆序的HTML
nav.order = nav.order === 0 ? 1 : 0; // 切换排序
$goodsContainer.children('.container:not(.hide)').addClass('hide');
switch (navType) {
case 'newest':
$ngc.removeClass('hide');
break;
case 'price':
$pgc.removeClass('hide');
break;
case 'discount':
$dgc.removeClass('hide');
break;
default:
break;
}
}
} else {
$active = $subNav.find('.active');
if ($active.hasClass('filter')) {
// 若之前active项为筛选,则隐藏筛选面板
filter.hideFilter();
} else {
// 切换container显示
$goodsContainer.children('.container:not(.hide)').addClass('hide');
switch (navType) {
case 'newest':
$ngc.removeClass('hide');
break;
case 'price':
$pgc.removeClass('hide');
break;
case 'discount':
$dgc.removeClass('hide');
break;
default:
break;
}
}
$subNav.children().removeClass('active');
$subNav.find(cname).addClass('active');
}
if (nav.reload) {
search({
type: 'shop_id',
id: shopId,
brand: brand,
appVersion: appVersion,
url: '/product/search/search',
nextPage: false
}, function() {
window.scrollTo(0, $('#list-nav').offset().top + 5)
});
}
}
e.stopPropagation();
});
$listNav.on('touchstart', 'li', function(e) {
$(this).addClass('bytouch');
}).on('touchend touchcancel', function() {
$listNav.find('li').removeClass('bytouch');
});
$nav2.on('touchstart', 'li', function(e) {
$(this).addClass('bytouch');
}).on('touchend touchcancel', function() {
$nav2.find('li').removeClass('bytouch');
});
$('.shop-foot-wrapper .buriedpoint').click(function() {
var subGroup = $(this).find('.sub-group');
if (subGroup.hasClass('hide')) {
subGroup.removeClass('hide');
} else {
subGroup.addClass('hide');
}
});
// 店铺收藏 || 取消收藏
$collect.on('touchstart', function() {
var opt;
if (searching) {
return;
}
searching = true;
if ($collect.hasClass('already-collect')) {
opt = 'cancel';
} else {
opt = 'ok';
}
$.ajax({
method: 'get',
url: '' + '/product/opt/favoriteBrand',
data: {
id: favId ? favId : shopId,
appVersion: appVersion,
opt: opt,
type: 'shop',
uid: uid
},
xhrFields: {
withCredentials: true
},
success: function(data) {
var url = '';
if (data.code === 200) {
if ($collect.hasClass('already-collect')) {
$collect.attr('class', 'not-collect');
tip.show('店铺取消收藏成功');
} else {
$collect.attr('class', 'already-collect');
tip.show('店铺收藏成功');
}
}
if (data.code === 400) {
url = data.data;
if ($('#jump-login').length <= 0) {
$('body').append('<a href=\'' + url + '\'><span id="jump-login"><span></a>');
}
$('#jump-login').click();
}
setTimeout(function() {
myScroll && myScroll.refresh();
scH = $('#scroller').outerHeight();
}, 500);
searching = false;
},
error: function() {
tip.show('网络断开连接了~');
searching = false;
}
});
});
... ...
... ... @@ -15,6 +15,11 @@ shopCoupon = {
couponTemplate: require('product/shop/coupon.hbs')
},
init: function() {
// 如果都为空,则不请求
if (this.common.shopId === '' && this.common.brandId === '') {
return true;
}
this.loginCoupon();
this.getShopCouponsList();
},
... ...
... ... @@ -77,3 +77,8 @@
}
}
}
.single-one {
margin-bottom: -2PX;
z-index: 2;
}
... ...
.banner-top {
position: relative;
margin-bottom: -2PX;
.swiper-pagination {
position: absolute;
... ...
.divide-image {
height: 30px;
height: 26px;
width: 100%;
background-size: 100% 100%;
}
\ No newline at end of file
... ...
... ... @@ -30,7 +30,7 @@
font-size: 28px;
height: 40px;
line-height: 40px;
color: #444;
color: #b0b0b0;
float: left;
border: none;
background: transparent;
... ... @@ -38,6 +38,22 @@
width: 380px;
}
input::-webkit-input-placeholder {
color: #e0e0e0;
}
input:-moz-placeholder {
color: #e0e0e0;
}
input::-moz-placeholder {
color: #e0e0e0;
}
input:-ms-input-placeholder {
color: #e0e0e0;
}
.notice {
float: left;
font-size: 28px;
... ...
... ... @@ -150,6 +150,7 @@
line-height: 85px;
margin: 0;
border-top: none;
background: #fff;
}
h2 {
... ... @@ -307,7 +308,6 @@
.advertisement-box {
width: 540px;
height: 550px;
background: rgba(255, 255, 255, 0.6);
border-radius: 15px;
position: absolute;
top: 50%;
... ...
... ... @@ -75,13 +75,6 @@ module.exports = (list) => {
floor.data.length === 1 &&
(floor.singleOne = true);
// vip专享 人气单品背景处理
if ((floor.vipUse || floor.popularSingleProduct || floor.newUserFloor) && floor.data && floor.data.background) {
let a = floor.data.background.src;
a = a.substr(0, a.indexOf('?'));
floor.data.background.src = a;
}
// 处理价格两位小数
if ((floor.vipUse || floor.popularSingleProduct || floor.newUserFloor) && floor.data) {
for (let item of floor.data.list) {
... ... @@ -93,24 +86,11 @@ module.exports = (list) => {
}
}
// 图标楼层背景图
if (floor.appIconList && floor.back_image) {
let a = floor.back_image;
a = a.substr(0, a.indexOf('?'));
floor.back_image = a;
}
// sale banner名字
if (floor.sale1T1L4R && floor.data && floor.data.big_image) {
floor.data.banner_image = floor.data.big_image;
}
// 分隔图楼层
if (floor.divideImage && floor.divideImage.data && floor.divideImage.data.src) {
let a = floor.divideImage.data.src;
a = a.substr(0, a.indexOf('?'));
floor.divideImage.data.src = a;
}
formatData.push(floor);
});
... ...