Authored by 陈峰

merge master

... ... @@ -7,9 +7,7 @@ const _ = require('lodash');
const helpers = global.yoho.helpers;
const crypto = global.yoho.crypto;
const SUB_DOMAIN = '.dev.yohobuy.com',
OLD_MAIN = '//m.yohobuy.com',
SITE_MAIN = '//m.dev.yohobuy.com';
const SITE_MAIN = '//m.yohobuy.com';
/**
* 仿php的strrpos
... ... @@ -60,7 +58,8 @@ const getShare = (code, shareTitle, shareDesc, shareImg) => {
* 过滤app的url
*/
const _getFilterUrl = url => {
url = url.replace('.m.yohobuy.com', SUB_DOMAIN).replace(OLD_MAIN, SITE_MAIN).replace('www.yohobuy.com', SITE_MAIN);
url = url.replace('www.yohobuy.com', SITE_MAIN);
if (strrpos(url, 'm.yohobuy.com') && !strrpos(url, 'sale.m.yohobuy.com') && !strrpos(url, 'cuxiao.m.yohobuy.com') &&
!strrpos(url, 'activity.m.yohobuy.com') && !strrpos(url, 'huodong.m.yohobuy.com') &&
strrpos(url, 'cdn.yoho.cn/myohobuy') && !strrpos(url, '/home/orders/pay')) {
... ... @@ -353,4 +352,4 @@ exports.receiveCoupon = (receiveData, uid) => {
}
return returnData;
});
};
};
\ No newline at end of file
... ...
... ... @@ -88,7 +88,7 @@ const pageData = (req, res, next) => {
authorId = req.query.authorId,
isApp = req.yoho.isApp || false,
isTab = req.query.isTab || false,
showAuthor = true;
showAuthor = false;
let uid = req.user.uid,
udid = req.sessionID;
... ... @@ -102,7 +102,7 @@ const pageData = (req, res, next) => {
return;
}
if (!authorId && isNaN(authorId)) {
showAuthor = false;
showAuthor = true;
}
return indexModel.getPageData(gender, sortId, uid, udid, page, tag, authorId, isApp, showAuthor, isTab).then(data => {
if (data) {
... ...
... ... @@ -29,6 +29,7 @@ const _pageArticleContent = (articleContent, isApp, gender) => {
return new Promise((resolve) => {
let joinContentFunc = (i, len) => {
if (i < len) {
let build = {};
let art = articleContent[i];
... ... @@ -160,6 +161,7 @@ const _pageArticleContent = (articleContent, isApp, gender) => {
resolve(contents);
}
};
joinContentFunc(0, articleContent.length);
});
};
... ... @@ -170,6 +172,7 @@ const _pageArticleContent = (articleContent, isApp, gender) => {
*/
const _relatedBrand = (getBrand) => {
let relatedBrand = getBrand;
relatedBrand.forEach(brand => {
brand.thumb = brand.thumb.replace('http://', '//');
});
... ... @@ -183,6 +186,7 @@ const _relatedBrand = (getBrand) => {
*/
const _relatedTag = (tags, isApp) => {
let relatedTag = [];
tags.forEach(value => {
if (!isApp) {
value.url = helpers.urlFormat('/tags/index', {
... ... @@ -201,6 +205,7 @@ const _relatedTag = (tags, isApp) => {
*/
const _relatedInfo = (getOtherArticle, isApp) => {
let relatedInfo = [];
getOtherArticle.forEach(value => {
if (!isApp) {
value.url = helpers.urlFormat('/info/index', {
... ... @@ -220,6 +225,7 @@ const _relatedInfo = (getOtherArticle, isApp) => {
*/
const _shareInfo = (id, getArticle) => {
let shareInfo = {};
shareInfo.shareLink = helpers.urlFormat('/info/index', {
id: id
}, 'guang');
... ... @@ -281,7 +287,7 @@ const index = (req, res, next) => {
}
// 作者信息数据
if (typeof detail.getAuthor.name !== 'undefined') {
if (detail && detail.getAuthor && (typeof detail.getAuthor.name !== 'undefined')) {
data.guang.author = {
avatar: detail.getAuthor.avatar.replace('http://', '//'),
name: detail.getAuthor.name,
... ... @@ -324,7 +330,6 @@ const index = (req, res, next) => {
// 分享参数
if (detail.getArticle.cover_image) {
let shareInfo = _shareInfo(id, detail.getArticle);
Object.assign(guang, shareInfo);
data.title = detail.getArticle.article_title + ' | Yoho!Buy有货 | 潮流购物逛不停';
data.title_more = true;
... ... @@ -399,6 +404,7 @@ const mini = (req, res, next) => {
// 分享参数
if (detail.getArticle.cover_image) {
let shareInfo = _shareInfo(id, detail.getArticle);
Object.assign(guang, shareInfo);
}
... ... @@ -454,9 +460,11 @@ const foryoho = (req, res, next) => {
let relatedRecoIndex = data.content.findIndex((cont) => {
return typeof cont.relatedReco !== 'undefined';
});
let collocationIndex = data.content.findIndex((cont) => {
return typeof cont.collocation !== 'undefined';
});
if (relatedRecoIndex > 0) {
data.goods = data.content[relatedRecoIndex].relatedReco;
data.content.splice(relatedRecoIndex, 1);
... ...
... ... @@ -124,8 +124,9 @@ const getPageData = (gender, sortId, uid, udid, page, tag, authorId, isApp, show
let artList = article.data.list.artList;
artList.forEach(art => {
// build.push(guangProcess.formatArticle(art, true, isApp, showAuthor, uid));
build.push(guangProcess.formatArticle(art, true, isApp, true, uid));
build.push(guangProcess.formatArticle(art, true, isApp, showAuthor, uid));
// build.push(guangProcess.formatArticle(art, true, isApp, true, uid));
});
result.infos = build;
return result;
... ...
<div class="guang-list-page guang-page yoho-page">
{{# guang}}
{{# authorInfo}}
<div id="author-infos" class="editor-header clearfix" data-id={{id}}>
<div id="author-infos" class="editor-header clearfix" data-id={{uid}}>
<div class="avatar">
<img src="{{avatar}}">
</div>
... ...
... ... @@ -237,6 +237,10 @@ const brand = (req, res, next) => {
}
listModel.getBrandLogoByDomain(domain).then(result => {
if (!result) {
return next();
}
brandLogo = result;
title = brandLogo.name;
... ...
... ... @@ -98,14 +98,17 @@ let _processComment = (data) => {
comments: []
};
_.forEach(data.pageResponse.list, (item) => {
result.comments.push({
userName: item.userInfo ? item.userInfo.nickName : '',
desc: item.goods ? `${item.goods.color_name}/${item.goods.size_name}` : '',
content: item.content,
time: helpers.dateFormat('YYYY-MM-DD HH:mm:ss', new Date(item.createTime * 1000))
if (data && data.pageResponse) {
_.forEach(data.pageResponse.list, (item) => {
result.comments.push({
userName: item.userInfo ? item.userInfo.nickName : '',
desc: item.goods ? `${item.goods.color_name}/${item.goods.size_name}` : '',
content: item.content,
time: helpers.dateFormat('YYYY-MM-DD HH:mm:ss', new Date(item.createTime * 1000))
});
});
});
}
return result;
};
... ...
... ... @@ -335,9 +335,10 @@ const _formShopData = (data, shopId, isApp) => {
}
};
_.forEach(resData, (cate) => {
_.forEach(resData, cate => {
hotCategory.data.list.push({
url: cate.url,
url: isApp ? _modifyAppUrl(cate, shopId) :
_modifyWapUrl(cate, shopId),
src: helpers.image(cate.src),
name: cate.name
});
... ... @@ -598,16 +599,18 @@ const getBrandIntro = (brandId, uid) => {
code: 200,
cache: true
}).then(result => {
if (result && result.data) {
let list = result.data;
let list = result.data;
return {
id: list.brand_id,
intro: list.brand_intro,
collected: list.is_favorite && list.is_favorite === 'Y',
title: list.brand_name ? list.brand_name : ''
};
return {
id: list.brand_id,
intro: list.brand_intro,
collected: list.is_favorite && list.is_favorite === 'Y',
title: list.brand_name ? list.brand_name : ''
};
} else {
return false;
}
});
};
... ... @@ -646,10 +649,9 @@ const getBrandLogoByDomain = (domain) => {
method: 'web.brand.byDomain',
domain: domain
}, {
code: 200,
cache: true
}).then(result => {
if (result.data) {
if (result && result.data) {
let formatData = result.data;
return {
... ...
... ... @@ -71,7 +71,7 @@ const getNewFocus = (channel) => {
const getSearchData = (params) => {
return _searchGoods(params).then((result) => {
if (result && result.code === 200) {
return productProcess.processProductList(result.data.product_list || []);
return productProcess.processProductList(result.data.product_list || [], {showTags: false});
} else {
logger.error('get product search api return code is not 200');
return [];
... ...
... ... @@ -13,6 +13,15 @@ const api = global.yoho.API;
const camelCase = global.yoho.camelCase;
/**
* 封面图
* @type {{boys: string, gilrs: string}}
*/
const _coverChannel = {
boys: '1,3',
gilrs: '2,3'
};
/**
* 品牌名称处理
* @param {[object]} list
* @return {[object]}
... ... @@ -82,6 +91,10 @@ const _searchGoods = (params) => {
delete params.filter_poolId;
}
if (params.brand) {
method = 'app.search.brand';
}
// 排除基本筛选项默认值为0的对象
for (let str in params) {
if (str !== 'order' && params[str] === '0' || params[str] === null) {
... ... @@ -104,6 +117,8 @@ const _searchGoods = (params) => {
if (params.order) {
params.order = searchProcess.getTypeCont(params.type || '', params.order);
} else {
params.order = 's_t_asc';
}
return api.get('', _.assign({
... ... @@ -119,7 +134,10 @@ const _searchGoods = (params) => {
const getSearchData = (params) => {
return _searchGoods(params).then((result) => {
if (result && result.code === 200) {
return productProcess.processProductList(result.data.product_list || []);
return productProcess.processProductList(result.data.product_list || [], {
isApp: params.appVersion && params.appVersion !== 'false',
gender: _coverChannel[params.coverChannel]
});
} else {
logger.error('get product search api return code is not 200');
return [];
... ...
... ... @@ -42,4 +42,4 @@
{{> common/suspend-cart}}
</div>
{{> download-app}}
{{download-app}}
... ...
... ... @@ -18,15 +18,14 @@ module.exports = {
assetUrl: '//localhost:5001',
domains: {
api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/',
// liveApi: 'http://api.live.yoho.cn/',
// singleApi: 'http://single.yoho.cn/',
service: 'http://service.yoho.cn/',
liveApi: 'http://api.live.yoho.cn/',
singleApi: 'http://single.yoho.cn/',
// api: 'http://api-test1.yohops.com:9999/',
service: 'http://service-test1.yohops.com:9999/',
liveApi: 'http://testapi.live.yohops.com:9999/',
singleApi: 'http://api-test1.yohops.com:9999/',
// service: 'http://service-test1.yohops.com:9999/',
// liveApi: 'http://testapi.live.yohops.com:9999/',
// singleApi: 'http://api-test1.yohops.com:9999/',
},
subDomains: {
host: '.m.yohobuy.com',
... ...
... ... @@ -120,7 +120,7 @@ function rePosFooter() {
winH = Math.min($(window).height(), window.screen.availHeight);
if ($('body').height() <= winH - parseInt($footer.css('height'), 0)) {
if ($('body').height() <= winH) {
$footer.addClass('bottom');
} else {
$footer.removeClass('bottom');
... ...
... ... @@ -94,6 +94,10 @@ function setSubClassify($this) {
$shower.removeClass('default');
}
if (hCbFn) {
hCbFn();
}
return $sub;
}
... ... @@ -139,8 +143,8 @@ function initFilter(opt) {
var $this = $(e.target),
$cur;
//这行不能注释,iphone下会出现穿透
e.preventDefault();//防止透点
// 这行不能注释,iphone下会出现穿透
e.preventDefault();// 防止透点
if ($this.closest('.filter-body').length > 0) {
$cur = $this.closest('.sub-item');
... ...
... ... @@ -223,7 +223,7 @@ function search(opt) {
break;
}
if (data === ' ') {
if (data === ' ' || data === '') {
nav.end = true;
if (nav.reload) {
$container.html(noResult);
... ...
... ... @@ -31,6 +31,8 @@ var historyval = writeSearch.getHistoryval();
var chHammer, cHammer;
require('../../common');
chHammer = new Hammer($clearHistory[0]);
chHammer.on('tap', function() {
... ... @@ -50,7 +52,7 @@ chHammer.on('tap', function() {
$historySearch.hide();
$clearHistory.hide();
// window.rePosFooter();
window.rePosFooter();
dialog.showDialog({
dialogText: '删除成功',
... ...
... ... @@ -89,7 +89,7 @@ ellipsis.init();
tip.show('网络断开连接了~');
}
});
} else if ($('.shopId').val().length > 0){
} else if ($('.shopId').val().length > 0) {
$.ajax({
url: '/product/index/baseShopFav',
data: {
... ... @@ -192,7 +192,7 @@ function getQueryString(name) {
shopId = getQueryString('shop_id');
sort = getQueryString('sort');
outlets = getQueryString('outlets');
age_level = getQueryString('ageLevel');
age_level = getQueryString('age_level');
app_type = getQueryString('app_type');
msort = getQueryString('msort');
misort = getQueryString('misort');
... ... @@ -218,7 +218,6 @@ function search(opt) {
}
if (opt) {
// 筛选项变更则重置reload为true
for (att in navInfo) {
if (navInfo.hasOwnProperty(att)) {
... ... @@ -255,7 +254,7 @@ function search(opt) {
color: opt.id
};
break;
case 'age_level':
case 'ageLevel':
ext = {
age_level: opt.id
};
... ...
... ... @@ -35,7 +35,7 @@ var $subNav = $('.home-sub-nav'),
appVersion = $('input[name="app_version"]').val(),
brand = $('input[name="brand"]').val(),
coverChannel = $('input[name="coverChannel"]').val(),
favId = $('input[name="favId"]').val();
favId = $('input[name="favId"]').val(),
uid = $('input[name="uid"]').val();
var winH = $(window).height(),
... ... @@ -228,9 +228,10 @@ function newData(callback) {
req.url = location.protocol + '//m.yohobuy.com/product/search/search';
req.data = {
type: 'new',
order: '1',
order: '0',
page: navInfo.new.page,
tagNew: '1'
tagNew: '1',
appVersion: appVersion
};
getParam(req);
... ... @@ -255,7 +256,8 @@ function hotData(callback) {
type: 'hot',
order: '1',
page: navInfo.hot.page,
showTag: '1'
showTag: '1',
appVersion: appVersion
};
getParam(req);
... ... @@ -643,7 +645,8 @@ function search(opt) {
$.extend(setting, defaultOpt, {
type: navType,
order: nav.order,
page: page
page: page,
appVersion: appVersion
});
if (brand) {
... ... @@ -857,6 +860,7 @@ $subNav.on('touchend touchcancel', function(e) {
type: 'shop_id',
id: shopId,
brand: brand,
appVersion: appVersion,
url: location.protocol + '//m.yohobuy.com/product/search/search',
nextPage: false
});
... ...
... ... @@ -139,6 +139,7 @@
top: 0;
color: #C0C0C0;
z-index: 2;
font-size: 18PX;
}
}
... ...
... ... @@ -36,7 +36,7 @@
.search {
position: absolute;
top: 18px;
top: 14px;
right: 40px;
border: none;
background: transparent;
... ...
... ... @@ -587,6 +587,7 @@
margin-top: 1px;
.filter-body {
top: 1px;
overflow: auto;
}
... ...
... ... @@ -133,26 +133,35 @@ exports.processProductList = (list, options) => {
}
if (options.showTags) {
product.tags = {};
product.tags.is_new = options.showNew && product.is_new === 'Y'; // 新品
product.tags.is_discount = options.showSale && product.is_discount === 'Y'; // 在售
product.tags.is_limited = product.is_limited === 'Y'; // 限量
product.tags.is_yohood = product.is_yohood === 'Y'; // YOHOOD
product.tags.mid_year = product.mid_year === 'Y'; // 年中
product.tags.year_end = product.year_end === 'Y'; // 年末
product.tags.is_advance = product.is_advance === 'Y'; // 再到着
// 打折与即将售完组合显示打折
if (product.is_soon_sold_out && product.tags.is_discount) {
product.tags.is_new = false;
} else if (product.tags.is_discount &&
(product.tags.is_new || product.tags.is_limited || product.tags.is_yohood || product.tags.is_advance)) {
// 打折与其它组合则隐藏打折
product.tags.is_discount = false;
} else if (product.tags.is_yohood && product.tags.is_new) {
// YOHOOD和新品组合显示YOHOOD
product.tags.is_new = false;
}
let tags = {};
_.forEach(product.tags, tag => {
tags[_.camelCase(tag)] = true;
});
product.tags = tags;
// 商品标签不再自行处理,直接使用接口返回的 is_yohood,is_new,is_discount,is_limited,is_soon_sold_out,mid-year,year-end
// product.tags = {};
// product.tags.isNew = options.showNew && product.isNew === 'Y'; // 新品
// product.tags.isDiscount = options.showSale && product.isDiscount === 'Y'; // 在售
// product.tags.isLimited = product.isLimited === 'Y'; // 限量
// product.tags.isYohood = product.isYohood === 'Y'; // YOHOOD
// product.tags.midYear = product.midYear === 'Y'; // 年中
// product.tags.yearEnd = product.yearEnd === 'Y'; // 年末
// product.tags.isAdvance = product.isAdvance === 'Y'; // 再到着
// // 打折与即将售完组合显示打折
// if (product.isSoonSoldOut && product.tags.isDiscount) {
// product.tags.isNew = false;
// } else if (product.tags.isDiscount &&
// (product.tags.isNew || product.tags.isLimited || product.tags.isYohood || product.tags.isAdvance)) {
// // 打折与其它组合则隐藏打折
// product.tags.isDiscount = false;
// } else if (product.tags.isYohood && product.tags.isNew) {
// // YOHOOD和新品组合显示YOHOOD
// product.tags.isNew = false;
// }
}
pruductList.push(product);
... ...
... ... @@ -55,6 +55,10 @@ const getTypeCont = (type, order) => {
return order === '0' ? 'd_s_desc' : 'd_s_asc';
case 'category':
return order === '0' ? 's_t_desc' : 's_t_asc';
case 'new':
return order === '0' ? 's_t_desc' : 's_t_asc';
case 'hot':
return order === '0' ? 's_n_desc' : 's_n_asc';
default:
return order === '0' ? 's_t_desc' : 's_t_asc';
}
... ...