Authored by 张孝茹

merge master

... ... @@ -646,7 +646,7 @@ exports.getTimeList = function(req, res, next) {
};
exports.addOrder = function(req, res, next) {
let uid = req.user.uid || req.query.uid;
let uid = req.user.uid;
let params = {
storeId: req.query.storeId,
appointTime: req.query.appointTime,
... ... @@ -670,6 +670,7 @@ exports.addOrder = function(req, res, next) {
exports.delOrder = function(req, res, next) {
let params = {
uid: req.user.uid,
id: req.query.id,
isFront: req.query.isFront || req.cookies.isFront
};
... ... @@ -737,6 +738,7 @@ exports.err = function(req, res) {
exports.changeDate = function(req, res, next) {
let params = {
uid: req.user.uid,
id: req.query.id,
storeId: req.query.storeId,
appointTimeStr: req.query.appointTimeStr,
... ...
... ... @@ -1449,6 +1449,7 @@ const cutter = (params) => {
// 删除预约订单
const delOrder = (params) => {
return service.get('AppointmentController/frontCancelAppoint', {
uid: params.uid,
id: params.id,
isFront: params.isFront
}).then(result => {
... ... @@ -1462,6 +1463,7 @@ const changeDate = (params) => {
let appointTimeStr = _originDay(params.appointTimeStr);
return service.get('AppointmentController/updateFrontAppointTime', {
uid: params.uid,
storeId: params.storeId,
id: params.id,
appointTimeStr: appointTimeStr,
... ...
... ... @@ -128,7 +128,7 @@
<div class="brand-div">
<span class="brand-name"{{#if ../fontColor}}style="color:{{../fontColor}};"{{/if}}>{{brandname}}</span>
</div>
<img class="brand-img lazy" data-original="{{image2 ../brandImg q=95}}">
<img class="brand-img" src="{{image2 ../brandImg q=95}}">
</a>
{{/if}}
</div>
... ...
<div class="trend-c map-c share-map" id="no-download">
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=55E5CFCa68831302cebe0acdd575c77d"></script>
<script type="text/javascript" src="http://api.map.baidu.com/library/SearchInfoWindow/1.5/src/SearchInfoWindow_min.js"></script>
<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=55E5CFCa68831302cebe0acdd575c77d"></script>
<script type="text/javascript" src="https://api.map.baidu.com/library/SearchInfoWindow/1.5/src/SearchInfoWindow_min.js"></script>
<div id="map"></div>
</div>
... ...
/**
* chanpin controller
* @author: yyq<yanqing.yang@yoho.cn>
* @date: 2017/09/22
*/
const _ = require('lodash');
const helpers = global.yoho.helpers;
const utils = '../../../utils';
const searchProcess = require(`${utils}/search-process`);
const stringCode = require(`${utils}/string-code`);
const chanpin = require('../models/chanpin');
const headerModel = require('../../../doraemon/models/header');
// 关键词页
const keyword = (req, res, next) => {
let queryKey = stringCode.hexToUtf8(`${req.params.query}`);
let params = {
isSearch: true, // 搜索列表将最新改成默认的标识
cartUrl: helpers.urlFormat('/cart/index/index'),
query: queryKey
};
params.isApp = req.yoho.isApp;
params.physical_channel = req.yoho.channel && searchProcess.getChannelType(req.yoho.channel);
// 唤起 APP 的路径
res.locals.appPath = `yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.list","params":${JSON.stringify(params)}}`;
return req.ctx(chanpin).getSearchKeywordData(params, req.user.uid).then(result => {
res.render('search/list', {
_noLazy: true,
module: 'product',
page: 'chanpin',
pageHeader: headerModel.setNav({
navTitle: queryKey
}),
goodList: params,
firstPageGoods: result || [],
fuzzyWord: result.fuzzyWord,
title: `${queryKey}价格_图片_品牌_怎么样-YOHO!BUY有货`,
keywords: `${queryKey},${queryKey}价格,${queryKey}图片,${queryKey}怎么样,${queryKey}品牌,YOHO!BUY有货`,
description: `YOHO!BUY有货网yohobuy.com是国内专业的${queryKey}网上潮流购物商城,为您找到${_.get(result,
'total', 0)}${queryKey}、产品的详细参数,实时报价,价格行情,图片、评价、品牌等信息。买${queryKey},就上YOHO!BUY有货`,
pageFooter: true
});
}).catch(next);
};
// 关键词页with id
const keyId = (req, res, next) => {
let params = {
isSearch: true, // 搜索列表将最新改成默认的标识
cartUrl: helpers.urlFormat('/cart/index/index')
};
params.isApp = req.yoho.isApp;
params.physical_channel = req.yoho.channel && searchProcess.getChannelType(req.yoho.channel);
return req.ctx(chanpin).getSearchKeywordDataById(req.params.id, params, req.user.uid).then(result => {
let queryKey = result.queryKey;
if (!result) {
return next();
}
// 唤起 APP 的路径
res.locals.appPath = `yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.list","params":${JSON.stringify(params)}}`;
res.render('search/list', {
_noLazy: true,
module: 'product',
page: 'chanpin',
pageHeader: headerModel.setNav({
navTitle: queryKey
}),
goodList: params,
firstPageGoods: result || [],
fuzzyWord: result.fuzzyWord,
title: `${queryKey}价格_图片_品牌_怎么样-YOHO!BUY有货`,
keywords: `${queryKey},${queryKey}价格,${queryKey}图片,${queryKey}怎么样,${queryKey}品牌,YOHO!BUY有货`,
description: `YOHO!BUY有货网yohobuy.com是国内专业的${queryKey}网上潮流购物商城,为您找到${_.get(result,
'total', 0)}${queryKey}、产品的详细参数,实时报价,价格行情,图片、评价、品牌等信息。买${queryKey},就上YOHO!BUY有货`,
pageFooter: true,
cononical: {
currentHref: `//www.yohobuy.com${req.originalUrl}`
}
});
}).catch(next);
};
const searchGoods = (req, res, next) => {
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;
return req.ctx(chanpin).getSeoSearchData(params).then((result) => {
if (result.list && result.list.length > 0) {
res.render('search/page', {
layout: false,
new: result.list,
suggestion: result.suggestion || [],
total: result.total,
_noLazy: params.noLazy || false
});
} else {
res.json(result);
}
}).catch(next);
};
module.exports = {
keyword,
keyId,
searchGoods
};
... ...
... ... @@ -13,7 +13,6 @@ const _ = require('lodash');
const helpers = global.yoho.helpers;
const searchProcess = require(`${utils}/search-process`);
const productProcess = require(`${utils}/product-process`);
const stringCode = require(`${utils}/string-code`);
const co = require('bluebird').coroutine;
/**
... ... @@ -271,83 +270,6 @@ exports.filter = (req, res, next) => {
}).catch(next);
};
// 关键词页
exports.keyword = (req, res, next) => {
let queryKey = stringCode.hexToUtf8(`${req.params.query}`);
let params = {
isSearch: true, // 搜索列表将最新改成默认的标识
cartUrl: helpers.urlFormat('/cart/index/index'),
query: queryKey
};
params.isApp = req.yoho.isApp;
params.physical_channel = req.yoho.channel && searchProcess.getChannelType(req.yoho.channel);
// 唤起 APP 的路径
res.locals.appPath = `yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.list","params":${JSON.stringify(params)}}`;
return req.ctx(searchModel).getSearchKeywordData(params, req.user.uid).then(result => {
res.render('search/list', {
_noLazy: true,
module: 'product',
page: 'search-list',
pageHeader: headerModel.setNav({
navTitle: queryKey
}),
goodList: params,
firstPageGoods: result || [],
fuzzyWord: result.fuzzyWord,
title: `${queryKey}价格_图片_品牌_怎么样-YOHO!BUY有货`,
keywords: `${queryKey},${queryKey}价格,${queryKey}图片,${queryKey}怎么样,${queryKey}品牌,YOHO!BUY有货`,
description: `YOHO!BUY有货网yohobuy.com是国内专业的${queryKey}网上潮流购物商城,为您找到${_.get(result,
'total', 0)}${queryKey}、产品的详细参数,实时报价,价格行情,图片、评价、品牌等信息。买${queryKey},就上YOHO!BUY有货`,
pageFooter: true
});
}).catch(next);
};
// 关键词页with id
exports.keyId = (req, res, next) => {
let params = {
isSearch: true, // 搜索列表将最新改成默认的标识
cartUrl: helpers.urlFormat('/cart/index/index')
};
params.isApp = req.yoho.isApp;
params.physical_channel = req.yoho.channel && searchProcess.getChannelType(req.yoho.channel);
return req.ctx(searchModel).getSearchKeywordDataById(req.params.id, params, req.user.uid).then(result => {
let queryKey = result.queryKey;
if (!result) {
return next();
}
// 唤起 APP 的路径
res.locals.appPath = `yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.list","params":${JSON.stringify(params)}}`;
res.render('search/list', {
_noLazy: true,
module: 'product',
page: 'search-list',
pageHeader: headerModel.setNav({
navTitle: queryKey
}),
goodList: params,
firstPageGoods: result || [],
fuzzyWord: result.fuzzyWord,
title: `${queryKey}价格_图片_品牌_怎么样-YOHO!BUY有货`,
keywords: `${queryKey},${queryKey}价格,${queryKey}图片,${queryKey}怎么样,${queryKey}品牌,YOHO!BUY有货`,
description: `YOHO!BUY有货网yohobuy.com是国内专业的${queryKey}网上潮流购物商城,为您找到${_.get(result,
'total', 0)}${queryKey}、产品的详细参数,实时报价,价格行情,图片、评价、品牌等信息。买${queryKey},就上YOHO!BUY有货`,
pageFooter: true,
cononical: {
currentHref: `//www.yohobuy.com${req.originalUrl}`
}
});
}).catch(next);
};
/**
* 搜索品牌下的商品
*/
... ...
/**
* chanpin model
* @author: yyq<yanqing.yang@yoho.cn>
* @date: 2017/09/22
*/
const _ = require('lodash');
const helpers = global.yoho.helpers;
const utils = '../../../utils';
const redis = require(`${utils}/redis`);
const searchProcess = require(`${utils}/search-process`);
const productProcess = require(`${utils}/product-process`);
const stringCode = require(`${utils}/string-code`);
/**
* 封面图
* @type {{boys: string, gilrs: string}}
*/
const _coverChannel = {
boys: '1,3',
gilrs: '2,3'
};
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
getFuzzyDatas(params) {
return this.get({
data: {
method: 'app.search.fuzzy',
keyword: params
},
param: {cache: true}
}).then((result) => {
return _.get(result, 'data', []);
});
}
getSeoSearchData(params) {
let finalParams = {
method: 'web.search.forseo',
sales: 'Y',
outlets: 2,
stocknumber: 1,
need_filter: 'no'
};
finalParams = _.assign(finalParams, searchProcess.getSearchParamsWithoutMethod(params));
return this.get({data: finalParams}).then(result => {
let resData = {};
resData.list = productProcess.processProductList(_.get(result, 'data.product_list', []), {
isApp: params.isApp || (params.appVersion && params.appVersion !== 'false'),
gender: _coverChannel[params.coverChannel],
showSimilar: params.shop_id || params.material === 'true' ? false : true
});
return resData;
});
}
getSearchKeywordData(params, uid) {
// 获取第一页数据做服务端渲染
let initialData = _.assign({
type: 'default',
order: '0',
page: 1,
limit: 24
}, params);
if (uid) {
initialData.uid = uid;
}
return Promise.all([
this.getFuzzyDatas(`${params.query}`.substr(0, 2)),
this.getSeoSearchData(initialData)
]).then(result => {
let resData = result[1];
let fuzzy = [];
if (_.isEmpty(result[0])) {
result[0] = [];
}
_.forEach(_.slice(result[0], 0, 12), value => {
if (value.keyword === params.query) {
return;
}
fuzzy.push({
name: value.keyword,
link: helpers.urlFormat(`/so/${stringCode.utf8ToHex(value.keyword)}.html`),
});
});
if (!_.isEmpty(fuzzy)) {
resData.fuzzyWord = fuzzy;
}
return resData;
});
}
getSearchKeywordDataById(id, params, uid) {
return redis.all([
['get', `global:yoho:seo:keywords:id:${id}`]
]).then(redisData => {
if (!redisData[0]) {
return false;
}
redisData = JSON.parse(redisData[0]);
params.query = redisData.name;
return this.getSearchKeywordData(params, uid).then(result => {
result.queryKey = params.query;
let fuzzyWord = [];
if (!_.isEmpty(redisData.data)) {
_.forEach(_.slice(redisData.data, 0, 12), value => {
if (!value) {
return;
}
fuzzyWord.push(Object.assign(value, {
name: value.keyword,
link: helpers.urlFormat(`/chanpin/${value.id}.html`, null)
}));
});
_.set(result, 'fuzzyWord', fuzzyWord);
}
return result;
});
});
}
};
... ...
... ... @@ -8,6 +8,7 @@ const bundle = require('./bundle');
const utils = '../../../utils';
const detailProcess = require(`${utils}/detail-process`);
const redis = require(`${utils}/redis`);
const logger = global.yoho.logger;
// const api = global.yoho.API;
const helpers = global.yoho.helpers;
... ... @@ -62,7 +63,12 @@ module.exports = class extends global.yoho.BaseModel {
return this.getRecomdKeywords(smallSort).then(res => {
let recomdKeywords = [];
res = res ? JSON.parse(res) : [];
try {
res = res ? JSON.parse(res) : [];
} catch (e) {
logger.error(`smallSort: ${smallSort}, message: ${e.message}`);
res = [];
}
_.forEach(_.slice(_.shuffle(res), 0, 12), val => {
recomdKeywords.push({
... ...
... ... @@ -7,12 +7,10 @@
const utils = '../../../utils';
const productProcess = require(`${utils}/product-process`);
const searchProcess = require(`${utils}/search-process`);
const stringCode = require(`${utils}/string-code`);
const _ = require('lodash');
const logger = global.yoho.logger;
const cache = require('memory-cache');
const helpers = global.yoho.helpers;
const redis = require(`${utils}/redis`);
const co = require('bluebird').coroutine;
/**
... ... @@ -570,85 +568,6 @@ module.exports = class extends global.yoho.BaseModel {
}
}
getSearchKeywordData(params, uid) {
// 获取第一页数据做服务端渲染
let initialData = _.assign({
type: 'default',
order: '0',
page: 1,
limit: 24
}, params);
if (uid) {
initialData.uid = uid;
}
return Promise.all([
this.getFuzzyDatas(`${params.query}`.substr(0, 2)),
this.getSearchData(initialData)
]).then(result => {
let fuzzy = [];
if (_.isEmpty(result[0])) {
result[0] = [];
}
_.forEach(_.slice(result[0], 0, 12), value => {
if (value.keyword === params.query) {
return;
}
fuzzy.push({
name: value.keyword,
link: helpers.urlFormat(`/so/${stringCode.utf8ToHex(value.keyword)}.html`),
});
});
if (!_.isEmpty(fuzzy)) {
result[1].fuzzyWord = fuzzy;
}
return result[1];
});
}
getSearchKeywordDataById(id, params, uid) {
return redis.all([
['get', `global:yoho:seo:keywords:id:${id}`]
]).then(redisData => {
if (!redisData[0]) {
return false;
}
redisData = JSON.parse(redisData[0]);
params.query = redisData.name;
return this.getSearchKeywordData(params, uid).then(result => {
result.queryKey = params.query;
if (!_.isEmpty(redisData.data)) {
let tdata = _.slice(redisData.data, 0, 12);
_.forEach(tdata, value => {
if (!value) {
return;
}
Object.assign(value, {
name: value.keyword,
link: helpers.urlFormat(`/chanpin/${value.id}.html`, null)
});
});
_.set(result, 'fuzzyWord', redisData.data);
}
return result;
});
});
}
/**
* 通过 skn 搜索商品
* @param productSkn
... ...
... ... @@ -59,6 +59,8 @@ const globalPro = require(`${cRoot}/global`);
// 找相似
const similar = require(`${cRoot}/similar`);
// seo推广
const chanpin = require(`${cRoot}/chanpin`);
const newRecommend = require(`${cRoot}/new-recommend`);
// routers
... ... @@ -137,8 +139,9 @@ router.get('/seckill/get-product-list', seckill.getProductList); // 秒杀列表
router.get('/search/index', search.index);
// 推广落地页
router.get('/search/so/:query.html', rewrite.sortParams, search.keyword);
router.get('/search/chanpin/:id.html', rewrite.sortParams, search.keyId);
router.get('/search/so/:query.html', rewrite.sortParams, chanpin.keyword);
router.get('/search/chanpin/:id.html', rewrite.sortParams, chanpin.keyId);
router.get('/search/chanpin/goods', chanpin.searchGoods); // 搜索的商品
// 搜索落地页
router.get('/search/list', rewrite.sortParams, search.list);
... ...
{
"name": "m-yohobuy-node",
"version": "6.1.0",
"version": "6.1.1",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ... @@ -96,6 +96,7 @@
"jquery-lazyload": "^1.9.7",
"nodemon": "^1.12.0",
"opn": "^5.1.0",
"postcss": "^6.0.9",
"postcss-assets": "^5.0.0",
"postcss-calc": "^6.0.0",
"postcss-center": "^1.0.0",
... ...
/**
* seo推广落地页
* @author: yyq<yanqing.yang@yoho.cn>
* @date: 2016/7/21
*/
require('product/search/list.page.css');
const $ = require('yoho-jquery');
const ProductListWithFilter = require('product/list/product-list-with-filter');
require('common/footer');
new ProductListWithFilter({
query: $.trim($('.nav-title').text()),
page: 2, // 首页服务端已经渲染
}, 'product/search/chanpin/goods').getFilter();
... ...
... ... @@ -100,6 +100,10 @@ const getListSeoData = (gender, sort_name) => {
const getSearchParamsWithoutMethod = (params) => {
let finalParams = {};
if (params.query) {
finalParams.query = params.query;
}
if (params.yh_channel) {
finalParams.yh_channel = params.yh_channel;
}
... ...