Authored by ccbikai(👎🏻🍜)

Merge branch 'gray'

... ... @@ -17,6 +17,7 @@ exports.productLst = function(req, res, next) {
specified_sort: req.query.enum,
stocknumber: req.query.sn,
p_d: req.query.pd,
noDup: req.query.noDup,
limit: req.query.limit || 10
};
... ...
... ... @@ -27,7 +27,9 @@ module.exports = {
productLst: function(params) {
return api.get('', Object.assign({
method: 'app.search.newPromotion'
}, params)).then(res => {
}, params), {
cache: true
}).then(res => {
var data = [],
lst = (res.data && res.data.product_list) || [];
... ...
/**
* 唤起苹果 app 配置文件
*/
'use strict';
let configFile = `
{
"applinks": {
"apps": [],
"details": [
{
"appID": "6U82P566A4.com.yoho.buy",
"paths": [ "*"]
},
{
"appID": "EX33S4LRW7.com.yoho.buy",
"paths": [ "*" ]
}
]
}
}
`;
const appSiteAssociation = (req, res) => {
res.set('Content-Disposition', 'attachment; filename="apple-app-site-association"');
res.send(configFile);
};
module.exports = {
appSiteAssociation
};
... ...
... ... @@ -13,12 +13,13 @@ var multipart = require('connect-multiparty');
var multipartMiddleware = multipart();
const uploadApi = require(cRoot + '/upload.js');
const hotfix = require(`${cRoot}/hotfix`);
const apple = require(`${cRoot}/apple`);
// routers
router.post('/api/upload/image', multipartMiddleware, uploadApi.uploadImg);
router.post('/hf/v1', hotfix.v1);
router.get('/.well-known/apple-app-site-association', apple.appSiteAssociation);
module.exports = router;
... ...
... ... @@ -83,8 +83,7 @@ const getDetailData = (req, res, next) => {
let udid = req.sessionID || 'yoho';
let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || '1,3';
let isApp = req.query.app_version || req.query.appVersion || false;
let clientType = req.body.client_type || '';
let version = req.body.app_version || '';
let clientType = (req.body.client_type || '').toLowerCase();
let userAgent = req.get('User-Agent');
let isWeixin = userAgent.includes('MicroMessenger'); // 标识是否是微信访问
... ... @@ -96,9 +95,9 @@ const getDetailData = (req, res, next) => {
uid = req.user.uid;
}
if (clientType.toLowerCase() === 'ios' && version) {
if (clientType === 'ios' && isApp) {
clientType = 'iphone';
} else if (clientType.toLowerCase() === 'android' && version) {
} else if (clientType === 'android' && isApp) {
clientType = 'android';
} else {
clientType = 'h5';
... ...
... ... @@ -31,7 +31,6 @@ const getAuthor = (id) => {
});
};
/**
* 逛分类
*/
... ... @@ -108,27 +107,21 @@ const getPageData = (gender, sortId, uid, udid, page, tag, authorId, isApp, show
// 广告列表
if (isTab && adList) {
let build = [];
adList.forEach(ad => {
build.push({
result.swiper = adList.map(function(ad) {
return {
url: guangProcess.getFilterUrl(ad.url),
img: helpers.image(ad.src, 830, 327)
});
};
});
result.swiper = build;
}
/* 构建资讯文章内容 */
let build = [];
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));
result.infos = artList.map(function(art) {
return guangProcess.formatArticle(art, true, isApp, showAuthor, uid);
});
result.infos = build;
return result;
});
};
... ...
... ... @@ -227,7 +227,7 @@ const getNewProduct = (brandId, gender, url, isApp) => {
});
};
// 相关资讯
// 相关资讯--不能加cache,否则点赞有缓存.
const getRelatedEditorial = (brandId, uid, udid, clientType, isApp) => {
return serviceAPI.get('guang/service/v1/article/getArticleByBrand', {
... ... @@ -324,12 +324,11 @@ const getDetailData = (id, uid, udid, gender, isApp, clientType) => {
list.brand_ico = imageProcess.getSourceUrl(list.brand_ico, 'brandLogo');
return Promise.all([getRelatedEditorial(brandId, uid, udid, clientType, isApp), getNewProduct(brandId, gender, url, isApp)]).then((result) => {
return getNewProduct(brandId, gender, url, isApp).then((result) => {
list = _.assign(list, {
return _.assign(list, {
isLike: false,
infos: result[0],
newArrival: result[1],
newArrival: result,
jumpToApp: jumpToApp,
shareLink: '//guang.m.yohobuy.com/plustar/brandinfo?id=' + id,
shareTitle: list.brand_name,
... ... @@ -337,8 +336,6 @@ const getDetailData = (id, uid, udid, gender, isApp, clientType) => {
shareDesc: htmlProcess.removeHtml(list.brand_intro),
clientType: clientType
});
return list;
});
} else {
... ...
... ... @@ -25,25 +25,25 @@
</div>
</div>
</div>
{{# newArrival}}
{{#if newArrival.naList}}
<div class="new-arrival ps-block">
<div class="floor-header-more">
<h2>NEW ARRIVAL</h2>
<a class="more-btn iconfont buriedpoint" href="{{moreUrl}}" data-bp-id="shop_more_btn_0">&#xe606;</a>
<a class="more-btn iconfont buriedpoint" href="{{newArrival.moreUrl}}" data-bp-id="shop_more_btn_0">&#xe606;</a>
</div>
<div class="new-arrival-content clearfix">
{{# naList}}
{{# newArrival.naList}}
{{> good}}
{{/ naList}}
{{/ newArrival.naList}}
</div>
<div class="more-goods-container">
<a class="mg-text" href="{{moreUrl}}">
<a class="mg-text" href="{{newArrival.moreUrl}}">
更多商品
<span class="more-prods iconfont">&#xe604;</span>
</a>
</div>
</div>
{{/ newArrival}}
{{/if}}
<div class="related-infos data-bind ps-block">
<div>
<h2 class="related-info-title">相关资讯</h2>
... ...
... ... @@ -24,7 +24,7 @@ const bind = {
indexPage: (req, res) => {
// 如果没有originalUrl,判定为非法链接
if (req.session.originalUrl !== 'true') {
res.redirect('//m.yohobuy.com');
return res.redirect('//m.yohobuy.com');
}
let refer = req.get('Referer');
... ...
... ... @@ -221,24 +221,23 @@ const category = (req, res, next) => {
JSON.stringify(appParams) +
'}';
let uid = req.user.uid || 0;
// 获取第一页数据做服务端渲染
let initialData = _.assign({
gender: params.gender,
sort: parseInt(params.sort) || '',
sort: parseInt(params.sort, 10) || '',
type: 'default',
order: '0',
page: 1,
limit: 12,
}, params);
if (uid) {
initialData.uid = uid;
}
searchModel.getSearchData(initialData).then((firstScreenGoodsList) => {
if (firstScreenGoodsList && firstScreenGoodsList.list) {
_.forEach(firstScreenGoodsList.list, function(item) {
if (item && item.default_images) {
item.default_images = item.default_images.replace(/quality\/80/g, 'quality/70');
}
});
}
res.render('search/goods-list', {
_noLazy: true, // 首屏不使用lazyload
module: 'product',
... ...
... ... @@ -4,7 +4,7 @@
'use strict';
const mRoot = '../models';
const utils = '../../../utils';
const listModel = require(`${mRoot}/list`);
const searchModel = require(`${mRoot}/search`);
const redsShopModel = require(`${mRoot}/popular-shop`);
... ... @@ -21,6 +21,7 @@ const shop = {
let brandId = 0;
let brandLogo = {};
let title = '';
let uid = req.user.uid || 0;
if (req.query.shop_id) {
return shop.shop(req, res, next);
... ... @@ -55,6 +56,10 @@ const shop = {
limit: 4,
}, params);
if (uid) {
searchParam.uid = uid;
}
if (req.query.from !== 'search' && brandLogo.type === '2' && brandLogo.shopId) {
req.query.shop_id = brandLogo.shopId;
shop.shop(req, res, next);
... ... @@ -98,7 +103,6 @@ const shop = {
});
}
}).then((isBrand) => {
// console.log(params);
if (isBrand) {
res.render('newshop/brand', {
module: 'product',
... ... @@ -165,6 +169,10 @@ const shop = {
let shopInfo = shopInfoResult;
let seoResult = listModel.getBrandShopSeo(channel, shopInfoResult, req.query);
if (uid) {
searchParam.uid = uid;
}
/* 基础店铺返回程序内的跳转信号,跳转到基础店铺 */
if (shopInfoResult && shopInfoResult.shop_template_type && parseInt(shopInfoResult.shop_template_type, 10) === 1) {
return Promise.all([listModel.getBaseShopData(req.query, shopInfo), searchModel.getSearchData(searchParam)]).then(fResult => {
... ...
... ... @@ -214,6 +214,10 @@ let search = (req, res, next) => {
});
}
if (uid) {
params.uid = uid;
}
saleModel.getSearchData(params, uid).then((result) => {
let vipLevel = result[1].cur_level;
let vipObj = {};
... ...
... ... @@ -22,10 +22,11 @@ const list = (req, res, next) => {
cartUrl: helpers.urlFormat('/cart/index/index')
}, req.query);
let title = '';
let query = req.query.query;
let query = (req.query.query || '').toString();
let isQueryFirstClass = false; // 标识用户搜的是不是一级品类
let isQuerySecondClass = false; // 标识用户搜的是不是二级品类
let domain = null;
let uid = req.user.uid || 0;
if (params.shop_id) {
params.shopId = params.shop_id;
... ... @@ -52,6 +53,10 @@ const list = (req, res, next) => {
query = query.toLowerCase();
}
if (uid) {
initialData.uid = uid;
}
/* 判断是不是品牌, 是品牌跳到品牌列表页(显示搜索框),判断是不是品类, 是品类加导航标题(不显示搜索框) */
return Promise.all([
searchModel.getBrandDomain(query),
... ... @@ -183,16 +188,26 @@ let fuzzyDatas = (req, res, next) => {
* ajax 商品数据请求
*/
const search = (req, res, next) => {
res.header('Access-Control-Allow-Origin', '*');
let allowOrigin = _.get(req, 'headers.origin', null) ?
req.headers.origin : req.protocol + '://' + req.headers.host;
res.setHeader('Access-Control-Allow-Origin', allowOrigin);
res.setHeader('Access-Control-Allow-Credentials', 'true');
let params = Object.assign({}, req.query);
let uid = req.user.uid || 0;
if (uid) {
params.uid = uid;
}
params.isApp = req.yoho.isApp;
params.limit = 24;
searchModel.getSearchData(params).then((result) => {
if (result && result.list &&
parseInt(params.page) === 1 && parseInt(params.start) > 0) {
parseInt(params.page, 10) === 1 && parseInt(params.start, 10) > 0) {
// 首屏渲染时,使用 'start' 参数裁减已渲染数据
result.list = result.list.slice(params.start || 0);
}
... ...
... ... @@ -126,11 +126,16 @@ const _getShopInfo = (shopId, uid) => {
* @param {int} shopId
*/
const getShopIntro = (shopId, uid) => {
return api.get('', {
let params = {
method: 'app.shops.getIntro',
shop_id: shopId,
uid: uid
}, {code: 200}).then(result => {
shop_id: shopId
};
if (uid) {
params.uid = uid;
}
return api.get('', params, {code: 200}).then(result => {
return result && result.data;
});
};
... ...
... ... @@ -15,7 +15,7 @@ const cachePage = {
// 自定义频道
'/channel/:id.html': 1 * MINUTE,
//ajax获取频道页楼层
// ajax获取频道页楼层
'/channel/getResourceContent': 30 * MINUTE,
// 商品分类
... ... @@ -30,10 +30,12 @@ const cachePage = {
// 店铺推荐
'/product/detail/preference': 5 * MINUTE,
'/product/detail/intro/:productskn': 15 * MINUTE,
// 店铺人气单品
'/product/new/shop/hotlist': 5 * MINUTE,
// 店铺简介
'/product/index/intro' : 15 * MINUTE,
'/product/index/intro': 15 * MINUTE,
// 逛
'/guang/': 1 * MINUTE,
... ... @@ -49,17 +51,17 @@ const cachePage = {
// '/guang/plustar/brandinfo': 1 * MINUTE,
'/guang/star': 1 * MINUTE,
// 领券中心
'/activity/coupon/floor': 1 * MINUTE,
// 商品列表
'/product/search/filter': 1 * MINUTE,
/* 筛选默认须要添加uid参数
'/product/list/index': 1 * MINUTE,
'/product/index/index': 1 * MINUTE,
'/product/index/brand': 1 * MINUTE,
'/product/search/filter': 1 * MINUTE,
'/product/search/search': 1 * MINUTE,
*/
'/product/new': 1 * MINUTE,
... ...
... ... @@ -76,7 +76,7 @@ module.exports = {
port: '4444' // influxdb port
},
console: {
level: 'info',
level: 'debug',
colorize: 'all',
prettyPrint: true
}
... ...
... ... @@ -12,7 +12,7 @@
a.async = 1;
a.src = j;
m.parentNode.insertBefore(a, m);
}(window, document, 'script', (document.location.protocol === 'https:' ? 'https:' : 'http:') + '//cdn.yoho.cn/yas-jssdk/2.2.4/yas.js', '_yas'));
}(window, document, 'script', (document.location.protocol === 'https:' ? 'https:' : 'http:') + '//cdn.yoho.cn/yas-jssdk/2.2.5/yas.js', '_yas'));
var _hmt = _hmt || [];
... ... @@ -56,7 +56,7 @@
uid = uid === 0 ? '' : uid;
window._ozuid = uid; // 暴露ozuid
if (window._yas) {
window._yas(1 * new Date(), '2.2.2', 'yohobuy_m', uid, '', '');
window._yas(1 * new Date(), '2.2.5', 'yohobuy_m', uid, '', '');
}
setTimeout(function() {
... ...
{
"name": "m-yohobuy-node",
"version": "5.4.7",
"version": "5.4.8",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -406,7 +406,7 @@ function search(opt) {
if (nav.reload) {
page = 1;
} else if (nav.end) {
$('.search-divide').remove();
// 不需要重新加载并且数据请求结束
return;
}
... ... @@ -532,6 +532,9 @@ function search(opt) {
type: 'GET',
url: location.protocol + '//m.yohobuy.com/product/search/search',
data: setting,
xhrFields: {
withCredentials: true
},
success: function(data) {
var num,
$container,
... ... @@ -580,7 +583,6 @@ function search(opt) {
if (data === '' || (data.list && data.list.length <= 0)) {
nav.end = true;
$('.search-divide').remove();
if (nav.reload) {
if (data.total === 0) {
$container.html(noResult);
... ...
... ... @@ -112,7 +112,6 @@ var defaultOpt = require('../common/query-param');
url: '/product/search/filter',
data: {
shop_id: $('.shopId').val(),
type: 'default',
order: '0',
channel: defaultOpt.channel
},
... ...
... ... @@ -385,6 +385,9 @@ function search(opt) {
type: 'GET',
url: location.protocol + '//m.yohobuy.com/product/search/search',
data: setting,
xhrFields: {
withCredentials: true
},
success: function(data) {
var noResult = '<p class="no-result">未找到相关搜索结果</p>',
num,
... ...
... ... @@ -211,6 +211,9 @@ function getPageGoods(info) {
type: 'GET',
url: info.url,
data: info.data,
xhrFields: {
withCredentials: true
},
success: function(data) {
if (data === '' || (data.list && data.list.length <= 0)) {
nav.end = true;
... ...
... ... @@ -52,6 +52,12 @@ const toArray = (obj) => {
const _sortListByField = (list, key, desc) => {
let array = toArray(list);
return array.sort(function(a, b) {
a = a._key.split(',')[0] * 1;
b = b._key.split(',')[0] * 1;
return desc ? a < b : a > b;
});
/*
array = array.sort((a, b) => {
let matchNumber = /([\d]+)/g;
... ... @@ -70,7 +76,7 @@ const _sortListByField = (list, key, desc) => {
return numA < numB ? -1 : 1;
});
return array;
return array;*/
};
/**
... ...