Authored by biao

Merge branch 'feature/news' into feature/index

... ... @@ -20,3 +20,14 @@ exports.getbrandFloorDataAjax = (req, res) => {
res.json(data);
});
};
exports.getNewArrival = (req, res) => {
channelModel.getNewArrival().then(data => {
let result = {
code: 200,
goods: data
};
res.send(result);
});
};
... ...
... ... @@ -8,11 +8,13 @@
const _ = require('lodash');
const ServiceAPI = require(`${global.library}/api`).ServiceAPI;
const SearchAPI = require(`${global.library}/api`).SearchAPI;
const sign = require(`${global.library}/sign`);
const helpers = require(`${global.library}/helpers`);
const serviceApi = new ServiceAPI();
const searchApi = new SearchAPI();
const headerModel = require('../../../doraemon/models/header');
... ... @@ -40,6 +42,106 @@ const channelMap = {
}
};
// 构建url
const httpBuildQuery = data => {
return searchApi.get('/search.json', data);
};
/**
* 格式化商品信息
*
* @param array $productData 需要格式化的商品数据
* @param bool $showTags 控制是否显示标签
* @param bool $showNew 控制是否显示NEW图标
* @param bool $showSale 控制是否显示SALE图标
* @param int $width 图片的宽度
* @param int $height 图片的高度
* @param bool $isApp 判断是不是APP访问
* @param bool $showPoint 商品价格是否显示小数位,默认显示
* @return array | false
*/
const formatProduct = (productData, showTags, showNew, showSale, width, height, isApp, showPoint) => {
let result = {};
// 默认值
if (!showTags) {
showTags = true;
}
if (!showNew) {
showNew = true;
}
if (!showSale) {
showSale = true;
}
if (!width) {
width = 290;
}
if (!height) {
height = 388;
}
if (!isApp) {
isApp = false;
}
if (!showPoint) {
showPoint = true;
}
// 商品信息有问题,则不显示
if (!productData.product_skn || !productData.goods_list[0]) {
return false;
}
// 市场价和售价一样,则不显示市场价
if (parseInt(productData.market_price, 0) === parseInt(productData.sales_price, 0)) {
productData.market_price = false;
}
result.id = productData.product_skn;
result.product_id = productData.product_id;
result.thumb = 'http://img10.static.yhbimg.com/goodsimg/2016/05/23/06/0145382aaf7f6b2bcb9f73bcc26fc14228.jpg?imageView/2/w/280/h/373';
result.name = productData.product_name;
result.price = !productData.market_price ? false : productData.market_price;
result.salePrice = productData.sales_price;
if (showPoint) {
result.price += '.00';
result.salePrice += '.00';
}
result.is_soon_sold_out = (productData.is_soon_sold_out === 'Y');
result.url = 'http://item.yohobuy.com/product/pro_' +
productData.product_id + '_' +
productData.goods_list[0].goods_id + '/' +
productData.cn_alphabet + '.html';
// APP访问需要加附加的参数
// 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护
if (isApp) {
result.url += '?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":' +
productData.product_skn + '}}';
}
if (showTags) {
result.tags = {};
result.tags.is_new = showNew && productData.is_new && productData.is_new === 'Y'; // 新品
result.tags.is_discount = showSale && productData.is_discount && productData.is_discount === 'Y'; // 在售
result.tags.is_limited = productData.is_limited && productData.is_limited === 'Y'; // 限量
result.tags.is_yohood = productData.is_yohood && productData.is_yohood === 'Y'; // YOHOOD
result.tags.midYear = productData['mid-year'] && productData['mid-year'] === 'Y'; // 年中
result.tags.yearEnd = productData['year-end'] && productData['year-end'] === 'Y'; // 年末
result.tags.is_advance = productData.is_advance && productData.is_advance === 'Y'; // 再到着
if (result.is_soon_sold_out && result.tags.is_discount) {
result.tags.is_new = false;// 打折与即将售完组合显示打折
} else if (result.tags.is_discount &&
(result.tags.is_new || result.tags.is_limited || result.tags.is_yohood || result.tags.is_advance)) {
result.tags.is_discount = false;// 打折与其它组合则隐藏打折
} else if (result.tags.is_yohood && result.tags.is_new) {
result.tags.is_new = false;// YOHOOD和新品组合显示YOHOOD
}
}
return result;
};
const getBannerList = data => {
let list = [];
... ... @@ -287,7 +389,103 @@ const getSingleHotFloorData = args => {
return floorDatas;
};
/**
* 组装最新上架楼层数据
*
* @param string data
* return obj
*/
const getNewGoodsFloorData = args => {
const data = {
newArrivls: {
name: '最新上架',
navs: {
name: '',
href: ''
}
}
};
data.newArrivls.navs.name = args[0].data[0].name;
data.newArrivls.navs.href = args[0].data[0].url;
return data;
};
/**
* 获取最新上架商品数据
*
* @param string $channel
* @return array
*/
exports.getNewArrival = channel => {
const sortList = [
{sort: 147, viewNum: 5}, // 休闲运动鞋
{sort: 129, viewNum: 5}, // 休闲裤
{sort: 152, viewNum: 5}, // 双肩包
{misort: 11, viewNum: 5}, // T恤
{sort: 115, viewNum: 5}, // 衬衫
{sort: 130, viewNum: 5}, // 牛仔裤
{misort: 60, viewNum: 5}, // 帽子
{sort: 124, viewNum: 5}, // 夹克
{sort: 119, viewNum: 5}, // 卫衣
{sort: 162, viewNum: 5}, // 手表
{sort: 148, viewNum: 5}, // 靴子
{misort: 65, viewNum: 5}, // 首饰
{sort: 151, viewNum: 5}, // 时装鞋
{misort: 61, viewNum: 5}, // 太阳镜
{misort: 39, viewNum: 5}, // 袜子
{sort: 346, viewNum: 5}, // 运动裤
{sort: 131, viewNum: 5}, // 短裤
{misort: 66, viewNum: 5}, // 配饰
{misort: 309, viewNum: 5}, // 内裤
{misort: 30, viewNum: 5}, // 打底裤/紧身裤
{sort: 342, viewNum: 5} // 邮差包
];
// 一级缓存
let rel = [];
// 接口
let params = {
// 'shelve_time' : new Date().getTime()+','+d.getTime(),
order: 'shelve_time:desc',
status: 1,
sales: 'Y',
attribute_not: 2,
stocknumber: 3
};
// 最新上架参数(男首频道:gender=1,3 女首频道gender=2,4)
if (channel === 'boys') {
params.gender = '1,3';
} else {
params.gender = '2,4';
}
_.forEach(sortList, (item) => {
let data = Object.assign(item, params);
rel.push(httpBuildQuery(data));
});
return Promise.all(rel).then(res => {
let data = [],
result = [];
_.forEach(sortList, (it, index) => {
if (res[index].data.product_list.length === sortList[index].viewNum) {
data = data.concat(res[index].data.product_list);
}
});
_.forEach(data, (item) => {
result.push(formatProduct(item, true, true, true, 280, 373));
});
return result;
});
};
const requestContent = type => {
... ... @@ -310,6 +508,7 @@ const floorMap = {
最新速报: getNewReportFloorData,
人气单品: getSingleHotFloorData,
优选品牌: getPreBrandTopData,
最新上架: getNewGoodsFloorData,
ad: getadbannerData
};
... ...
... ... @@ -12,8 +12,11 @@ const cRoot = './controllers';
// Your controller here
const channelController = require(`${cRoot}/index`);
// 路由
router.get('/boys', channelController.boysIndex);
// ajax
router.get('/getbrandFloorDataAjax', channelController.getbrandFloorDataAjax);
router.post('/common/getNewArrival', channelController.getNewArrival);
module.exports = router;
... ...
... ... @@ -14,10 +14,11 @@ module.exports = {
siteUrl: 'http://localhost:6002/',
domains: {
api: 'http://192.168.102.205:8080/gateway/',
service: 'http://testservice.yoho.cn:28077/',
// service: 'http://testservice.yoho.cn:28077/', // 'http://service.api.yohobuy.com/',
search: 'http://192.168.10.64:8080/yohosearch/'
// service: 'http://testservice.yoho.cn:28077/',
service: 'http://service.api.yohobuy.com/',
search: 'http://192.168.102.216:8080/yohosearch/'
},
useOneapm: false,
useCache: false,
... ...
... ... @@ -19,14 +19,12 @@ require('../plugins/logo-brand');
require('../plugins/accordion');
$(document).on('mouseenter', '.imgopacity a img', function() {
$(this).css('opacity', 0.8);
$(this).css('opacity', 0.8); // eslint-disable-line
});
$(document).on('mouseout', '.imgopacity a img', function() {
$(this).css('opacity', 1);
$(this).css('opacity', 1); // eslint-disable-line
});
if ($.inArray(homePage, ['boys', 'girls', 'kids', 'lifestyle']) > -1) {
require('../plugins/new-arrivls')({
type: homePage,
... ...
... ... @@ -229,6 +229,7 @@ a {
@import "footer";
@import "404";
@import "index/index";
@import "product/index";
/* 模块 */
@import "index/index";
... ...
.good-info {
margin-bottom: 35px;
width: 222px;
margin-right: 10px;
float: left;
.good-detail-img {
width: 100%;
height: 300px;
position: relative;
.good-thumb, img.lazy {
display: block;
overflow: hidden;
width: 100%;
height: 100%;
}
.few-tag {
width: 100%;
position: absolute;
left: 0;
height: 16px;
line-height: 16px;
background: #ffac5b;
color: #fff;
font-size: 12px;
text-align: center;
bottom: 0;
}
}
.good-detail-text {
color: #222;
font-size: 12px;
text-align: left;
overflow: hidden;
> a {
margin-top: 16px;
line-height: 1.5;
display: block;
@mixin ellipsis;
}
> .price {
margin-top: 5px;
}
.brand {
a {
color: #666;
line-height: 1.5;
}
}
.market-price {
text-decoration: line-through;
color: #999;
}
}
.col-btn {
position: absolute;
top: 15px;
right: 15px;
color: #ccc;
font-size: 12px;
&.coled {
color: #f95b4f;
}
}
.tag-container {
font-size: 12px;
height: 22px;
line-height: 22px;
.good-tag {
float: left;
box-sizing: border-box;
display: block;
height: 22px;
padding: 0 7px;
margin-right: 3px;
color: #fff;
&:nth-last-of-type(1) {
margin-right: 0;
}
}
.new-tag {
background: #78dc7d;
}
.renew-tag {
background: #78dc7e;
}
.running-man-tag {
background-color: #017df9;
color: #f7ed02;
}
.yep-tag, .ymp-tag, .sale-tag {
background: #ff565b;
}
.limit-tag {
color: #4e4e4e;
border: 1px solid #4e4e4e;
}
}
}
@keyframes slideRight {
from {
max-width: 0;
}
to {
max-width: 150px;
}
}
.good-item-wrapper {
border: 1px solid #dddddd;
padding-left: 20px;
padding-top: 18px;
padding-right: 20px;
position: absolute;
background: #fff;
display: none;
.good-info-main{
float: left;
}
.col-btn {
display: block;
&:hover {
cursor: pointer;
}
}
.good-select-color {
float: left;
margin-top: 22px;
overflow: hidden;
animation: slideRight 600ms 1;
ul {
display: block;
float: left;
margin-left: 15px;
}
li {
width: 50px;
margin-bottom: 15px;
a, img {
display: block;
overflow: hidden;
width: 100%;
}
}
}
.good-info {
margin-right: 10px;
}
}
.block-next-page {
width: 222px;
height: 297px;
padding-top: 22px;
margin-bottom: 35px;
margin-right: 10px;
float: left;
cursor: pointer;
a {
display: block;
img {
width: 100%;
height: 100%;
display: block;
overflow: hidden;
}
}
}
... ...
@import "good";
.product-page {
/*分页*/
.product-pager {
padding: 20px 0;
font-size: 12px;
color: #6a6a6a;
border-top: 2px solid #eaeceb;
.pager {
float: right;
}
}
/*分页 END*/
.list-left {
width: 160px;
}
.list-right {
width: 970px;
}
}
.product-list-page, .new-sale-page {
.goods-container {
height: auto;
padding-top: 25px;
position: relative;
width: calc(970px + 10px);/*每列增加右边距*/
.good-info {
width: 235px;
.good-detail-img {
height: 315px;
}
}
.block-next-page {
width: 235px;
height: 315px;
}
}
.filter-box .brand .attr-content {
max-width: 730px;
}
}
/*990px*/
.min-screen .product-list-page,
.min-screen .new-sale-page {
.list-right {
width: 810px;
}
.goods-container {
height: auto;
padding-top: 25px;
position: relative;
width: calc(810px + 10px);/*每列增加右边距*/
.good-info {
width: 195px;
.good-detail-img {
height: 261px;
}
}
.block-next-page {
width: 195px;
height: 261px;
}
}
.filter-box .brand .attr-content {
max-width: 570px;
}
}
... ...