Authored by htoooth

Merge remote-tracking branch 'origin/release/1.0' into release/1.0

... ... @@ -30,7 +30,7 @@ const product = (req, res, next) => {
code: 403,
message: '请登录后执行该操作',
data: {
refer: helpers.urlFormat('/signin')
refer: helpers.urlFormat('/passport/login')
}
});
}
... ... @@ -59,7 +59,7 @@ const brand = (req, res, next) => {
code: 403,
message: '请登录后执行该操作',
data: {
refer: helpers.urlFormat('/signin')
refer: helpers.urlFormat('/passport/login')
}
});
}
... ... @@ -88,7 +88,7 @@ const shop = (req, res, next) => {
code: 403,
message: '请登录后执行该操作',
data: {
refer: helpers.urlFormat('/signin')
refer: helpers.urlFormat('/passport/login')
}
});
}
... ...
... ... @@ -9,238 +9,6 @@ const _ = require('lodash');
const Item = require('../models/item');
const index = (req, res, next) => {
// let data = {
// brandBanner: {
// bgColor: '#93897d',
// brandLogo: {
// link: '#',
// img: 'http://placehold.it/{width}x{height}'
// },
// brandHome: {
// link: '#'
// }
// },
// nav: [
// {
// link: '#',
// name: 'MEN首页'
// },
// {
// link: '#',
// name: '上衣'
// },
// {
// link: '#',
// name: '卫衣'
// },
// {
// name: 'Spring 2016NEWT-Shirt 2016迷彩蝴蝶夹克'
// }
// ],
// goodInfo: {
// name: 'Spring 2016NEWT-Shirt 2016迷彩蝴蝶夹克',
// brandName: 'Supreme',
// intro: '2016最新发布',
// img: 'http://placehold.it/{width}x{height}',
// sellPrice: 3199,
// marketPrice: 4009,
// colors: [
// {
// name: '黑色',
// title: '黑色',
// focus: true,
// thumbs: [
// 'http://placehold.it/{width}x{height}',
// 'http://placehold.it/{width}x{height}',
// 'http://placehold.it/{width}x{height}',
// 'http://placehold.it/{width}x{height}',
// 'http://placehold.it/{width}x{height}'
// ],
// sizes: [
// {
// name: 'S',
// title: 'S',
// sku: '12313',
// num: 10
// },
// {
// name: 'M',
// title: 'M',
// sku: '12314',
// num: 14
// },
// {
// name: 'L',
// title: 'L',
// sku: '12315',
// num: 0
// },
// {
// name: 'XL',
// title: 'XL',
// sku: '12316',
// num: 0
// }
// ],
// rgb: '#000'
// },
// {
// name: '黄色',
// title: '黄色',
// thumbs: [
// 'http://placehold.it/{width}x{height}',
// 'http://placehold.it/{width}x{height}'
// ],
// rgb: '#efdc0e',
// sizes: [
// {
// name: 'S',
// title: 'S',
// sku: '12313',
// num: 0
// },
// {
// name: 'M',
// title: 'M',
// sku: '12314',
// num: 14
// },
// {
// name: 'L',
// title: 'L',
// sku: '12315',
// num: 0
// },
// {
// name: 'XL',
// title: 'XL',
// sku: '12316',
// num: 23
// }
// ]
// },
// {
// name: '蓝色',
// title: '蓝色',
// thumbs: [
// 'http://placehold.it/{width}x{height}',
// 'http://placehold.it/{width}x{height}',
// 'http://placehold.it/{width}x{height}',
// 'http://placehold.it/{width}x{height}'
// ],
// rgb: '#2ea8e6'
// },
// {
// name: '绿色',
// title: '绿色',
// thumbs: [
// 'http://placehold.it/{width}x{height}',
// 'http://placehold.it/{width}x{height}',
// 'http://placehold.it/{width}x{height}',
// 'http://placehold.it/{width}x{height}'
// ],
// rgb: '#85b2ef'
// }
// ]
// },
// description: {
// titleEn: 'DESCRIPTION',
// titleCn: '商品信息',
// basic: [
// {
// key: '编号',
// value: '51144694'
// },
// {
// key: '颜色',
// value: '灰色'
// },
// {
// key: '性别',
// value: '男款'
// },
// {
// key: '经典款型',
// value: '灰色'
// }
// ]
// },
// material: {
// titleEn: 'MATERIALS',
// titleCn: '材料洗涤',
// detail: [
// {
// img: 'http://placehold.it/{width}x{height}',
// name: '皮革',
// nameEn: 'Leather',
// text: '不适宜沾水,避免硬物划花,使用专用清洁膏擦拭。长时间不着用,可用软毛巾抹掉表面尘土,上一层皮革保养油。建议几双鞋交替穿着,不穿时放置通风处保持鞋内干爽。'
// }
// ],
// wash: [
// {
// img: 'http://placehold.it/{width}x{height}',
// name: '分色洗涤'
// }
// ]
// },
// sizeInfo: {
// titleEn: 'SIZEINFO',
// titleCn: '尺码信息',
// param: {
// thead: [
// {
// width: 126,
// name: '吊牌尺码'
// },
// {
// width: 126,
// name: '后衣长'
// },
// {
// width: 126,
// name: '前衣长'
// }
// ],
// tbody: [
// ['XS', 66, 66],
// ['S', 66, 66],
// ['L', 66, 66]
// ]
// },
// taste: {
// thead: [
// {
// width: 170,
// name: '模特'
// },
// {
// width: 126,
// name: '身高'
// },
// {
// width: 126,
// name: '体重'
// }
// ],
// tbody: [
// [{
// img: 'http://placehold.it/{width}x{height}',
// name: 'Steven'
// }, 187, 66],
// [{
// img: 'http://placehold.it/{width}x{height}',
// name: 'Oliver'
// }, 183, 66]
// ]
// }
// },
// details: {
// titleEn: 'DETAILS',
// titleCn: '商品详情',
// content: 'aaaa'
// }
// };
Item.getProductItemData(req.params, req.url, req.user.uid).then(result => {
if (_.isEmpty(result)) {
return next();
... ...
... ... @@ -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)
};
},
... ...
... ... @@ -140,7 +140,10 @@ const setPathNav = (data, name) => {
let resData = {};
if (!_.isEmpty(data)) {
let navs = [];
let navs = [{
link: helpers.urlFormat(''),
name: 'MEN首页' // 待处理
}];
let sort = data.sort[0];
navs.push({
... ... @@ -185,6 +188,7 @@ const setPathNav = (data, name) => {
*/
const setBrandBanner = brand => {
let data = {
brandId: brand.id,
bgColor: '#000',
brandLogo: {
link: `/product/shop/${brand.brandDomain}`, // 品牌跳转链接 -- 待处理
... ...
... ... @@ -7,6 +7,7 @@
const _ = require('lodash');
const itemAPI = require('./item-api');
const brandAPI = require('./brand-api');
const itemFUN = require('./item-handler');
const search = require('./search-api');
... ... @@ -14,8 +15,7 @@ const search = require('./search-api');
const _getMultiResourceByBaseInfo = (base) => {
let productId = base.id;
let skn = base.erpProductId;
// let brandId = base.brand.id ? base.brand.id : 0;
let brandId = base.brand.id ? base.brand.id : 0;
// 获取相关数据
let promiseData = [
... ... @@ -27,6 +27,7 @@ const _getMultiResourceByBaseInfo = (base) => {
if (base.uid) {
promiseData.push(itemAPI.getUserIsFav(base.uid, productId));
promiseData.push(brandAPI.getBrandInfo(brandId, base.uid));
}
return Promise.all(promiseData).then(result => {
... ... @@ -35,7 +36,8 @@ const _getMultiResourceByBaseInfo = (base) => {
comfort: result[1].data,
modelTry: result[2].data,
sort: result[3].data,
productFav: (result[4] && result[4].data)
productFav: (result[4] && result[4].data),
brandFav: (result[5] && result[5].data && result[5].data.is_favorite === 'Y')
};
});
};
... ... @@ -68,12 +70,14 @@ let getProductItemData = (params, url, uid) => {
}
return _getMultiResourceByBaseInfo(result).then(mulRes => {
// 面包屑导航
Object.assign(data, itemFUN.setPathNav(mulRes.sort, result.productName));
// 收藏状态
_.set(data, 'brandBanner.brandFav', mulRes.brandFav);
_.set(data, 'goodInfo.productFav', mulRes.productFav);
// 面包屑导航
Object.assign(data, itemFUN.setPathNav(mulRes.sort, result.productName));
// DESCRIPTION商品描述
Object.assign(data, itemFUN.setDescriptionData(mulRes.sizeInfo, mulRes.comfort));
... ...
... ... @@ -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 = '品牌介绍';
... ...
... ... @@ -23,7 +23,7 @@
</a>
{{/ brandIntro}}
<span id="brand-fav" class="brand-fav{{#if coled}} coled{{/if}}">
<span id="brand-fav" class="brand-fav{{#if brandFav}} cur{{/if}}" data-id={{brandId}}>
<i class="iconfont">&#xe627;</i>
</span>
</p>
... ...
... ... @@ -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
},
... ...
... ... @@ -12,7 +12,9 @@
</li>
{{/ navbars}}
</ul>
<div class="main-logo"></div>
<div class="main-logo">
<a href="{{../siteUrl}}"></a>
</div>
</div>
</div>
<div class="sub-nav">
... ...
... ... @@ -256,6 +256,33 @@ $('#keep-shopping').click(function() {
$tradeWrapper.slideDown(SLIDETIME);
});
$('#brand-fav').click(function() {
var $this = $(this),
info = $this.data(),
param = {};
if (!info.id) {
return;
}
param.brandId = info.id;
if ($this.hasClass('coll')) {
param.type = 'cancel';
}
$.ajax({
type: 'POST',
url: '/product/brand/togglecollect',
data: param
}).then(function(data) {
if (data.code === 200) {
$this.toggleClass('coll');
} else if (data.code === 403) {
location.href = data.data.refer;
}
});
});
// 商品收藏
$('#collect-product').click(function() {
var $this = $(this),
... ...
... ... @@ -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);
... ...
... ... @@ -194,6 +194,12 @@
margin-left: -132px;
margin-top: 20px;
background: resolve('layout/blk-logo.png') no-repeat center center;
a {
display: block;
width: 100%;
height: 100%;
}
}
}
... ...
... ... @@ -36,6 +36,10 @@
cursor: pointer;
}
.coll {
color: #1d1d1d;
}
.iconfont {
font-size: 12px;
}
... ...