Authored by 郭成尧

Merge branch 'hotfix/searchWord' into release/5.2

... ... @@ -7,6 +7,7 @@
'use strict';
const indexModel = require('../models/market');
const _ = require('lodash');
exports.index = (req, res, next) => {
... ... @@ -21,3 +22,26 @@ exports.index = (req, res, next) => {
}).catch(next);
};
/**
* 市场推广活动升级版,自定义下载渠道
* @param req
* @param res
* @param next
*/
exports.v2 = (req, res, next) => {
indexModel.index({
}).then((result) => {
if (_.has(result, 'download[0].url') && req.query.union_type) {
result.download[0].url = result.download[0].url.split('?')[0] +
'?union_type=' + req.query.union_type;
}
res.render('market/market', Object.assign(result, {
title: 'Yoho!Buy 有货'
}));
}).catch(next);
};
... ...
... ... @@ -71,6 +71,7 @@ router.get('/invite', invite.checkType, invite.index);
router.get('/invite/index', invite.checkType, invite.index);
router.get('/market', market.index); // 市场推广活动
router.get('/market/v2', market.v2); // 市场推广活动升级版,自定义下载渠道
router.get(/\/invite\/share_([\d]+)_([\d]+)_([\d]+).html/, invite.checkType, invite.share);
... ...
... ... @@ -60,13 +60,14 @@ exports.ensure = (req, res, next) => {
let view;
if (paymentInfo.code !== 200) {
if (paymentInfo.message) {
view = {
orderEnsure: false,
message: paymentInfo.message
};
} else {
return Promise.reject(paymentInfo);
view = {
orderEnsure: false,
message: paymentInfo.message
};
// hotfix: nginx 接口限流, code:9999991时没message 信息
if (!view.message) {
view.message = '挤爆啦,系统繁忙';
}
} else {
// 渲染
... ...
... ... @@ -12,10 +12,6 @@
{{/if}}
<!--/tab-nav-->
{{#if isApp}}
<div class='empty-height'></div>
{{/if}}
<div class="plusstar-resources">
<!--资源位数据模板-->
</div><!--/plusstar-resources-->
... ...
... ... @@ -490,6 +490,9 @@ const userCoupon = (req, res, next) => {
let isApp = req.body.app_version || req.body.appVersion || false;
let data = {};
cryptCouponId = parseInt(cryptCouponId, 10);
uid = parseInt(uid, 10);
if (uid) {
listModel.receiveCoupon(
uid,
... ...
... ... @@ -25,106 +25,109 @@ const list = (req, res, next) => {
let isQuerySecondClass = false; // 标识用户搜的是不是二级品类
let domain = null;
if (params.query) {
let activity = _.get(searchModel.searchKeyActivity(params.query), 'data.urlobj.appUrl', '');
if (activity) {
res.redirect(activity);
}
}
if (params.shop_id) {
params.shopId = params.shop_id;
}
/* 判断是不是品牌, 是品牌跳到品牌列表页(显示搜索框),判断是不是品类, 是品类加导航标题(不显示搜索框) */
Promise.all([
searchModel.getAllBrandNames(),
searchModel.getClassNames()
]).then(result => {
if (query) {
query = query.toLowerCase();
_.forEach(result[0], obj => {
if (query === obj.brandDomain) { // 精确查品牌域名
domain = query;
return false;
}
if (query === obj.brandName || query === obj.brandName || query === obj.brandName) { // 精确查品牌名称
domain = obj.brandDomain;
return false;
}
// if (obj.brandDomain.indexOf(query) > 0) { // 模糊查品牌域名
// domain = obj.brandDomain;
// return false;
// }
});
// 跳转到品牌商品列表页
if (domain !== null && !params.shop_id) {
let url = helpers.urlFormat('', {
from: 'search',
query: query
}, domain);
return res.redirect(url);
}
// 品类名称为空时跳出
if (!result[1]) {
return;
}
_.forEach(result[1].first, (obj) => {
// 精确查一级品类
if (obj === query) {
isQueryFirstClass = true;
return false;
}
});
_.forEach(result[1].second, (obj) => {
// 精确查二级品类
if (obj === query) {
isQuerySecondClass = true;
return false;
}
});
} else {
params.query = '';
}
// 搜索是一级品类
if (isQueryFirstClass) {
title = '全部' + query;
} else if (isQuerySecondClass) { // 搜索是二级品类
title = query;
} else { // 搜索其它内容
if (query || params.form) {
params.search = {
default: query === '' ? false : query,
url: helpers.urlFormat('', null, 'search')
};
if (params.query) {
return searchModel.searchKeyActivity(params.query).then(activityResult => {
let activity = _.get(activityResult, 'urlobj.appUrl', '');
if (activity) {
return res.redirect(activity);
} else {
/* 判断是不是品牌, 是品牌跳到品牌列表页(显示搜索框),判断是不是品类, 是品类加导航标题(不显示搜索框) */
return Promise.all([
searchModel.getAllBrandNames(),
searchModel.getClassNames()
]).then(result => {
if (query) {
query = query.toLowerCase();
_.forEach(result[0], obj => {
if (query === obj.brandDomain) { // 精确查品牌域名
domain = query;
return false;
}
if (query === obj.brandName || query === obj.brandName || query === obj.brandName) { // 精确查品牌名称
domain = obj.brandDomain;
return false;
}
// if (obj.brandDomain.indexOf(query) > 0) { // 模糊查品牌域名
// domain = obj.brandDomain;
// return false;
// }
});
// 跳转到品牌商品列表页
if (domain !== null && !params.shop_id) {
let url = helpers.urlFormat('', {
from: 'search',
query: query
}, domain);
return res.redirect(url);
}
// 品类名称为空时跳出
if (!result[1]) {
return;
}
_.forEach(result[1].first, (obj) => {
// 精确查一级品类
if (obj === query) {
isQueryFirstClass = true;
return false;
}
});
_.forEach(result[1].second, (obj) => {
// 精确查二级品类
if (obj === query) {
isQuerySecondClass = true;
return false;
}
});
} else {
params.query = '';
}
// 搜索是一级品类
if (isQueryFirstClass) {
title = '全部' + query;
} else if (isQuerySecondClass) { // 搜索是二级品类
title = query;
} else { // 搜索其它内容
if (query || params.form) {
params.search = {
default: query === '' ? false : query,
url: helpers.urlFormat('', null, 'search')
};
}
title = '搜索';
}
title = params.title ? params.title : title;
res.render('search/list', {
module: 'product',
page: 'search-list',
pageHeader: headerModel.setNav({
navTitle: title
}),
title: title,
goodList: params,
pageFooter: true
});
}).catch(next);
}
title = '搜索';
}
title = params.title ? params.title : title;
res.render('search/list', {
module: 'product',
page: 'search-list',
pageHeader: headerModel.setNav({
navTitle: title
}),
title: title,
goodList: params,
pageFooter: true
});
}).catch(next);
}
};
/**
... ... @@ -132,6 +135,7 @@ const list = (req, res, next) => {
*/
const index = (req, res, next) => {
let title = '搜索';
((render) => {
if (_.get(req, 'app.locals.wap.search.removeHotSearch', false)) {
render([]);
... ...
{
"name": "m-yohobuy-node",
"version": "5.1.9",
"version": "5.1.10",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -4,8 +4,7 @@ var $ = require('yoho-jquery'),
loading = require('../plugin/loading'),
debounce = require('lodash/debounce');
var plusstar = {},
$footer = $('#yoho-footer');
var plusstar = {};
var windowHeight = $(window).height();
var scrollFn,
... ... @@ -186,6 +185,9 @@ plusstar = {
return true;
}
// 固定底部去除
window.rePosFooter();
// 记录切换tab位置
$(document).scrollTop(window.cookie(code) || 0);
... ... @@ -303,23 +305,17 @@ $(function() {
apt: window.queryString.client_type || '',
sid: window.queryString.session_id || '',
};
}
// 男:1,女:2,潮童:3,创意生活:4
speckParamApp.CID = window.queryString.yh_channel || window._ChannelVary[window.cookie('_Channel')] || 1;
if (!isApp) {
$('.plusstar-resources').css({'margin-top': $('.tab-nav').height()});
} else {
$('.tab-nav').css({
position: 'relative'
});
$footer.css({
'max-width': '650px'
}).before(
'<div style="height: ' + parseInt($footer.css('height'), 0) + 'px"></div>'
);
}
// 男:1,女:2,潮童:3,创意生活:4
speckParamApp.CID = window.queryString.yh_channel || window._ChannelVary[window.cookie('_Channel')] || 1;
plusstar.init();
// 滚动翻页
... ...
... ... @@ -18,12 +18,13 @@
position: fixed;
z-index: 10;
background-color: #fff;
top: 0;
li {
display: block;
float: left;
height: 100%;
width: 33.33%;
width: 50%;
line-height: 60px;
color: #999;
white-space: nowrap;
... ...