channel-gender.js 590 Bytes
'use strict';

const path = require('path');
const utilsPath = path.join(global.utils, '/constant');
const channelDict = require(utilsPath).channelDict;


// 如果 没有 gender, 根据channel,设置gender
// Notice: 如果 没有 channel,则不设 gender
exports.channelGender = (req, res, next) => {
    if (/^\/product\/shop\//.test(req.path)) {  // 店铺 不分 男女
        next();
        return;
    }

    if (!req.query.hasOwnProperty('gender')) {
        const channel = channelDict(req.yoho.channel);

        channel && (req.query.gender = channel);
    }

    next();
};