Authored by zhangxiaoru

merge from feature/wantSearch

... ... @@ -132,13 +132,14 @@ const list = (req, res, next) => {
* 搜索主页
*/
const index = (req, res, next) => {
let title = '搜索';
let title = '搜索',
uid = req.user.uid || 0;
((render) => {
if (_.get(req, 'app.locals.wap.search.removeHotSearch', false)) {
render([]);
} else {
searchModel.getSearchIndex().then((result) => {
searchModel.getSearchIndex(uid).then((result) => {
render(result);
}).catch(next);
}
... ... @@ -152,16 +153,14 @@ const index = (req, res, next) => {
}),
pageFooter: true,
search: {
defaultTerms: (result && result.defaultTerms &&
result.defaultTerms.length !== 0) ? result.defaultTerms[0].content : '',
defaultTerms: (result && result.hotTerms && result.hotTerms.defaultTerms && result.hotTerms.defaultTerms.length !== 0) ? result.hotTerms.defaultTerms[0].content : '',
url: helpers.urlFormat('', null, 'search'),
hotTerms: result.hotTerms
hotTerms: result.hotTerms.hotTerms,
wantTerms: result.wantTerms.guessTerms
}
});
});
};
/**
... ...
... ... @@ -262,32 +262,34 @@ const getAllBrandNames = () => {
* 获取猜你想找
**/
const getWantSearch = (uid) => {
return [];
// return api.get('', {
// method: 'app.search.getSomeTerms',
// uid: uid
// }, {
// cache: true
// }).then((result) => {
// if (result && result.code === 200) {
// return result.data;
// } else {
// logger.error('Hot Search return code is not 200');
// return {};
// }
// });
return api.get('', {
method: 'app.search.getSomeTerms',
uid: uid
}, {
cache: true
}).then((result) => {
if (result && result.code === 200) {
return result.data;
} else {
logger.error('Hot Search return code is not 200');
return {};
}
});
};
/**
* 获取热门搜索
**/
const getSearchIndex = () => {
const getHotSearch = () => {
return api.get('', {
method: 'app.search.getTerms'
}, {
cache: true
}).then((result) => {
if (result && result.code === 200) {
if (result.data.hotTerms && result.data.hotTerms.length > 10) {
result.data.hotTerms = result.data.hotTerms.slice(0, 10);
}
return result.data;
} else {
logger.error('Hot Search return code is not 200');
... ... @@ -299,14 +301,14 @@ const getSearchIndex = () => {
/**
* 搜索主页
*/
// const getSearchIndex = (uid) => {
// return Promise.all([getHotSearch(), getWantSearch(uid)]).then((result) => {
// return {
// hotTerms: result[0],
// wantTerms: result[1]
// };
// });
// };
const getSearchIndex = (uid) => {
return Promise.all([getHotSearch(), getWantSearch(uid)]).then((result) => {
return {
hotTerms: result[0],
wantTerms: result[1]
};
});
};
/**
* 获取联想词
... ...
... ... @@ -537,7 +537,11 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
return;
}
if (num <= discountNum) {
if (discountNum && num <= discountNum + 1) {
$('.btn-minus').addClass('discount-gray');
}
if (discountNum && num <= discountNum) {
tip.show('量贩商品,' + discountNum + '件起购');
return;
}
... ... @@ -563,6 +567,10 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
return;
}
if (discountNum && num >= discountNum) {
$('.btn-minus').removeClass('discount-gray');
}
if (num - 0 === leftNum || leftNum === 0) {
return;
}
... ...
... ... @@ -131,41 +131,41 @@ function inputAction() {
C_ID = window._ChannelVary[window.cookie('_Channel')];
// function yasRequest(PRD_ID, PRD_NUM, ACTION_ID) {
// if (window._yas && window._yas.sendCustomInfo) {
// window._yas.sendCustomInfo({
// op: 'YB_CHOOSE_FOR_YOU_Y',
// param: JSON.stringify({
// REC_POSE: 100016,
// REC_ID: RECID,
// PRD_ID: PRD_ID,
// PRD_NUM: PRD_NUM,
// C_ID: C_ID,
// ACTION_ID: ACTION_ID
// })
// }, true);
// }
// }
function yasRequest(PRD_ID, PRD_NUM, ACTION_ID) {
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_CHOOSE_FOR_YOU_Y',
param: JSON.stringify({
REC_POSE: 100016,
REC_ID: RECID,
PRD_ID: PRD_ID,
PRD_NUM: PRD_NUM,
C_ID: C_ID,
ACTION_ID: ACTION_ID
})
}, true);
}
}
// 猜你想找展示时埋点
// $('.want-search').find('li').each(function() {
$('.want-search').find('li').each(function() {
// querys = $(this).find('a').html();
querys = $(this).find('a').html();
// if (querys) {
// prdids.push(querys);
// }
// });
if (querys) {
prdids.push(querys);
}
});
// prdLoad = JSON.stringify(prdids).replace(/\[|\]|\"|/g, '');
prdLoad = JSON.stringify(prdids).replace(/\[|\]|\"|/g, '');
// if (prdLoad) {
// setTimeout(function() {
// yasRequest(encodeURIComponent(prdLoad), prdids.length, 0);
// }, 200);
// }
if (prdLoad) {
setTimeout(function() {
yasRequest(encodeURIComponent(prdLoad), prdids.length, 0);
}, 200);
}
// 热门搜索、最近搜索事件
$('.search-items .search-group').on('click', 'li', function(event) {
... ... @@ -185,15 +185,14 @@ $('.search-items .search-group').on('click', 'li', function(event) {
} else if ($(this).parents('.search-group').hasClass('hot-search-new')) {
POS_ID = 2;
FLR_INDEX = 2;
}
// else {
// var PRD_NUM = $(this).index() + 1;
} else {
var PRD_NUM = $(this).index() + 1;
// POS_ID = 3;
// FLR_INDEX = 3;
POS_ID = 3;
FLR_INDEX = 3;
// yasRequest(query, PRD_NUM, 1);
// }
yasRequest(query, PRD_NUM, 1);
}
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
... ... @@ -247,11 +246,11 @@ $search.on('touchend', function() {
return false;
});
// navSwiper = new Swiper('.new-hot', {
// grabCursor: true,
// slidesPerView: 'auto',
// slideElement: 'li'
// });
navSwiper = new Swiper('.new-hot', {
grabCursor: true,
slidesPerView: 'auto',
slideElement: 'li'
});
// 初始化历史搜索的内容
(function() {
... ...
body {
background-color: #f0f0f0;
}
//body {
// background-color: #f0f0f0;
//}
.bundle-detail-goods {
width: 100%;
... ...
... ... @@ -8,4 +8,4 @@
@import "../../common/good";
@import "../../cart/chose-panel";
@import "../../common/_suspend-home.css";
@import "bundle";
... ...
... ... @@ -47,11 +47,6 @@
}
.search-items {
<<<<<<< HEAD
padding: 40px 20px;
=======
>>>>>>> feature/wantSearch
h3 {
font-size: 24px;
margin-bottom: 20px;
... ... @@ -66,7 +61,7 @@
}
a {
display: block;
display: inline-block;
height: 68px;
line-height: 68px;
padding: 0 20px;
... ... @@ -78,11 +73,9 @@
white-space: nowrap;
}
<<<<<<< HEAD
=======
.search-index {
padding-top: 30px;
border-top: 1px solid #e0e0e0;
background: #fff;
}
.hot-search-new {
... ... @@ -114,7 +107,6 @@
}
}
>>>>>>> feature/wantSearch
.clear-icon {
float: right;
background: #fff;
... ... @@ -125,7 +117,7 @@
}
.search-group {
border-bottom: 1px solid #e6e6e6;
background: #fff;
.ico-hot {
width: 22px;
... ... @@ -174,7 +166,6 @@
.search-content {
clear: both;
padding-left: 47px;
box-sizing: border-box;
padding-bottom: 18px;
... ... @@ -183,13 +174,27 @@
border: 2px solid #e0e0e0;
background: #fff;
font-size: 28px;
width: auto;
}
}
.hot-search {
margin-top: 38px;
.history-search {
padding: 30px;
}
.want-search {
padding: 30px;
}
.want {
max-height: 264px;
overflow: hidden;
}
}
.swiper-slide {
width: auto;
}
}
.search-associate {
... ... @@ -341,4 +346,4 @@
font-size: 24px;
}
}
}
\ No newline at end of file
}
... ...