Authored by yyq

Merge branch 'release/1.0' of git.yoho.cn:fe/yoho-blk into release/1.0

... ... @@ -11,6 +11,7 @@ const list = {
let q = req.query;
q.page = parseInt(q.page || 1, 10);
q.order = q.order || 's_n_desc';
let retData = {
module: 'product',
... ... @@ -55,6 +56,7 @@ const list = {
let q = req.query;
q.page = parseInt(q.page || 1, 10);
q.order = q.order || 's_n_desc';
let retData = {
module: 'product',
... ...
... ... @@ -16,8 +16,10 @@ const DataHelper = require('../models/helpers');
const Query = {
index: (req, res, next) => {
let q = req.query;
let query = q.query || '';
q.page = parseInt(q.page || 1, 10);
q.order = q.order || 's_n_desc';
let retData = {
module: 'product',
... ... @@ -32,11 +34,12 @@ const Query = {
let nav = [DataHelper.getChannelNav()];
nav.push({
name: `"${q.query}" ${data.total}个结果`
name: `"${query}" ${data.total}个结果`
});
if (data.filter) {
retData.filter = DataHelper.filterHandle(data.filter, q);
retData.filter.showPrice = data.total > 10;
}
retData.navPath = {
... ...
... ... @@ -92,6 +92,7 @@ const shop = {
let uid = cookie.getUid(req);
let q = req.query;
q.order = q.order || 's_n_desc';
q.page = parseInt(q.page || 1, 10);
ShopData.getShopHeadData(domain, uid).then(result => {
... ...
... ... @@ -43,13 +43,17 @@ const helpers = {
},
colorConvert(colors) {
return colors.map((c) => {
return {
id: c.colorId,
title: c.colorName,
rgb: c.colorValue ? `url(${c.colorValue})` : '#' + c.colorCode
};
});
if (colors) {
return colors.map((c) => {
return {
id: c.colorId,
title: c.colorName,
rgb: c.colorValue ? `url(${c.colorValue})` : '#' + c.colorCode
};
});
} else {
return [];
}
},
getChannelNav() {
... ... @@ -119,32 +123,43 @@ const helpers = {
let matchPrice = false;
priceRange = Object.keys(priceRange).map((k) => {
let prices = k.split(',');
let p = {
lower: prices[0],
higher: prices[1]
};
if (priceRange) {
priceRange = Object.keys(priceRange).map((k) => {
let prices = k.split(',');
let p = {
lower: prices[0],
higher: prices[1]
};
if (k === q.price) {
p.checked = true;
matchPrice = true;
filters.push(this.newFilter('price', q.price, ${prices[0]}-¥${prices[1]}`));
}
return p;
}).sort((a, b) => {
return a.lower - b.lower;
});
if (k === q.price) {
p.checked = true;
matchPrice = true;
}
return p;
}).sort((a, b) => {
return a.lower - b.lower;
});
if (!matchPrice && q.price) {
let prices = q.price.split(',');
let priceTxt = ${prices[0]}-¥${prices[1]}`;
customPriceLow = prices[0];
customPriceHigh = prices[1];
if (!matchPrice && q.price) {
let prices = q.price.split(',');
if (prices[1] === Number.MAX_SAFE_INTEGER.toString()) {
priceTxt = `大于¥${prices[0]}`;
customPriceHigh = '';
}
filters.push(this.newFilter('price', q.price, ${prices[0]}-¥${prices[1]}`));
customPriceLow = prices[0];
customPriceHigh = prices[1];
filters.push(this.newFilter('price', q.price, priceTxt));
}
}
if (!_.isArray(sizeInfo)) {
if (!_.isArray(sizeInfo) && sizeInfo) {
sizeInfo.checked = true;
sizeInfo = [sizeInfo];
}
... ... @@ -197,6 +212,7 @@ const helpers = {
customPriceLow: customPriceLow,
customPriceHigh: customPriceHigh,
showSize: !!q.sort,
showPrice: true,
nav: this.getSortNav(q.sort, sorts)
};
},
... ...
... ... @@ -3,12 +3,22 @@
const api = global.yoho.API;
const _ = require('lodash');
function clearEmptyVal(obj) {
function _paramHanlde(obj) {
_.keys(obj).forEach(k => {
if (obj[k] === null || obj[k] === '') {
_.unset(obj, k);
}
});
if (obj.price) {
let prices = obj.price.split(',');
if (!prices[1]) {
prices[1] = Number.MAX_SAFE_INTEGER;
obj.price = prices.join(',');
}
}
return obj;
}
... ... @@ -20,7 +30,7 @@ const Search = {
limit: 45
};
Object.assign(finalParams, clearEmptyVal(params));
Object.assign(finalParams, _paramHanlde(params));
return api.get('', finalParams);
},
... ... @@ -30,7 +40,7 @@ const Search = {
limit: 45
};
Object.assign(finalParams, clearEmptyVal(params));
Object.assign(finalParams, _paramHanlde(params));
return api.get('', finalParams);
},
... ... @@ -40,7 +50,7 @@ const Search = {
limit: 45
};
Object.assign(finalParams, clearEmptyVal(params));
Object.assign(finalParams, _paramHanlde(params));
return api.get('', finalParams);
},
... ...
... ... @@ -122,8 +122,6 @@ const ShopService = {
let brandId = domainInfo.id;
let brandInfo = yield BrandService.getBrandInfo(brandId, uid);
console.log(brandInfo);
info.name = brandInfo.brandName;
info.info = brandInfo.brandIntro;
info.btnName = '品牌介绍';
... ...
... ... @@ -71,6 +71,7 @@
</div>
{{/if}}
{{#if showPrice}}
<div class="yoho-ui-accordion">
<h3>价格</h3>
<div class="body price-body">
... ... @@ -94,6 +95,7 @@
</div>
</div>
</div>
{{/if}}
{{#if showSize}}
<div class="yoho-ui-accordion">
... ...
<div class="goods-area clearfix">
{{#each products}}
<div class="goods" data-id="{{productId}}" data-url="{{url}}">
<div class="goods-img">
<img class="lazy" data-original="{{image defaultImages 263 344}}" width="263" height="344" alt="">
<div class="goods" data-id="{{productId}}" data-url="{{url}}">
<div class="goods-img">
<a href="{{url}}">
<img class="lazy" data-original="{{image defaultImages 263 344}}" width="263" height="344" alt="">
</a>
</div>
<div class="goods-brand">
<a href="/product/shop/{{brandDomain}}" target="_blank">{{brandName}}</a>
</div>
<div class="goods-name">
<a href="{{url}}">{{productName}}</a>
</div>
<div class="goods-price">
<span>¥{{round salesPrice}}</span>
{{#if marketPrice}}
<b>¥{{round marketPrice}}</b>
{{/if}}
</div>
<div class="goods-list hide">
{{#each goodsList}}
<i data-url="{{url}}">{{image imagesUrl 256 343}}</i>
{{/each}}
</div>
</div>
<div class="goods-brand">
{{brandName}}
</div>
<div class="goods-name">
{{productName}}
</div>
<div class="goods-price">
<span>¥{{round salesPrice}}</span>
{{#if marketPrice}}
<b>¥{{round marketPrice}}</b>
{{/if}}
</div>
<div class="goods-list hide">
{{#each goodsList}}
<i data-url="{{url}}">{{image imagesUrl 265 344}}</i>
{{/each}}
</div>
</div>
{{/each}}
<div class="goods-wrapper">
<div class="goods">
... ...
<div class="order-area">
<div class="order {{#if order}}{{^}}selected{{/if}}" data-order="">综合</div>
<div class="order {{#isEqual order 's_n_desc'}}selected{{/isEqual}}" data-order="s_n_desc">综合</div>
<div class="order {{#isEqual order 's_t_desc'}}selected{{/isEqual}}" data-order="s_t_desc">上新时间</div>
<div class="order order-price {{#isEqual order 's_p_asc'}}selected{{/isEqual}}{{#isEqual order 's_p_desc'}}selected{{/isEqual}}" data-order="s_p_asc,s_p_desc" data-target="price-dest">价格</div>
<div class="dest price-dest">
... ...
... ... @@ -26,9 +26,9 @@ module.exports = {
useOneapm: false,
useCache: false,
memcache: {
master: ['192.168.102.168:11211'],
slave: ['192.168.102.168:11211'],
session: ['192.168.102.168:11211'],
master: ['127.0.0.1:11211'],
slave: ['127.0.0.1:11211'],
session: ['127.0.0.1:11211'],
timeout: 1000,
retries: 0
},
... ...
... ... @@ -112,9 +112,13 @@ var YohoListPage = {
}
});
$('.price-input input', this.rootDoc).keyup(function() {
$(this)[0].value = $(this)[0].value.replace(/\D+/g, '');
});
$('.price-btns .confirm', this.rootDoc).click(function() {
var priceLow = $('.price-low', $(this).parent()).val() || 0;
var priceHigh = $('.price-high', $(this).parent()).val() || 0;
var priceHigh = $('.price-high', $(this).parent()).val() || '';
if (priceLow > 0 || priceHigh > 0) {
YohoListPage.go({
... ... @@ -139,7 +143,7 @@ var YohoListPage = {
YohoListPage.openWin(url);
});
$('.goods-wrapper > .goods').click(function() {
$('.goods-wrapper > .goods > img').click(function() {
var url = $(this).data('url');
YohoListPage.openWin(url);
... ...