Authored by 王水玲

搜索,代码检查修改

... ... @@ -12,7 +12,7 @@ const _ = require('lodash');
const helpers = global.yoho.helpers;
const list = (req, res) => {
const list = (req, res, next) => {
let params = Object.assign({}, req.query);
let title = '';
let query = req.query.query;
... ... @@ -25,49 +25,85 @@ const list = (req, res) => {
cartUrl: helpers.urlFormat('/cart/index/index')
}, params);
// 品类 品牌
if (query) {
domain = searchModel.getAllBrandNames(query);
// 跳转到品牌商品列表页
//if (domain !== null && !params.shop_id) {
// $url = Helpers::url('', array(
// 'from' => 'search',
// 'query' => $query
//), $domain);
// $this->go($url);
//}
} else {
params.query = '';
}
// 搜索是一级品类
if (isQueryFirstClass) {
title = '全部' + query;
} // 搜索是二级品类
else if (isQuerySecondClass) {
title = query;
} // 搜索其它内容
else {
/* 判断是不是品牌, 是品牌跳到品牌列表页(显示搜索框),判断是不是品类, 是品类加导航标题(不显示搜索框) */
Promise.all([searchModel.getAllBrandNames(), searchModel.getClassNames()]).then((result) => {
if (query) {
params.search = {
default: query === '' ? false : query,
url: ''
};
_.forEach(result[0], function(obj) {
if (query === obj.brandDomain) { // 精确查品牌域名
domain = query;
return false;
}
if (query === obj.brandName) { // 精确查品牌名称
domain = obj.brandName;
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);
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.search = {
default: query === '' ? false : query,
url: ''
};
}
title = '搜索';
}
title = '搜索';
}
res.render('search/list', {
module: 'product',
page: 'search-list',
pageHeader: headerModel.setNav({
navTitle: title
}),
goodList: params,
pageFooter: true
});
res.render('search/list', {
module: 'product',
page: 'search-list',
pageHeader: headerModel.setNav({
navTitle: title
}),
goodList: params,
pageFooter: true
});
}).catch(next);
};
const search = (req, res, next) => {
... ...
... ... @@ -10,8 +10,6 @@ const camelCase = global.yoho.camelCase;
const productProcess = require(`${utils}/product-process`);
const _ = require('lodash');
const api = global.yoho.API;
const serviceAPI = global.yoho.ServiceAPI;
const helpers = global.yoho.helpers;
/**
* 排序转换
... ... @@ -26,14 +24,6 @@ const typeCont = {
category: ['s_t_desc', 's_t_asc']
};
const channelType = {
boys: '1',
girls: '2',
kids: '3',
lifestyle: '4',
all: '1,2,3,4'
};
/**
* 商品搜索接口请求
* @param {[object]} params
... ... @@ -81,8 +71,8 @@ const _processBrandNames = (list) => {
list = list || [];
list = camelCase(list);
_.forEach(list, function(item) {
_.forEach(item, function(obj) {
_.forEach(list, (item) => {
_.forEach(item, (obj) => {
formatData.push({
brandDomain: obj.brandDomain,
brandName: obj.brandName
... ... @@ -94,9 +84,40 @@ const _processBrandNames = (list) => {
};
/**
* 品牌名称处理
* @param {[object]} list
* @return {[object]}
*/
const _processClassNames = (list) => {
const formatData = {
first: {},
second: {}
};
list = list || [];
list = camelCase(list);
_.forEach(list, (item) => {
_.forEach(item, (obj) => {
formatData.first[obj.categoryId] = obj.categoryName;
if (obj.sub) {
_.forEach(obj.sub, (sub) => {
formatData.second[sub.categoryId] = sub.categoryName;
});
}
});
});
return formatData;
};
/**
* 获取商品数据
*/
const getSearchData = (params, uid) => {
const getSearchData = (params) => {
return _searchSales(params).then((result) => {
if (result && result.code === 200) {
return productProcess.processProductList(result.data.product_list || []);
... ... @@ -126,34 +147,34 @@ const getFilterData = (params) => {
/**
* 获取所有的品牌名称
**/
const getAllBrandNames = (query) => {
const getAllBrandNames = () => {
return api.get('', {
method: 'app.brand.brandlist'
}, {
cache: true
}).then((result) => {
if (result && result.code === 200) {
let domain = null;
let brandNames = _processBrandNames(result.data.brands);
_.forEach(brandNames, function(obj) {
// 精确查品牌域名
if (query === obj.brandDomain) {
domain = query;
}
// 精确查品牌名称
if (query === obj.brandName) {
domain = query;
}
// 模糊查品牌域名
//if ()
});
return _processBrandNames(result.data.brands);
} else {
logger.error('品牌名称接口返回 code 不是 200');
return {};
}
});
};
return domain;
/**
* 获取所有的品类名称
**/
const getClassNames = () => {
return api.get('', {
method: 'app.sort.get'
}, {
cache: true
}).then((result) => {
if (result && result.code === 200) {
return _processClassNames(result.data);
} else {
logger.error('断码区分类接口返回 code 不是 200');
logger.error('品类名称接口返回 code 不是 200');
return {};
}
});
... ... @@ -162,5 +183,6 @@ const getAllBrandNames = (query) => {
module.exports = {
getSearchData,
getFilterData,
getAllBrandNames
getAllBrandNames,
getClassNames
};
... ...
var $ = require('yoho-jquery'),
phone,
reg,
... ...
... ... @@ -5,11 +5,9 @@
*/
var $ = require('yoho-jquery');
var $resend = $('#resend');
var tip = require('../../plugin/tip'),
showTip = tip.show;
var tip = require('../../plugin/tip');
var showTip = tip.show;
$resend.on('touchstart', function(e) {
e.preventDefault();
... ...
... ... @@ -146,7 +146,7 @@ function getQueryString(name) {
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
var r = window.location.search.substr(1).match(reg);
if (r != null) {
if (r !== null) {
return window.unescape(r[2]);
}
return null;
... ... @@ -240,6 +240,8 @@ function search(opt) {
outlets: opt.id
};
break;
default:
break;
}
$.extend(defaultOpt, ext); // 扩展筛选项
... ... @@ -315,6 +317,8 @@ function search(opt) {
case 'discount':
$container = $dgc;
break;
default:
break;
}
if (data === ' ') {
... ... @@ -367,6 +371,8 @@ function search(opt) {
window._yas(1 * new Date(), '1.0.16', 'yohobuy_m', window._ozuid,
'', $('.discount-goods .good-info .good-detail-img .good-thumb'));
break;
default:
break;
}
}
}
... ... @@ -407,7 +413,7 @@ writeSearch.bindWirteLocal($('#search-form'));
// 4.筛选有active时点击隐藏筛选面板并恢复点击筛选前active项的active状态
// 5.当前active为筛选并且点击其他项时,隐藏筛选面板
$listNav.bind('contextmenu', function(e) {
$listNav.bind('contextmenu', function() {
return false;
});
... ...
... ... @@ -17,17 +17,9 @@ function getHistoryval() {
return historyval;
}
// 绑定提交前的存local操作
function bindWirteLocal($form) {
$form.on('submit', function() {
var query = this.query.value;
setHistoryValFun(query);
});
}
function setHistoryValFun(query) {
var historys;
if (localStorage) {
historys = localStorage.getItem(historyval);
... ... @@ -42,6 +34,15 @@ function setHistoryValFun(query) {
}
}
// 绑定提交前的存local操作
function bindWirteLocal($form) {
$form.on('submit', function() {
var query = this.query.value;
setHistoryValFun(query);
});
}
exports.getRanToken = getRanToken;
exports.getHistoryval = getHistoryval;
exports.setHistoryValFun = setHistoryValFun;
... ...
... ... @@ -124,7 +124,7 @@
&.chosed {
border-color: #e10;
background: resolve('shopping-cart/right.png') no-repeat;
background: resolve("shopping-cart/right.png") no-repeat;
background-position: bottom right;
background-size: 38px;
color: #e10;
... ...
... ... @@ -56,13 +56,13 @@
display: inline-block;
width: 52px;
height: 54px;
background-image: url('/channel/click-txt.png');
background-image: url("/channel/click-txt.png");
}
&.received {
width: 113px;
height: 132px;
background-image: url('/channel/received.png');
background-image: url("/channel/received.png");
position: absolute;
top: 0;
right: 0;
... ... @@ -71,7 +71,7 @@
&.zero {
width: 111px;
height: 132px;
background-image: url('/channel/zero.png');
background-image: url("/channel/zero.png");
position: absolute;
top: 0;
right: 0;
... ...
... ... @@ -7,7 +7,7 @@
border: none;
border-bottom: 8px solid #fff;
background-color: transparent;
background-image: resolve('channel/yohood.png');
background-image: resolve("channel/yohood.png");
background-position-x: 26%;
background-position-y: 36%;
background-size: 40%;
... ... @@ -17,7 +17,7 @@
#yohood:active {
border-bottom-color: #000;
background-color: rgba(255, 255, 255, 0.4);
background-image: resolve('channel/yohood-tapped.png');
background-image: resolve("channel/yohood-tapped.png");
.right-icon {
color: #000;
... ...
... ... @@ -28,7 +28,7 @@
background-color: #fff;
&:before {
content: '';
content: "";
position: absolute;
border-top: 1px solid #ccc;
left: 0;
... ...
... ... @@ -10,7 +10,7 @@
background-color: #fff;
&:after {
content: '';
content: "";
position: absolute;
right: 0;
top: 16px;
... ...
... ... @@ -27,7 +27,7 @@
background: #fff;
&:after {
content: '';
content: "";
position: absolute;
right: 0;
bottom: 0;
... ...
... ... @@ -7,7 +7,7 @@
left: 50%;
margin-left: -2.5rem;
margin-top: -2.5rem;
background: resolve('common/404.png') no-repeat;
background: resolve("common/404.png") no-repeat;
background-size: 100% 100%;
}
}
... ...
... ... @@ -97,7 +97,6 @@
.forward {
width: 40px;
height: 28px;
float: right;
margin-left: 45px;
font-size: 24px;
... ... @@ -113,6 +112,6 @@
.star-class-body {
background: #333;
width: 100%;
font: 12px/1.5 Arial, '黑体';
font: 12px/1.5 Arial, "黑体";
float: left;
}
... ...
... ... @@ -294,7 +294,7 @@
.pic-icon {
width: 19px;
height: 15px;
background: url('/guang/star/img.png') no-repeat;
background: url("/guang/star/img.png") no-repeat;
background-size: contain;
display: inline-block;
margin: 6px 4px 0 8px;
... ... @@ -394,7 +394,7 @@
}
.default-avater {
background-image: resolve('guang/star/user-avatar.png');
background-image: resolve("guang/star/user-avatar.png");
}
.loading-tip {
... ...
... ... @@ -62,8 +62,8 @@ a {
@font-face {
font-family: "iconfont";
src: resolve('iconfont.eot'); /* IE9 */
src: resolve('iconfont.eot?#iefix') format('embedded-opentype'), resolve('iconfont.woff') format('woff'), resolve('iconfont.ttf') format('truetype'), resolve('iconfont.svg#iconfont') format('svg'); /* iOS 4.1- */
src: resolve("iconfont.eot"); /* IE9 */
src: resolve("iconfont.eot?#iefix") format("embedded-opentype"), resolve("iconfont.woff") format("woff"), resolve("iconfont.ttf") format("truetype"), resolve("iconfont.svg#iconfont") format("svg"); /* iOS 4.1- */
}
.iconfont {
... ... @@ -95,12 +95,12 @@ a {
}
.order-failure {
background-image: resolve('common/order-good.jpg');
background-image: resolve("common/order-good.jpg");
background-size: 100%;
}
.good-failure {
background-image: resolve('common/order-good.jpg');
background-image: resolve("common/order-good.jpg");
background-position-x: 40%;
background-size: 132px !important;
}
... ...
@import 'suggest';
@import "suggest";
... ...
... ... @@ -13,7 +13,7 @@
background-image: linear-gradient(#383838, #505050);
&:before {
content: '';
content: "";
display: block;
background: url("/me/suggest/suggest-logo.png");
width: 104px;
... ... @@ -192,7 +192,7 @@
height: 130px;
float: left;
margin-right: 30px;
background: resolve('common/loading.gif') center center no-repeat;
background: resolve("common/loading.gif") center center no-repeat;
background-size: 50%;
position: relative;
... ... @@ -227,7 +227,7 @@
float: left;
&:after {
content: '';
content: "";
display: block;
background: url("/me/suggest/suggest-add.png");
width: 72px;
... ...
... ... @@ -5,7 +5,7 @@
}
#yohood {
background-image: resolve('./common/yohood.png');
background-image: resolve("./common/yohood.png");
background-size: 40%;
background-repeat: no-repeat;
background-color: transparent;
... ...
... ... @@ -43,7 +43,7 @@ body.passport-body {
width: 30PX;
top: 5PX;
left: 0;
background: resolve('passport/go-back.png') no-repeat;
background: resolve("passport/go-back.png") no-repeat;
background-size: 100% 100%;
}
.title {
... ... @@ -54,7 +54,7 @@ body.passport-body {
.img-header {
width: 68PX;
height: 40PX;
background: resolve('passport/yoho-family.png') no-repeat;
background: resolve("passport/yoho-family.png") no-repeat;
background-size: 100% 100%;
margin: 0 auto;
}
... ... @@ -104,7 +104,7 @@ body.passport-body {
height: 20PX;
right: 15PX;
top: 16PX;
background: resolve('passport/arrow-right.png') no-repeat;
background: resolve("passport/arrow-right.png") no-repeat;
background-size: 100% 100%;
}
}
... ... @@ -152,7 +152,7 @@ body.passport-body {
right: 10PX;
width: 16PX;
height: 16PX;
background: resolve('passport/clear-input.png') no-repeat;
background: resolve("passport/clear-input.png") no-repeat;
background-size: 100% 100%;
}
.eye {
... ... @@ -161,10 +161,10 @@ body.passport-body {
right: 10PX;
width: 19PX;
height: 12PX;
background: resolve('passport/eye.png') no-repeat;
background: resolve("passport/eye.png") no-repeat;
background-size: 100% 100%;
&.close {
background-image: resolve('passport/eye-close.png');
background-image: resolve("passport/eye-close.png");
}
}
.row {
... ...
... ... @@ -3,7 +3,7 @@
position: absolute;
height: 31PX;
width: 26PX;
background: resolve('passport/yoho.png');
background: resolve("passport/yoho.png");
background-size: 100% 100%;
top: 10PX;
left: 15PX;
... ... @@ -57,20 +57,20 @@
}
.alipay {
background-image: resolve('passport/alipay.png');
background-image: resolve("passport/alipay.png");
}
.weibo {
background-image: resolve('passport/weibo.png');
background-image: resolve("passport/weibo.png");
}
.qq {
background-image: resolve('passport/qq.png');
background-image: resolve("passport/qq.png");
}
.wechat {
display: none;
background-image: resolve('passport/wechat.png');
background-image: resolve("passport/wechat.png");
}
}
}
... ... @@ -97,7 +97,7 @@
display: inline-block;
height: 12PX;
width: 12PX;
background-image: resolve('passport/info.png');
background-image: resolve("passport/info.png");
background-size: 100% 100%;
}
}
... ...
... ... @@ -384,13 +384,13 @@ $basicBtnC: #eb0313;
text-align: left;
.vip-img {
background: resolve('product/silver.png') no-repeat;
background: resolve("product/silver.png") no-repeat;
}
}
&:nth-child(2) {
.vip-img {
background: resolve('product/golden.png') no-repeat;
background: resolve("product/golden.png") no-repeat;
}
}
... ... @@ -398,7 +398,7 @@ $basicBtnC: #eb0313;
text-align: right;
.vip-img {
background: resolve('product/platinum.png') no-repeat;
background: resolve("product/platinum.png") no-repeat;
}
}
}
... ...
... ... @@ -7,7 +7,7 @@
margin-left: 50px;
width: 494px;
height: 28px;
background: resolve('product/service.png') no-repeat;
background: resolve("product/service.png") no-repeat;
background-size: cover;
}
... ...
... ... @@ -103,7 +103,8 @@
}
}
.btn-intro, .btn-col {
.btn-intro,
.btn-col {
position: absolute;
display: block;
width: 124px;
... ... @@ -133,11 +134,11 @@
}
.txt:after {
content: '收藏'
content: "收藏";
}
&.coled .txt:after {
content: '已收藏'
content: "已收藏";
}
}
... ... @@ -147,7 +148,7 @@
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,.3);
background: rgba(0, 0, 0, 0.3);
padding: 88px 0;
z-index: 1;
overflow: auto;
... ... @@ -206,8 +207,9 @@
text-align: center;
font-size: 28px;
}
.bytouch{
background:#eee;
.bytouch {
background: #eee;
}
a {
... ...
... ... @@ -89,7 +89,7 @@
width: 22px;
height: 30px;
display: inline-block;
background: url('/search/hot-ico.png') no-repeat;
background: url("/search/hot-ico.png") no-repeat;
margin-right: 20px;
position: relative;
top: 2px;
... ... @@ -108,7 +108,7 @@
width: 26px;
height: 26px;
display: inline-block;
background: url('/search/time-ico.png') no-repeat;
background: url("/search/time-ico.png") no-repeat;
margin-right: 20px;
position: relative;
top: 2px;
... ... @@ -118,7 +118,7 @@
width: 24px;
height: 26px;
display: inline-block;
background: url('/search/del-ico.png') no-repeat;
background: url("/search/del-ico.png") no-repeat;
}
.left {
... ... @@ -130,7 +130,7 @@
}
}
.search-content{
.search-content {
clear: both;
padding-left: 47px;
box-sizing: border-box;
... ... @@ -263,7 +263,7 @@
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
border:1px solid #b8b8b8;
border: 1px solid #b8b8b8;
border-radius: 0.2rem;
}
... ... @@ -271,27 +271,27 @@
font-size: 28px;
}
.clear-icon{
.clear-icon {
float: right;
color: #b8b8b8;
border: none;
background: white;
}
span{
span {
margin-right: 10px;
font-size: 14px;
}
.history-search{
border-bottom:1px solid #f3f3f3;
.history-search {
border-bottom: 1px solid #f3f3f3;
}
.hot-search{
.hot-search {
margin-top: 20px;
}
.clearfix{
.clearfix {
margin-left: 30px;
}
... ...