|
|
/*
|
|
|
* @Author: Targaryen
|
|
|
* @Date: 2016-05-25 18:16:59
|
|
|
* @Last Modified by: Targaryen
|
|
|
* @Last Modified time: 2016-05-25 18:21:15
|
|
|
*/
|
|
|
* @Author: Targaryen
|
|
|
* @Date: 2016-05-25 18:16:59
|
|
|
* @Last Modified by: Targaryen
|
|
|
* @Last Modified time: 2016-05-26 11:11:07
|
|
|
*/
|
|
|
|
|
|
'use strict';
|
|
|
const _ = require('lodash');
|
|
|
|
|
|
/**
|
|
|
* 处理用于筛选的 URL
|
|
|
* @param {[type]} originParam [description]
|
|
|
* @param {[type]} newParam [description]
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
const 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]} origin [description]
|
|
|
* @return {[type]} [description]
|
...
|
...
|
@@ -16,7 +52,6 @@ const _ = require('lodash'); |
|
|
exports.handleSaleGoodsListData = (origin) => {
|
|
|
var dest = [];
|
|
|
|
|
|
|
|
|
if (!_.isEmpty(origin)) {
|
|
|
|
|
|
_.forEach(origin, function(value) {
|
...
|
...
|
@@ -29,7 +64,7 @@ exports.handleSaleGoodsListData = (origin) => { |
|
|
oneGoods.goodsList = value.goods_list;
|
|
|
oneGoods.name = value.product_name;
|
|
|
oneGoods.brand = {};
|
|
|
oneGoods.brand.url = value.brand_domain + '.SUB_DOMAIN'; // 待处理
|
|
|
oneGoods.brand.url = value.brand_domain + '.yohobuy.com'; // 待处理
|
|
|
oneGoods.brand.name = value.brand_name;
|
|
|
oneGoods.marketPrice = value.market_price;
|
|
|
|
...
|
...
|
@@ -45,7 +80,7 @@ exports.handleSaleGoodsListData = (origin) => { |
|
|
* @param {[type]} origin [description]
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
exports.handleSaleFilterData = (origin) => {
|
|
|
exports.handleSaleFilterData = (origin, params) => {
|
|
|
var dest = {};
|
|
|
|
|
|
dest.brand = {};
|
...
|
...
|
@@ -61,7 +96,7 @@ exports.handleSaleFilterData = (origin) => { |
|
|
let brand = {};
|
|
|
|
|
|
brand.checked = false;
|
|
|
brand.href = 'CURRENT_URL/brand=' + value.brand_domain; // 待处理
|
|
|
brand.href = handleFilterUrl(params, { brand: value.id });
|
|
|
brand.name = value.brand_name;
|
|
|
|
|
|
dest.brand.default.push(brand);
|
...
|
...
|
@@ -73,7 +108,7 @@ exports.handleSaleFilterData = (origin) => { |
|
|
_.forEach(origin.priceRange, function(value, key) {
|
|
|
let price = {
|
|
|
checked: false,
|
|
|
href: 'CURRENT_URL/price=' + key, // 待处理
|
|
|
href: handleFilterUrl(params, { price: key }),
|
|
|
name: value
|
|
|
};
|
|
|
|
...
|
...
|
@@ -89,9 +124,9 @@ exports.handleSaleFilterData = (origin) => { |
|
|
}
|
|
|
|
|
|
dest.channel[0].name = '男生';
|
|
|
dest.channel[0].href = 'CURRENT_URL/?gender=1,3';
|
|
|
dest.channel[0].href = handleFilterUrl(params, { gender: '1,3' });
|
|
|
dest.channel[1].name = '女生';
|
|
|
dest.channel[1].href = 'CURRENT_URL/?gender=2,3';
|
|
|
dest.channel[1].href = handleFilterUrl(params, { gender: '2,3' });
|
|
|
|
|
|
return dest;
|
|
|
};
|
...
|
...
|
@@ -101,7 +136,7 @@ exports.handleSaleFilterData = (origin) => { |
|
|
* @param {[type]} origin [description]
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
exports.handleSaleOptsData = () => {
|
|
|
exports.handleSaleOptsData = (params) => {
|
|
|
var dest = {};
|
|
|
|
|
|
dest.countPerPage = 60;
|
...
|
...
|
@@ -112,7 +147,7 @@ exports.handleSaleOptsData = () => { |
|
|
for (let i = 0; i < 2; i++) {
|
|
|
let opt = {};
|
|
|
|
|
|
opt.href = 'CURRENT_URL/?order=s_p_asc';
|
|
|
opt.href = handleFilterUrl(params, { order: 's_p_asc' });
|
|
|
opt.name = '价格';
|
|
|
opt.hasSortOrient = {};
|
|
|
opt.hasSortOrient.active = {};
|
...
|
...
|
@@ -128,7 +163,7 @@ exports.handleSaleOptsData = () => { |
|
|
* 处理页面左侧分类筛选数据
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
exports.handleSaleSortData = (origin) => {
|
|
|
exports.handleSaleSortData = (origin, params) => {
|
|
|
var leftContent = {};
|
|
|
|
|
|
leftContent.allSort = {};
|
...
|
...
|
@@ -145,7 +180,7 @@ exports.handleSaleSortData = (origin) => { |
|
|
category.childList.push({
|
|
|
name: subValue.category_name,
|
|
|
num: subValue.node_count,
|
|
|
href: ''
|
|
|
href: handleFilterUrl(params, { sort: subValue.relation_parameter.sort })
|
|
|
});
|
|
|
});
|
|
|
|
...
|
...
|
|