Authored by 郭成尧

公共方法剥离

... ... @@ -178,7 +178,7 @@ exports.formatActivityData = (data) => {
* @param {[type]} origin [description]
* @return {[type]} [description]
*/
exports.handleOutletsBannersData = (origin) => {
exports.handleOutletsBannersData = (origin, params) => {
var dest = {};
dest.limitedBuy = {};
... ... @@ -233,8 +233,15 @@ exports.handleOutletsBannersData = (origin) => {
let goodsmenu = {};
goodsmenu.name = subValue.categoryName;
goodsmenu.href = subValue.url;
_.forEach(params, (paramValue, paramKey) => {
goodsmenu.href += paramKey + '=' + paramValue + '&';
});
goodsmenu.href = _.trim(goodsmenu.href, '&');
dest.goodsBoard.goodsMenu.menuList.push(goodsmenu);
});
... ...
... ... @@ -2,7 +2,7 @@
* @Author: Targaryen
* @Date: 2016-05-30 16:20:03
* @Last Modified by: Targaryen
* @Last Modified time: 2016-06-02 14:26:27
* @Last Modified time: 2016-06-02 15:57:38
*/
'use strict';
... ... @@ -42,7 +42,7 @@ exports.getOutletsIndexData = (params) => {
// 处理资源位数据
if (result[0].code === 200) {
finalResult = Object.assign(finalResult,
outletsProcess.handleOutletsBannersData(result[0].data));
outletsProcess.handleOutletsBannersData(result[0].data, params));
}
// 处理限时嗨购列表数据
... ...
/*
* @Author: Targaryen
* @Date: 2016-06-02 15:50:47
* @Last Modified by: Targaryen
* @Last Modified time: 2016-06-02 16:05:54
*/
'use strict';
const _ = require('lodash');
/**
* 处理用于筛选的 URL
* @param {[type]} originParam [description]
* @param {[type]} newParam [description]
* @return {[type]} [description]
*/
exports.handleFilterUrl = (originParam, newParam) => {
let dest = '?';
let tempOriginParam = {};
// 创建 originParam、newParam 键的数组
let originParamArray = _.keys(originParam);
let newParamArray = _.keys(newParam);
// 判断参数是否已经存在
let isExist = !_.isEmpty(_.find(originParamArray, function(o) {
return o === newParamArray[0];
}));
if (isExist) {
tempOriginParam = Object.assign(tempOriginParam, originParam);
_.forEach(newParam, function(value, key) {
tempOriginParam[key] = value;
});
} else {
tempOriginParam = Object.assign(tempOriginParam, originParam, newParam);
}
_.forEach(tempOriginParam, function(value, key) {
dest = dest + key + '=' + value + '&';
});
return _.trim(dest, '&');
};
/**
* 处理选中数据
* @param {[type]} params [description]
* @param {[type]} origin [description]
* @param {[type]} param [description]
* @return {[type]} [description]
*/
exports.handleCheckedData = (params, origin, param) => {
var dest = [];
// 品牌选中数据
if (!_.isEmpty(origin)) {
_.forEach(origin, (value) => {
if (value.checked) {
let checked = {};
checked.name = value.name;
let tempParam = {};
tempParam[param] = '';
// checked.href = handleFilterUrl(params, tempParam);
dest.push(checked);
}
});
}
return dest;
};
... ...