redshop-process.js 1.73 KB
/*
 * @Author: Targaryen
 * @Date: 2017-03-23 11:02:31
 * @Last Modified by: Targaryen
 * @Last Modified time: 2017-03-23 14:19:26
 */
/* 红人店铺数据处理 */

const _ = require('lodash');

/**
 * 红人店铺楼层数据处理工具
 */
const _tools = {
    carouselImage(data) {
        return data;
    },
    title(data) {
        return data;
    },
    singleImage(data) {
        return data;
    },
    doubleImage(data) {
        return data;
    },
    tripleImage(data) {
        return data;
    },
    sknList(data) {
        return data;
    }
};

/**
 * 处理红人店铺楼层
 * @param {*} decoratorsData
 */
const floor = (decoratorsData) => {
    let finalData = [];

    _.forEach(decoratorsData, value => {
        switch (value.module_type) {
            case 'CarouselImage':
                finalData.push(_tools.carouselImage(value.data));
                break;
            case 'Title':
                finalData.push(_tools.title(value.data));
                break;
            case 'SingleImage':
                finalData.push(_tools.singleImage(value.data));
                break;
            case 'DoubleImage':
                finalData.push(_tools.doubleImage(value.data));
                break;
            case 'TripleImage':
                finalData.push(_tools.tripleImage(value.data));
                break;
            case 'SknList':
                finalData.push(_tools.sknList(value.data));
                break;
            default:
                break;
        }
    });

    return finalData;
};

const shopIntro = (params) => {
    if (params) {
        params.short_intro = _.get(params, 'shop_intro', '').replace(/<.*?>/g, '');
    }

    return params;
};

module.exports = {
    floor,
    shopIntro
};