plustar.js 2.25 KB
/**
 * 国际优选
 * @author: zxr<xiaoru.zhang@yoho.cn>
 * @date: 2016/09/12
 */
'use strict';

const mRoot = '../models';
const plustarModel = require(`${mRoot}/plustar`);
const htmlProcess = require(`${global.utils}/html-process`);
const headerModel = require('../../../doraemon/models/header'); // 头部model
let channels = {
    boys: '1,3',
    girl: '2,3',
    kids: '3,3',
    lifestyle: '4'
};

const getListData = (req, res, next) => {
    let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || '1,3';
    let recom = '4';
    let all = '1';

    plustarModel.getListData(gender, recom, all).then((result) => {

        res.render('plustar/list', {
            module: 'guang',
            page: 'plustar-list',
            title: '国际优选',
            pageHeader: headerModel.setNav({
                navTitle: '国际优选'
            }),
            pageFooter: true,
            ps: {
                sName: '设计师',
                pName: '经典潮牌',
                star: result.star,
                plus: result.plus
            }
        });
    }).catch(next);
};

const getDetailData = (req, res, next) => {
    let id = req.query.id;
    let uid = req.user.uid;
    let udid = req.sessionID || 'yoho';
    let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || '1,3';
    let isApp = req.query.app_version || req.query.appVersion || false;
    let clientType = req.body.client_type || '';
    let version = req.body.app_version || '';

    if (clientType.toLowerCase() === 'ios' && version) {
        clientType = 'iphone';
    } else if (clientType.toLowerCase() === 'android' && version) {
        clientType = 'android';
    } else {
        clientType = 'h5';
    }

    plustarModel.getDetailData(id, uid, udid, gender, isApp, clientType).then((result) => {
        result.brandIntro = htmlProcess.removeHtml(result.brandIntro);
        res.render('plustar/detail', {
            module: 'guang',
            page: 'plustar-detail',
            title: result.brandName,
            pageHeader: headerModel.setNav({
                navTitle: result.brandName
            }),
            ps: result
        });
    }).catch(next);
};

module.exports = {
    getListData,
    getDetailData
};