simple-header.js 1.29 KB
/**
 * simple-header model
 * @author: wsl<shuiling.wang@yoho.cn>
 * @date: 2016/07/06
 */

'use strict';
let helpers = global.yoho.helpers;

/**
 * 获取简单头部数据
 */
const setSimpleHeaderData = (user) => {
    let time = Date.now();

    let simpleHeader = {
        logo: {
            img: '//static.yohobuy.com/newheader/img/logo_e.png',
            url: '//www.yohobuy.com'
        },
        tool: {
            favoriteHref: helpers.urlFormat('/home/favorite', {t: time}), // 我的收藏链接
            couponHref: helpers.urlFormat('/home/coupons', {t: time}), // 我的优惠券链接
            orderHref: helpers.urlFormat('/home/orders', {t: time}), // 订单中心连接
            userCenter: helpers.urlFormat('/home', {t: time}), // 用户中心链接
            helpHref: helpers.urlFormat('/help'),
            loginHref: helpers.urlFormat('/signin.html'), // 登录链接,已登录不传
            registerHref: helpers.urlFormat('/reg.html') // 注册链接,已登录不传
        }
    };

    if (user && user.uid) {
        Object.assign(simpleHeader.tool, {
            loginHref: false,
            registerHref: false,
            user: user.name,
            isLogin: true
        });
    }

    return simpleHeader;
};

module.exports = {
    setSimpleHeaderData
};