Authored by 郭成尧

折扣专场

... ... @@ -12,26 +12,65 @@ const mRoot = '../models';
// sale 页 model
const sale = require(`${mRoot}/sale`);
const saleDiscount = require(`${mRoot}/sale-discount`);
/**
* sale 首页
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.index = (req, res) => {
headerModel.requestHeaderData()
.then(response => {
response = headerModel.setHeaderData(response.data, 'boys');
response = headerModel.setHeaderData(response.data, 'sale');
response.module = 'product';
response.page = 'sale';
response.footerTop = true;
response.devEnv = true;
res.render('sale/index', Object.assign(response, sale.outputDevData()));
// 假数据输出
// res.render('sale/index', Object.assign(response, sale.outputDevData()));
/* return sale.getSaleDate().then(result => {
// 真实数据输出
return sale.getSaleDate().then(result => {
response.result = result;
response.resultShow = JSON.stringify(result, null, 4);
res.render('sale/index', response);
});*/
});
})
.catch(() => {
res.render('error', { devEnv: true, pageErr: true });
});
};
/**
* 折扣专场
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.discount = (req, res) => {
headerModel.requestHeaderData()
.then(response => {
response = headerModel.setHeaderData(response.data, 'sale-discount');
response.module = 'product';
response.page = 'sale';
response.footerTop = true;
response.devEnv = true;
return saleDiscount.getSaleDiscountData()
.then(result => {
response.result = result;
response.resultShow = JSON.stringify(result, null, 4);
res.render('sale/discount', response);
});
})
.catch(() => {
res.render('error', { devEnv: true, pageErr: true });
... ...
/*
* @Author: Targaryen
* @Date: 2016-05-19 16:10:11
* @Last Modified by: Targaryen
* @Last Modified time: 2016-05-19 16:16:55
*/
'use strict';
const library = '../../../library';
const API = require(`${library}/api`).API;
const sign = require(`${library}/sign`);
const api = new API();
/**
* 处理商品列表数据
* @param {[type]} origin [description]
* @return {[type]} [description]
*/
const handleSaleDiscountData = (origin) => {
var dest = {};
dest = origin;
return dest;
};
/**
* 获取商品列表数据
* @return {[type]} [description]
*/
exports.getSaleDiscountData = () => {
return api.get('', sign.apiSign({
method: 'app.search.sales',
limit: 20,
order: 's_t_desc',
page: 1,
productSize: '384x511',
yh_channel: 1
})).then(result => {
return handleSaleDiscountData(result);
});
};
... ...
... ... @@ -17,6 +17,7 @@ const sale = require(`${cRoot}/sale`);
// routers
// router.get('/detail/:id/:gid', detail.index);
router.get('/sale', sale.index);
router.get('/sale/index', sale.index);
router.get('/sale/discount', sale.discount);
module.exports = router;
... ...
<div>keep coding...</div>
\ No newline at end of file
... ...