Authored by zhangxiaoru

merge

... ... @@ -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,9 +153,10 @@ 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
}
});
... ...
... ... @@ -178,7 +178,7 @@ const getSearchData = (params) => {
gender: _coverChannel[params.coverChannel]
});
if (parseInt(params.page) === 1) {
if (parseInt(params.page, 10) === 1) {
newList.total = result.data.total;
}
... ... @@ -259,15 +259,37 @@ const getAllBrandNames = () => {
};
/**
* 获取猜你想找
**/
const getWantSearch = (uid) => {
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');
... ... @@ -277,6 +299,18 @@ const getSearchIndex = () => {
};
/**
* 搜索主页
*/
const getSearchIndex = (uid) => {
return Promise.all([getHotSearch(), getWantSearch(uid)]).then((result) => {
return {
hotTerms: result[0],
wantTerms: result[1]
};
});
};
/**
* 获取联想词
* @param params
* @returns {*|Promise.<TResult>}
... ...
... ... @@ -11,26 +11,42 @@
</form>
</div>
<ul class="search-associate"></ul>
<div class="search-items">
{{#if hotTerms}}
<div class="hot-search-new search-group">
<div class="search-content new-hot">
<ul class="clearfix swiper-wrapper">
<li class="swiper-slide hot-title">热搜</li>
{{# hotTerms}}
<li class="swiper-slide hot-term">
<a href='javascript:void(0);'>{{content}}</a>
</li>
{{/ hotTerms}}
</ul>
</div>
</div>
{{/if}}
<div class="search-group history-search">
<div class="search-content-title">
<h3 class="left"><i class="ico-lately"></i>最近搜索</h3>
<h3 class="left">最近搜索</h3>
<i id="clear-history" class="right ico-del hide"></i>
</div>
<div class="search-content">
<ul class="history clearfix"></ul>
</div>
</div>
{{#if hotTerms}}
<div class="search-group hot-search">
<h3><i class="ico-hot"></i>热门搜索</h3>
{{#if wantTerms}}
<div class="search-group want-search">
<h3>猜你想找</h3>
<div class="search-content">
<ul class="hot clearfix">
{{# hotTerms}}
<ul class="want clearfix">
{{# wantTerms}}
<li>
<a href='javascript:void(0);'>{{content}}</a>
<a href='javascript:void(0);'>{{.}}</a>
</li>
{{/ hotTerms}}
{{/ wantTerms}}
</ul>
</div>
</div>
... ...
'use strict';
const fs = require('fs');
let devHost = '127.0.0.1';
let devHost = '172.16.6.134';
fs.readFile('.devhost', (err, buf)=> {
if (!err) {
... ...
const seoMap = {
/* eslint-disable */
'/': {
title: 'Yoho!BuyBuy有货|年轻人潮流购物中心,中国潮流购物风向标',
keywords: 'Yoho!BuyBuy有货 有货官网,潮流志,潮流男装,潮牌,美国潮牌,日本潮牌,香港潮牌,潮牌店,新品首发,欧美潮流,全球购,代购,时尚,流行,特卖,B2C,正品,购物网站,网上购物,货到付款',
description: 'Yoho!BuyBuy有货,年轻人潮流购物中心,中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。'
title: 'Yoho!Buy有货|年轻人潮流购物中心,中国潮流购物风向标',
keywords: 'Yoho!Buy有货 有货官网,潮流志,潮流男装,潮牌,美国潮牌,日本潮牌,香港潮牌,潮牌店,新品首发,欧美潮流,全球购,代购,时尚,流行,特卖,B2C,正品,购物网站,网上购物,货到付款',
description: 'Yoho!Buy有货,年轻人潮流购物中心,中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。'
},
'/boys': {
title: '男式服饰|男装,休闲男装,时尚男装品牌|Yoho!Buy有货',
... ... @@ -11,19 +11,19 @@ const seoMap = {
description: 'Yoho!Buy有货男装汇集国内国际各大男装品牌,提供品牌男装、休闲男装、商务男装、外套,100%正品保证!'
},
'/girls': {
title: '潮流女装|时尚女装,日韩女装,潮牌女装全球购|Yoho!BuyBUY有货',
title: '潮流女装|时尚女装,日韩女装,潮牌女装全球购|Yoho!BUY有货',
keywords: '潮流女装,女生服饰,时尚潮流女装,日韩女装,女装正品购物网站,女装全球购',
description: 'Yoho!BuyBUY有货官网女生频道汇集了全球女装潮流时尚,提供时尚潮流女装,日版女装,韩版女装,潮牌女装正品全球购,100%正品保证!'
description: 'Yoho!BUY有货官网女生频道汇集了全球女装潮流时尚,提供时尚潮流女装,日版女装,韩版女装,潮牌女装正品全球购,100%正品保证!'
},
'/kids': {
title: '潮童|男童装,女童装,韩版儿童服装服饰|Yoho!BuyBUY有货',
title: '潮童|男童装,女童装,韩版儿童服装服饰|Yoho!BUY有货',
keywords: '潮童,男童装,女童装,韩版童装,儿童服装服饰',
description: 'Yoho!BuyBUY有货官网潮童频道汇集了全球潮童潮流时尚,提供新款男童装,女童装,韩版童装,儿童服装服饰正品全球购。'
description: 'Yoho!BUY有货官网潮童频道汇集了全球潮童潮流时尚,提供新款男童装,女童装,韩版童装,儿童服装服饰正品全球购。'
},
'/lifestyle': {
title: '创意生活|创意生活馆,潮流创意家居,家居生活用品|Yoho!BuyBUY有货',
title: '创意生活|创意生活馆,潮流创意家居,家居生活用品|Yoho!BUY有货',
keywords: '创意生活,创意生活馆,潮流家居,潮流创意家居,家居生活用品,Yoho!Buy有货',
description: 'Yoho!BuyBUY有货官网创意生活频道提供了潮流创意家居,家居生活用品等正品网购,给您的生活带来更多创意。'
description: 'Yoho!BUY有货官网创意生活频道提供了潮流创意家居,家居生活用品等正品网购,给您的生活带来更多创意。'
},
'/product/sale?channel=boys': {
title: '折扣男装专区|男装SALE折扣,男款鞋包配饰特卖|Yoho!Buy有货 100%正品保证',
... ...
... ... @@ -27,7 +27,7 @@ if (!shelljs.grep('npm run -s', path.resolve('./.git/hooks/pre-commit')).stdout.
if (changeFiles.js) {
changeFiles.js = changeFiles.js.replace(/\n/g, ' ');
lintResult.js = shelljs.exec(`${lintPath.js}${ext} -c .eslintrc --cache --fix ${changeFiles.js}`);
lintResult.js = shelljs.exec(`${lintPath.js}${ext} -c .eslintrc --cache ${changeFiles.js}`);
}
if (changeFiles.css) {
... ... @@ -37,7 +37,7 @@ if (changeFiles.css) {
if (changeFiles.vue) {
changeFiles.vue = changeFiles.vue.replace(/\n/g, ' ');
lintResult.vueScript = shelljs.exec(`${lintPath.js}${ext} -c .eslintrc --cache --fix ${changeFiles.vue}`);
lintResult.vueScript = shelljs.exec(`${lintPath.js}${ext} -c .eslintrc --cache ${changeFiles.vue}`);
lintResult.vueStyle = shelljs.exec(`${lintPath.css}${ext} --syntax scss --extract --config .stylelintrc ${changeFiles.vue}`); // eslint-disable-line
}
... ...
{
"name": "m-yohobuy-node",
"version": "5.2.16",
"version": "5.2.17",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -5,6 +5,7 @@
*/
var $ = require('yoho-jquery');
var FastClick = require('yoho-fastclick');
var $nav = $('.category-nav'),
$search = $('#search-input'),
... ... @@ -15,6 +16,10 @@ var $nav = $('.category-nav'),
require('../common');
$(function() {
FastClick.attach(document.body);
});
function resetHeight() {
var h = document.body.scrollHeight - $search.outerHeight() - $nav.outerHeight();
... ... @@ -47,7 +52,7 @@ $nav.on('touchend touchcancel', function(e) {
$contents.filter(selector).removeClass('hide');
});
$categoryContainer.on('touchend', function(e) {
$categoryContainer.on('click', function(e) {
var $this = $(e.target),
$subLevel,
$cur, index;
... ... @@ -59,6 +64,14 @@ $categoryContainer.on('touchend', function(e) {
e.preventDefault();
}
if ($this[0] && $this[0].tagName === 'LI' && $this.find('a').attr('href')) {
location.href = $this.find('a').attr('href');
}
if ($this[0] && $this[0].tagName === 'A' && $this.attr('href')) {
location.href = $this.attr('href');
}
if ($cur.length > 0) {
index = $cur.index();
$subLevel = $this.closest('.content').find('.sub-level');
... ... @@ -73,14 +86,6 @@ $categoryContainer.on('touchend', function(e) {
$subLevel.not('.hide').addClass('hide');
$subLevel.eq(index).removeClass('hide');
}
if ($this[0] && $this[0].tagName === 'LI' && $this.find('a').attr('href')) {
location.href = $this.find('a').attr('href');
}
if ($this[0] && $this[0].tagName === 'A' && $this.attr('href')) {
location.href = $this.attr('href');
}
});
$categoryContainer.find('.primary-level').on('touchstart touchend touchcancel', 'li', function() {
... ...
... ... @@ -128,13 +128,17 @@ function rePosFooter() {
return;
}
$footer.addClass('bottom');
winH = Math.min($(window).height(), window.screen.availHeight);
if ($('body').height() <= winH) {
$footer.addClass('bottom');
} else {
if ($('body').height() >= winH - parseInt($footer.css('height'), 0)) {
$footer.removeClass('bottom');
}
// else {
// $footer.removeClass('bottom');
// }
}
/**
... ...
... ... @@ -8,7 +8,8 @@ var $ = require('yoho-jquery'),
security = require('../../plugin/security'),
tip = require('../../plugin/tip'),
Hammer = require('yoho-hammer'),
dialog = require('../../plugin/dialog');
dialog = require('../../plugin/dialog'),
Swiper = require('yoho-swiper');
var $input = $('#search-input input');
... ... @@ -29,9 +30,12 @@ var writeSearch = require('./write-search');
var ranToken = writeSearch.getRanToken();
var historyval = writeSearch.getHistoryval();
var chHammer, cHammer;
var chHammer, cHammer, navSwiper;
var C_ID, POS_ID, FLR_INDEX;
var C_ID, POS_ID, FLR_INDEX, prdLoad, querys, prdids = [];
var RECID = (new Date().getTime() + '_H5_YOHOBUY_' + Math.floor(Math.random() * 1000000 + 1000000) +
'_' + Math.floor(Math.random() * 1000000 + 1000000));
require('../../common');
... ... @@ -127,6 +131,42 @@ 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);
}
}
// 猜你想找展示时埋点
$('.want-search').find('li').each(function() {
querys = $(this).find('a').html();
if (querys) {
prdids.push(querys);
}
});
prdLoad = JSON.stringify(prdids).replace(/\[|\]|\"|/g, '');
if (prdLoad) {
setTimeout(function() {
yasRequest(encodeURIComponent(prdLoad), prdids.length, 0);
}, 200);
}
// 热门搜索、最近搜索事件
$('.search-items .search-group').on('click', 'li', function(event) {
var query = '';
... ... @@ -142,9 +182,16 @@ $('.search-items .search-group').on('click', 'li', function(event) {
if ($(this).parents('.search-group').hasClass('history-search')) {
POS_ID = 1;
FLR_INDEX = 1;
} else {
} else if ($(this).parents('.search-group').hasClass('hot-search-new')) {
POS_ID = 2;
FLR_INDEX = 2;
} else {
var PRD_NUM = $(this).index() + 1;
POS_ID = 3;
FLR_INDEX = 3;
yasRequest(query, PRD_NUM, 1);
}
if (window._yas && window._yas.sendCustomInfo) {
... ... @@ -199,6 +246,12 @@ $search.on('touchend', function() {
return false;
});
navSwiper = new Swiper('.new-hot', {
grabCursor: true,
slidesPerView: 'auto',
slideElement: 'li'
});
// 初始化历史搜索的内容
(function() {
var html = '',
... ... @@ -242,4 +295,6 @@ $search.on('touchend', function() {
$historySearch.hide();
$clearHistory.hide();
}
window.rePosFooter();
}());
... ...
.search-page {
/*.search-page {
.search-input {
position: relative;
padding: 14px 22px;
... ... @@ -83,7 +83,6 @@
}
.search-group {
border-bottom: 1px solid #e6e6e6;
.ico-hot {
width: 22px;
... ... @@ -132,7 +131,6 @@
.search-content{
clear: both;
padding-left: 47px;
box-sizing: border-box;
padding-bottom: 18px;
... ... @@ -150,7 +148,7 @@
}
}
}
}*/
.search-associate {
width: 100%;
... ...
... ... @@ -81,6 +81,7 @@ button {
max-width: 750px;
}
/* 字体名称勿改的,APP做IP直连有使用到 */
@font-face {
font-family: "iconfont";
src: resolve("iconfont.eot"); /* IE9 */
... ...
... ... @@ -47,7 +47,7 @@
}
.search-items {
padding: 40px 20px;
background: #f0f0f0;
h3 {
font-size: 24px;
... ... @@ -63,7 +63,7 @@
}
a {
display: block;
display: inline-block;
height: 68px;
line-height: 68px;
padding: 0 20px;
... ... @@ -75,6 +75,28 @@
white-space: nowrap;
}
.hot-search-new {
height: 120px;
background: #fff;
margin-bottom: 30px;
.new-hot {
overflow: hidden;
}
.hot-title {
font-size: 32px;
color: #000;
line-height: 130px;
height: 120px;
padding-left: 30px;
}
.hot-term {
padding-top: 30px;
}
}
.clear-icon {
float: right;
background: #fff;
... ... @@ -85,7 +107,7 @@
}
.search-group {
border-bottom: 1px solid #e6e6e6;
background: #fff;
.ico-hot {
width: 22px;
... ... @@ -134,7 +156,6 @@
.search-content {
clear: both;
padding-left: 47px;
box-sizing: border-box;
padding-bottom: 18px;
... ... @@ -144,12 +165,26 @@
background: #fff;
color: #b0b0b0;
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;
}
}
... ... @@ -290,7 +325,7 @@
border-bottom: 1px solid #f3f3f3;
}
.hot-search {
.want-search {
margin-top: 20px;
}
... ...