Authored by yyq

Merge branch 'feature/sale' of git.yoho.cn:fe/yohobuy-node into feature/sale

... ... @@ -2,12 +2,56 @@
* @Author: Targaryen
* @Date: 2016-05-21 10:59:20
* @Last Modified by: Targaryen
* @Last Modified time: 2016-05-21 13:22:46
* @Last Modified time: 2016-06-02 15:17:03
*/
'use strict';
const headerModel = require('../../../doraemon/models/header');
const mRoot = '../models';
// list 页 model
const list = require(`${mRoot}/list`);
exports.getProductPic = (req, res) => {
res.jsonp();
};
/**
* 商品列表页
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.index = (req, res) => {
let params = Object.assign({
saleType: 2,
order: 's_t_asc,s_s_asc'
}, req.query);
let channel = req.query.channel || req.cookies._Channel || 'boys';
params.uid = req.user.uid || 0;
let responseData = {};
headerModel.requestHeaderData().then(headerData => {
responseData = headerModel.setHeaderData(headerData.data, 'vip');
responseData.module = 'product';
responseData.page = 'sale';
// responseData.footerTop = true;
responseData.devEnv = true;
list.getSaleOthersData(params, channel).then((result) => {
responseData.saleList = result;
responseData.resultShow = JSON.stringify(result, null, 4);
res.render('sale/other', responseData);
});
}).catch(() => {
res.render('error', { devEnv: true, pageErr: true });
});
};
... ...
/*
* @Author: Targaryen
* @Date: 2016-06-02 15:11:15
* @Last Modified by: Targaryen
* @Last Modified time: 2016-06-02 15:22:08
*/
'use strict';
const library = '../../../library';
const utils = '../../../utils';
const API = require(`${library}/api`).API;
const api = new API();
const saleApi = require('./sale-api');
const saleHandler = require('./sale-handler');
const productProcess = require(`${utils}/product-process`);
const _ = require('lodash');
/**
* 获取 VIP 会员专享和新降价专区数据 Controller 调用
* @return {[type]} [description]
*/
exports.getSaleOthersData = (params) => {
let promiseObject = [
saleApi.getSaleGoodsList(params),
saleApi.getLeftContentList()
];
return api.all(promiseObject).then(result => {
let finalResult = {};
// 获取商品数据和顶部筛选条件
if (result[0].code === 200) {
finalResult.goods = productProcess.processProductList(result[0].data.product_list);
if (!_.isEmpty(result[0].data.filter)) {
finalResult.filters = saleHandler.handleSaleFilterData(result[0].data.filter, params);
}
// 处理排序数据
finalResult.opts = saleHandler.handleSaleOptsData(params, result[0].data.total);
finalResult.totalCount = result[0].data.total;
finalResult.pager = saleHandler.handleSalePagerData(result[0].data.total, params);
}
// 获取左侧类目数据
if (result[1].code === 200) {
if (params.gender === '2,3') {
finalResult.leftContent = saleHandler.handleSaleSortData(result[1].data.girl, params);
} else {
finalResult.leftContent = saleHandler.handleSaleSortData(result[1].data.boy, params);
}
}
return finalResult;
});
};
... ...
... ... @@ -197,6 +197,13 @@ exports.handleOutletsBannersData = (origin) => {
dest.column = value.data;
}
// 处理右侧一张图片
if (value.template_name === 'single_image') {
dest.limitedBuy.extra.sourceImg = {};
dest.limitedBuy.extra.sourceImg.href = value.data.url;
dest.limitedBuy.extra.sourceImg.img = value.data.src;
}
// 处理热销推荐数据
if (value.template_name === 'recommendCategory') {
dest.limitedBuy.extra.hotType = {};
... ... @@ -308,6 +315,9 @@ exports.handleOutletstrendGoodData = (origin) => {
dest.title = '潮品推荐';
dest.goods = productProcess.processProductList(origin.product_list);
_.forEach(dest.goods, (value, key) => {
dest.goods[key].discount = (value.sales_price / value.market_price).toFixed(2) * 10;
});
return dest;
};
... ...
... ... @@ -2,7 +2,7 @@
* @Author: Targaryen
* @Date: 2016-05-30 16:20:03
* @Last Modified by: Targaryen
* @Last Modified time: 2016-06-02 13:53:24
* @Last Modified time: 2016-06-02 14:26:27
*/
'use strict';
... ... @@ -34,7 +34,8 @@ exports.getOutletsIndexData = (params) => {
outletsApi.getChannelResouceData({ content_code: channelCode.index }),
outletsApi.getOutletsActivityOrigin(params), // 获取限时活动列表
outletsApi.getOutletsActivityOrigin(params), // 获取即将结束列表
outletsApi.getOutletsTrendData(params)
outletsApi.getOutletsTrendData(params), // 获取潮流速递商品数据
saleApi.getSaleGoodsList(params) // 获取底部商品数据
]).then(result => {
let finalResult = {};
... ... @@ -60,6 +61,11 @@ exports.getOutletsIndexData = (params) => {
finalResult.limitedBuy.extra.trendGood = outletsProcess.handleOutletstrendGoodData(result[3].data);
}
// 处理底部商品数据
if (result[4].code === 200) {
finalResult.goodsBoard.list = productProcess.processProductList(result[4].data.product_list);
}
return finalResult;
});
};
... ...
... ... @@ -18,6 +18,9 @@ const sale = require(`${cRoot}/sale`);
// 奥特莱斯controller
const outlets = require(`${cRoot}/outlets`);
// 商品促销controller
const list = require(`${cRoot}/list`);
// 商品促销routers
router.get('/sale', sale.index); // sale 首页
router.get('/sale/discount/detail', sale.discount); // 折扣专场详情页
... ... @@ -31,4 +34,7 @@ router.get('/outlets/index', outlets.index);
router.get('/outlets/special/detail', outlets.special);
router.get('/outlets/:channel', outlets.channel);
// 商品列表页
router.get('/list', list.index); // 商品列表页
module.exports = router;
... ...
... ... @@ -16,7 +16,7 @@ $('.slide-container').slider();
// 请求带导航的列表数据
function getNaviData(items) {
var location, url, goodItems;
var location, url, goodItems, navTitle;
navTitle = items.attr('urlLocation');
... ...