Authored by biao

update for coding style uniform

... ... @@ -14,7 +14,7 @@ const renderData = {
// 奥莱首页控制器
exports.index = (req, res) => {
exports.index = (req, res, next) => {
let headerData = headerModel.setNav({
navTitle: 'OUTLET',
navBtn: false
... ... @@ -29,11 +29,11 @@ exports.index = (req, res) => {
page: 'outlet',
pageHeader: headerData
}, renderData, result));
});
}).catch(next);
};
// 奥莱活动详情页
exports.activityDetail = (req, res) => {
exports.activityDetail = (req, res, next) => {
outletModel.getActivity(req.query.id).then(result => {
let headerData = headerModel.setNav({
navTitle: result.activityTitle,
... ... @@ -45,11 +45,11 @@ exports.activityDetail = (req, res) => {
pageHeader: headerData,
pageFooter: true
}, renderData, result));
});
}).catch(next);
};
// 奥莱活动频道列表页
exports.activityList = (req, res) => {
exports.activityList = (req, res, next) => {
let headerData = headerModel.setNav({
navTitle: 'OUTLET',
navBtn: false
... ... @@ -69,5 +69,5 @@ exports.activityList = (req, res) => {
pageHeader: headerData,
pageFooter: true
}, renderData, result));
});
}).catch(next);
};
... ...
... ... @@ -31,7 +31,7 @@ const dateFormate = (str) =>{
};
// 为了活动卡片特殊样式,将折扣信息拆分开来
const transDiscountToArr = (discount) => {
const _transDiscountToArr = (discount) => {
return discount.replace(/(?:\d+[.\d]?)([\u4e00-\u9fa5]{1})/g, function(fullMatch, capture) {
if (capture) {
const arr = [];
... ... @@ -52,7 +52,7 @@ const transDiscountToArr = (discount) => {
* @param {String} contentcode 内容码
* @return {Promise}
*/
const getOutletResource = (channel, contentcode) => {
const _getOutletResource = (channel, contentcode) => {
const params = {
content_code: contentcode || 'c19ffa03f053f4cac3690b22c8da26b7',
limit: 25,
... ... @@ -63,7 +63,7 @@ const getOutletResource = (channel, contentcode) => {
if (result && result.code === 200) {
return resourcesProcess(result.data.list);
} else {
log.error('奥莱资源位接口返回状态码 不是 200');
log.error('the response code of outlet "operations/api/v5/resource/home" is NOT 200', result);
return [];
}
});
... ... @@ -74,7 +74,7 @@ const getOutletResource = (channel, contentcode) => {
* @param {[Object]} 原始导航数据
* @return {Object} 转换后的数据
*/
const convertNavData = (list) => {
const _convertNavData = (list) => {
const formatData = [];
list = list || [];
... ... @@ -95,7 +95,7 @@ const convertNavData = (list) => {
* @param {String} 导航类型id
* @return {Promise}
*/
const getNavData = (categoryId) => {
const _getNavData = (categoryId) => {
const params = {
v: 7,
parent_id: categoryId
... ... @@ -103,12 +103,12 @@ const getNavData = (categoryId) => {
return serviceApi.get('operations/api/v6/category/getCategory', sign.apiSign(params)).then(result => {
if (result && result.code === 200) {
let data = convertNavData(result.data);
let data = _convertNavData(result.data);
data.category = categoryId;
return data;
} else {
log.error('奥莱导航接口返回状态码 不是 200', result);
log.error('the response code of "operations/api/v6/category/getCategory" is NOT 200', result);
return [];
}
});
... ... @@ -119,7 +119,7 @@ const getNavData = (categoryId) => {
* @param {Object} data 原始数据
* @return {Object} 转换后的数据
*/
const convertActicityData = (data) => {
const _convertActicityData = (data) => {
const formatData = [];
let discountArr = [],
... ... @@ -130,11 +130,11 @@ const convertActicityData = (data) => {
_.forEach(data, (item) => {
discountArr = item.promotionName.split('~');
if (discountArr.length === 1) {
discountNum = transDiscountToArr(discountArr[0])[0];
discountText = transDiscountToArr(discountArr[0])[1];
discountNum = _transDiscountToArr(discountArr[0])[0];
discountText = _transDiscountToArr(discountArr[0])[1];
} else {
discountNum = discountArr[0] + '~' + transDiscountToArr(discountArr[1])[0];
discountText = transDiscountToArr(discountArr[1])[1];
discountNum = discountArr[0] + '~' + _transDiscountToArr(discountArr[1])[0];
discountText = _transDiscountToArr(discountArr[1])[1];
}
... ... @@ -159,7 +159,7 @@ const convertActicityData = (data) => {
* @param {String} id 活动id
* @return {Promise} 调用接口的Promise
*/
const getActivityDetail = (id) => {
const _getActivityDetail = (id) => {
var params = {
method: 'app.outlets.activityGet',
sort: 1,
... ... @@ -171,9 +171,9 @@ const getActivityDetail = (id) => {
return api.get('', sign.apiSign(params)).then(res => {
if (res.code === 200) {
return convertActicityData(res.data);
return _convertActicityData(res.data);
} else {
log.error('获取奥莱活动详情页接口返回状态码 不是 200', res);
log.error('the response code of "app.outlets.activityGet" is NOT 200', res);
return {};
}
});
... ... @@ -184,14 +184,14 @@ const getActivityDetail = (id) => {
* @param {Object} data 请求接口所需的参数
* @return {Promise} 调用接口的Promise
*/
const getHomeActivity = (data) => {
const _getHomeActivity = (data) => {
var params = {
method: 'app.outlets.activityGet',
platform: 3
};
return api.get('', sign.apiSign(_.assign(params, data))).then(res => {
return convertActicityData(res.data);
return _convertActicityData(res.data);
});
};
... ... @@ -202,13 +202,13 @@ const getHomeActivity = (data) => {
* @param {Strting} code 内容码
* @return {Promise} 调用接口的Promise
*/
exports.getContent = (categoryId, channel, code) => {
const getContent = (categoryId, channel, code) => {
let params = {
type: 0,
yh_channel: channel
};
const p = [getNavData(categoryId), getOutletResource(channel, code), getHomeActivity(params)];
const p = [_getNavData(categoryId), _getOutletResource(channel, code), _getHomeActivity(params)];
return Promise.all(p).then(data => {
... ... @@ -225,8 +225,8 @@ exports.getContent = (categoryId, channel, code) => {
* @param {String} id 活动id
* @return {Promise} 调用接口的Promise
*/
exports.getActivity = (id) => {
return getActivityDetail(id).then(res => {
const getActivity = (id) => {
return _getActivityDetail(id).then(res => {
return {
activity: res,
productPool: res[0] && res[0].productPoolId || '',
... ... @@ -242,12 +242,12 @@ exports.getActivity = (id) => {
* @param {String} categoryId 父级菜单id,用于标明当前页面是奥莱页面
* @return {Object} 活动列表数据
*/
exports.getRecentActivity = (type, categoryId) => {
const getRecentActivity = (type, categoryId) => {
var params = {
type: type
};
return Promise.all([getNavData(categoryId), getHomeActivity(params)]).then(res => {
return Promise.all([_getNavData(categoryId), _getHomeActivity(params)]).then(res => {
return {
nav: res[0] || [],
... ... @@ -255,3 +255,9 @@ exports.getRecentActivity = (type, categoryId) => {
};
});
};
module.exports = {
getContent: getContent,
getActivity: getActivity,
getRecentActivity: getRecentActivity
}
... ...