...
|
...
|
@@ -5,12 +5,10 @@ |
|
|
*/
|
|
|
|
|
|
'use strict';
|
|
|
const library = '../../../library';
|
|
|
const mRoot = '../models';
|
|
|
|
|
|
// const cookie = require(`${library}/cookie`);
|
|
|
const headerModel = require('../../../doraemon/models/header');
|
|
|
const log = require(`${library}/logger`);
|
|
|
const saleModel = require(`${mRoot}/sale`);
|
|
|
|
|
|
const queryParam = {
|
...
|
...
|
@@ -22,12 +20,6 @@ const queryParam = { |
|
|
pD: '0.1,0.9'
|
|
|
};
|
|
|
|
|
|
const saleLogger = (err, res) => {
|
|
|
log.error('sale页面渲染错误:' + JSON.stringify(err));
|
|
|
res.send('error');
|
|
|
};
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 公共数据处理
|
|
|
* @param {[object]} req
|
...
|
...
|
@@ -60,7 +52,7 @@ const processPublicData = (req, title, page) => { |
|
|
* @param {[object]} res
|
|
|
* @return {[type]}
|
|
|
*/
|
|
|
exports.index = (req, res) => {
|
|
|
exports.index = (req, res, next) => {
|
|
|
let params = processPublicData(req, 'SALE', 'sale');
|
|
|
|
|
|
saleModel.getSaleData(params.channel).then((result) => {
|
...
|
...
|
@@ -72,9 +64,7 @@ exports.index = (req, res) => { |
|
|
}
|
|
|
}
|
|
|
}));
|
|
|
}).catch((err) => {
|
|
|
saleLogger(err, res);
|
|
|
});
|
|
|
}).catch(next);
|
|
|
};
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -83,16 +73,14 @@ exports.index = (req, res) => { |
|
|
* @param {[object]} res
|
|
|
* @return {[type]}
|
|
|
*/
|
|
|
exports.breakingYards = (req, res) => {
|
|
|
exports.breakingYards = (req, res, next) => {
|
|
|
let params = processPublicData(req, '断码区', 'break-code');
|
|
|
|
|
|
saleModel.getBreakCodeData({
|
|
|
yhChannel: params.channel
|
|
|
}).then((result) => {
|
|
|
res.render('sale/break-code', Object.assign(params.renderData, result));
|
|
|
}).catch((err) => {
|
|
|
saleLogger(err, res);
|
|
|
});
|
|
|
}).catch(next);
|
|
|
};
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -101,14 +89,12 @@ exports.breakingYards = (req, res) => { |
|
|
* @param {[object]} res
|
|
|
* @return {[type]}
|
|
|
*/
|
|
|
exports.discount = (req, res) => {
|
|
|
exports.discount = (req, res, next) => {
|
|
|
let params = processPublicData(req, '折扣专场', 'discount');
|
|
|
|
|
|
saleModel.getDiscountData(params.channel).then((result) => {
|
|
|
res.render('sale/discount', Object.assign(params.renderData, result));
|
|
|
}).catch((err) => {
|
|
|
saleLogger(err, res);
|
|
|
});
|
|
|
}).catch(next);
|
|
|
};
|
|
|
|
|
|
|
...
|
...
|
@@ -118,16 +104,14 @@ exports.discount = (req, res) => { |
|
|
* @param {[object]} res
|
|
|
* @return {[type]}
|
|
|
*/
|
|
|
exports.discountDetail = (req, res) => {
|
|
|
exports.discountDetail = (req, res, next) => {
|
|
|
let id = req.query.id;
|
|
|
let params = processPublicData(req, '', 'discount-detail');
|
|
|
|
|
|
saleModel.getDiscountDetailData(id).then((result) => {
|
|
|
params.renderData.pageHeader.navTitle = result.title;
|
|
|
res.render('sale/discount-detail', Object.assign(params.renderData, result));
|
|
|
}).catch((err) => {
|
|
|
saleLogger(err, res);
|
|
|
});
|
|
|
}).catch(next);
|
|
|
};
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -136,16 +120,14 @@ exports.discountDetail = (req, res) => { |
|
|
* @param {[object]} res
|
|
|
* @return {[type]}
|
|
|
*/
|
|
|
exports.vip = (req, res) => {
|
|
|
exports.vip = (req, res, next) => {
|
|
|
let params = processPublicData(req, '会员专享', 'vip');
|
|
|
|
|
|
saleModel.getVipData(params.channel).then((result) => {
|
|
|
res.render('sale/vip', Object.assign(params.renderData, {
|
|
|
content: result
|
|
|
}));
|
|
|
}).catch((err) => {
|
|
|
saleLogger(err, res);
|
|
|
});
|
|
|
}).catch(next);
|
|
|
};
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -154,7 +136,7 @@ exports.vip = (req, res) => { |
|
|
* @param {[object]} res
|
|
|
* @return {[type]}
|
|
|
*/
|
|
|
exports.filter = (req, res) => {
|
|
|
exports.filter = (req, res, next) => {
|
|
|
let params = Object.assign({}, req.query);
|
|
|
|
|
|
saleModel.getFilterData(params).then((result) => {
|
...
|
...
|
@@ -163,7 +145,7 @@ exports.filter = (req, res) => { |
|
|
params: params,
|
|
|
filter: result
|
|
|
});
|
|
|
});
|
|
|
}).catch(next);
|
|
|
};
|
|
|
|
|
|
|
...
|
...
|
@@ -173,7 +155,7 @@ exports.filter = (req, res) => { |
|
|
* @param {[object]} res
|
|
|
* @return {[type]}
|
|
|
*/
|
|
|
exports.search = (req, res) => {
|
|
|
exports.search = (req, res, next) => {
|
|
|
let params = Object.assign({}, req.query);
|
|
|
|
|
|
// uid = 9239279
|
...
|
...
|
@@ -199,5 +181,5 @@ exports.search = (req, res) => { |
|
|
params: params,
|
|
|
goods: result[0]
|
|
|
}, vipObj));
|
|
|
});
|
|
|
}).catch(next);
|
|
|
}; |
...
|
...
|
|