search-process.js 1.6 KB
/**
 * 搜索相关数据处理
 * @author: wsl<shuiling.wang@yoho.cn>
 * @date: 2016/7/29
 */

/**
 * 根据频道判断出性别
 */
const getGenderByChannel = (channel) => {
    channel = channel ? channel : 'boys';

    switch (channel) {
        case 'boys': // 男
            return '1,3';
        case 'girls': // 女
            return '2,3';
        default: // 其它
            return '1,2,3';
    }
};

// 频道转换
const getChannelType = (channel) => {
    channel = channel ? channel : 'boys';

    switch (channel) {
        case 'boys': // 男
            return '1';
        case 'girls': // 女
            return '2';
        case 'kids': // 童装
            return '3';
        case 'lifestyle': // 创意生活
            return '4';
        default: // all
            return '1,2,3,4';
    }
};

// 排序转换
const getTypeCont = (type, order) => {
    switch (type) {
        case 'price':
            return order === '0' ? 's_p_desc' : 's_p_asc';
        case 'discount':
            return order === '0' ? 'p_d_desc' : 'p_d_asc';
        case 'sale':
            return order === '0' ? 's_n_desc' : 's_n_asc';
        case 'newest':
            return order === '0' ? 's_t_desc' : 's_t_asc';
        case 'stock':
            return order === '0' ? 's_s_desc' : 's_s_asc';
        case 'all':
            return order === '0' ? 'd_s_desc' : 'd_s_asc';
        case 'category':
            return order === '0' ? 's_t_desc' : 's_t_asc';
        default:
            return order === '0' ? 's_t_desc' : 's_t_asc';
    }
};

module.exports = {
    getGenderByChannel,
    getChannelType,
    getTypeCont
};