Authored by ccbikai(👎🏻🍜)

Merge branch 'release/5.4.1' into gray

... ... @@ -32,67 +32,56 @@ const handleBrandList = origin => {
indexList: []
};
let keyList = [];
// 标记是否有数字,有数字先暂存
let hasNum = false;
let numTemp = {};
_.forEach(origin, (value, key) => {
let brands = [];
if (_.size(value) <= 0) {
return;
}
_.forEach(value, function(subValue) {
subValue.brandUrl = '//m.yohobuy.com/product/index/brand?domain=' + subValue.brand_domain + '&app_type=1';
subValue.name = subValue.brand_name_en || subValue.brand_name_cn || subValue.brand_name;
subValue.domain = subValue.brand_domain;
});
if (key === '0~9') {
hasNum = true;
numTemp = origin[key];
} else {
_.forEach(value, (subValue) => {
brands.push({
name: subValue.brand_name_en || subValue.brand_name_cn || subValue.brand_name,
logo: subValue.brand_ico,
domain: subValue.brand_domain,
brandUrl: '//m.yohobuy.com/product/index/brand?domain=' + subValue.brand_domain + '&app_type=1'
});
});
dest.ListData.push({
index: key,
brands: brands
});
dest.indexList.push({
index: key,
name: key === '0~9' ? '0' : key
});
keyList.push(key);
}
});
// 商品列表排序一次
_.sortBy(dest.ListData, o => {
return o.index.charCodeAt();
});
keyList.sort();
_.forEach(keyList, function(key) {
let keyName = key;
// 字母列表排序一次
_.sortBy(dest.indexList, o => {
return o.index.charCodeAt();
dest.ListData.push({
index: keyName,
brands: origin[key]
});
dest.indexList.push({
index: keyName,
name: key === '0~9' ? '0' : key
});
});
// 如果有数字,单独处理
if (hasNum) {
let brands = [];
_.forEach(numTemp, (subValue) => {
brands.push({
name: subValue.brand_name_en || subValue.brand_name_cn || subValue.brand_name,
logo: subValue.brand_ico,
domain: subValue.brand_domain
});
});
dest.ListData.push({
index: '0~9',
brands: brands
brands: numTemp
});
dest.indexList.push({
... ... @@ -167,6 +156,7 @@ const _getBrandListOriginData = (channel) => {
});
};
// 全部分类数据
const _processCateData = (list, channel, appType) => {
let nav = ['MEN男士', 'WOMEN女士'];
... ... @@ -301,8 +291,6 @@ const brandListData = (code, gender) => {
});
};
module.exports = {
indexData,
brandListData
... ...
... ... @@ -31,7 +31,7 @@
<div class="brand-box">
<a href="{{brandUrl}}">
<div class="brand-logo">
<img src="{{image logo 136 136}}">
<img src="{{image brand_ico 136 136}}">
</div>
<span class="brand-name">
{{name}}
... ...
... ... @@ -101,7 +101,7 @@ exports.record = (req, res, next) => {
indexModel.recordContent(uid, udid, page, limit).then((result) => {
if (result.browseRecord && result.browseRecord.length > 0) {
if (result && result.browseRecord && result.browseRecord.length > 0) {
responseData.browseRecord = result.browseRecord;
} else {
responseData.noRecord = true;
... ...
... ... @@ -8,6 +8,7 @@ const detailModel = require('../models/detail');
const newDetailModel = require('../models/new-detail');
const listModel = require('../models/list');
const headerModel = require('../../../doraemon/models/header'); // 头部model
const helpers = global.yoho.helpers;
const newDetail = {
index(req, res, next) {
... ... @@ -113,7 +114,8 @@ const newDetail = {
message: '数据错误'
});
}
result.studentPrice = req.__User__.isStudent && result && result.goodsPrice && result.goodsPrice.studentPrice ? result.goodsPrice.studentPrice : false;
result.studentPrice = req.__User__.isStudent && result && result.goodsPrice &&
result.goodsPrice.studentPrice ? result.goodsPrice.studentPrice : false;
return res.json(result);
}).catch(next);
},
... ... @@ -128,12 +130,22 @@ const newDetail = {
res.setHeader('Access-Control-Allow-Origin', allowOrigin);
res.setHeader('Access-Control-Allow-Credentials', 'true');
let uid = req.user.uid;
if (!uid) {
return res.json({
code: 400,
data: helpers.urlFormat('/signin.html', {
refer: req.originalUrl
})});
}
if (req.body.opt === 'ok') {
listModel.setFavorite(req.body.id, req.user.uid, 'product').then(result => {
listModel.setFavorite(req.body.id, uid, 'product').then(result => {
return res.json(result);
}).catch(next);
} else {
listModel.setFavoriteCancel(req.body.id, req.user.uid, 'product').then(result => {
listModel.setFavoriteCancel(req.body.id, uid, 'product').then(result => {
return res.json(result);
}).catch(next);
}
... ...
... ... @@ -2,7 +2,7 @@
* @Author: Targaryen
* @Date: 2016-05-18 11:42:11
* @Last Modified by: Targaryen
* @Last Modified time: 2017-02-23 10:53:15
* @Last Modified time: 2017-02-24 15:18:50
*/
'use strict';
... ... @@ -24,7 +24,14 @@ module.exports = (data) => {
shopId: data.shopId,
yh_channel: yhchannelMap[data.yhChannel]
}).then(result => {
result = $.load(result)('#goods-container').append(
let goodsContainer = $.load(result)('#goods-container');
let goodThumb = goodsContainer.find('.good-thumb');
goodThumb.each(function(index, domEle) {
$(domEle).attr('href', $(domEle).attr('href').split('?')[0]);
});
result = goodsContainer.append(
`<script type="text/javascript">
(function() {
var qs = {};
... ...
... ... @@ -176,7 +176,7 @@ router.get('/newsale/selectHotrank', newsale.selectHotrank); // 热销排行榜
router.get('/bundle/detail', bundle.detail); // 套装详情页
router.post('/opt/favoriteProduct', auth, newDetail.favoriteProduct); // 商品收藏、取消收藏
router.post('/opt/favoriteProduct', newDetail.favoriteProduct); // 商品收藏、取消收藏
router.get('/detail/limitHelp', newDetail.limitHelp);
module.exports = router;
... ...
... ... @@ -48,6 +48,10 @@ $nav.on('touchend touchcancel', function(e) {
$contents.addClass('hide');
$contents.filter(selector).removeClass('hide');
$('html,body').animate({
scrollTop: 0
}, 100);
});
$categoryContainer.on('click', function(e) {
... ...
... ... @@ -6,7 +6,14 @@ var categoryHeight = $('.tab-box').height(),
var $intercept = $('.no-intercept'),
$list = $('.brand-list-box'),
$listBox = $('.list-box');
$listBox = $('.list-box'),
$brandContent = $('.brand-content'),
$tabBox = $('.tab-box'),
$contentIndex = $('.content-index'),
$categoryNav = $('.category-nav'),
$channelTab = $('.channel-tab'),
$categoryContent = $('.category-content'),
$brandCha = $('.brand-cha');
require('../common');
require('./brand-cate/cate-all');
... ... @@ -48,14 +55,21 @@ function loadData(channel) {
gender: channel
},
success: function(data) {
$('.brand-content').html(data);
$brandContent.html(data);
initialize();
$('html,body').animate({
scrollTop: 0
}, 100, function() {
$tabBox.removeClass('fastening');
$contentIndex.removeClass('distance');
});
}
});
}
$('.brand-cha').find('li').click(function() {
$brandCha.find('li').click(function() {
gender = $(this).find('span').text().replace(/[^A-Za-z]+/g, '').toLowerCase();
$(this).addClass('focus').siblings().removeClass('focus');
... ... @@ -79,15 +93,30 @@ $('.brand-tab').find('li').click(function() {
$(this).addClass('active').siblings().removeClass('active');
if ($(this).hasClass('brand')) {
$('.brand-content').removeClass('hide').siblings().addClass('hide');
$('.channel-tab').removeClass('hide');
$('.brand-cha').removeClass('hide').siblings().addClass('hide');
$brandContent.removeClass('hide').siblings().addClass('hide');
$channelTab.removeClass('hide');
$brandCha.removeClass('hide').siblings().addClass('hide');
} else {
$('.category-content').removeClass('hide').siblings().addClass('hide');
$categoryContent.removeClass('hide').siblings().addClass('hide');
$('.channel-tab').addClass('hide');
}
initialize();
// 页面切换回到头部
$('html,body').animate({
scrollTop: 0
}, 100, function() {
if (!$brandContent.hasClass('hide')) {
$tabBox.removeClass('fastening');
$contentIndex.removeClass('distance');
} else {
$tabBox.removeClass('fastening');
$categoryNav.removeClass('loca');
$('.blk-cate-all .content').removeClass('living');
$contentIndex.removeClass('distance');
}
});
});
if ($listBox.find('li').length <= 0) {
... ... @@ -97,24 +126,24 @@ if ($listBox.find('li').length <= 0) {
$(window).scroll(function() {
var totalHeight = $('#yoho-header').height() + $('.tab-box').height();
if (!$('.brand-content').hasClass('hide')) {
if (!$brandContent.hasClass('hide')) {
if ($(this).scrollTop() >= $('#yoho-header').height()) {
$('.tab-box').addClass('fastening');
$('.content-index').addClass('distance');
$tabBox.addClass('fastening');
$contentIndex.addClass('distance');
$('.list-box').css('top', $('.tab-box').height());
} else {
$('.tab-box').removeClass('fastening');
$('.content-index').removeClass('distance');
$tabBox.removeClass('fastening');
$contentIndex.removeClass('distance');
$('.list-box').css('top', totalHeight - $(this).scrollTop());
}
} else {
if ($(this).scrollTop() >= $('#yoho-header').height()) {
$('.tab-box').addClass('fastening');
$('.category-nav').addClass('loca');
$tabBox.addClass('fastening');
$categoryNav.addClass('loca');
$('.blk-cate-all .content').addClass('living');
} else {
$('.tab-box').removeClass('fastening');
$('.category-nav').removeClass('loca');
$tabBox.removeClass('fastening');
$categoryNav.removeClass('loca');
$('.blk-cate-all .content').removeClass('living');
}
}
... ...
... ... @@ -70,7 +70,6 @@
}
.content-index {
.search {
width: 100%;
height: 88px;
... ... @@ -190,7 +189,7 @@
.list-box {
position: fixed;
width: 30px;
width: 38px;
margin: 0;
padding: 6px 0;
right: 0;
... ... @@ -206,9 +205,10 @@
width: 100%;
a {
font-size: 26px;
font-size: 27px;
display: inline-block;
width: 100%;
padding: 1px 0;
}
}
}
... ... @@ -256,85 +256,6 @@
display: none;
}
/*.category-content {
.category-container {
margin-bottom: 100px;
}
.content {
background: #f8f8f8;
overflow: hidden;
position: relative;
&.hide {
display: none;
}
}
.primary-level {
float: left;
box-sizing: border-box;
width: 45%;
> li {
height: 89px;
line-height: 89px;
padding: 0 32px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
&.focus {
background-color: #fff;
}
&.highlight {
background-color: #eee;
}
}
}
.sub-level-container {
float: left;
overflow-x: auto;
box-sizing: border-box;
background: #fff;
width: 55%;
height: 100%;
}
.sub-level {
width: 100%;
&.hide {
display: none;
}
> li {
box-sizing: border-box;
height: 89px;
line-height: 89px;
border-bottom: 1px solid #e6e6e6;
padding-left: 20px;
&.highlight {
background: #eee;
}
&:last-child {
border-bottom: none;
}
}
a {
display: block;
height: 100%;
width: 100%;
color: #000;
}
}
}*/
.resources {
.recommend-content-five {
margin-top: -1px;
... ...
... ... @@ -124,7 +124,8 @@ $basicBtnC: #eb0313;
.portrait img {
display: block;
/*margin: 84px auto;*/
/* margin: 84px auto; */
max-width: 100%;
border: 0;
width: 124px;
... ... @@ -1082,6 +1083,7 @@ $basicBtnC: #eb0313;
.recommend-for-you {
border-bottom: none;
padding-left: 15px;
.tag-container {
overflow: hidden;
... ...