resources-process.js 963 Bytes
const _ = require('lodash');
const camelCase = global.yoho.camelCase;

/**
 * 处理楼层数据
 * @param  {[array]} list
 * @return {[array]}
 */
module.exports = (list) => {
    const formatData = [];

    list = list || [];

    // TODO:
    list = camelCase(list);

    _.forEach(list, (floor) => {
        floor[_.camelCase(floor.templateName)] = true;

        // 特殊资源位处理
        // PLUS
        if (floor.singleNameImage && floor.data) {
            floor.data.title = {
                title: floor.data.title
            };
        }

        // 潮流时装/经典裤裙/时尚靴履/潮人配饰/潮流上装
        if (floor.recommendContentOne && floor.data) {
            if (floor.data.bigImage && floor.data.bigImage.length > 1) {
                floor.data.bigImage = {
                    bigList: floor.data.bigImage
                };
            }
        }

        formatData.push(floor);
    });

    return formatData;
};