menu-crumb-handler.js
1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
* 个人中心布局(顶部面包屑和左侧导航)
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2016/7/5
*/
'use strict';
const _ = require('lodash');
const blk = global.yoho;
const url = blk.helpers.urlFormat;
// 左侧菜单
const navigation = [
{
link: url('/me/order'),
name: '我的订单'
},
{
link: url('/me/return'),
name: '我的退/换货'
},
{
link: url('/me/collection'),
name: '我的收藏'
},
{
link: url('/me/message'),
name: '我的消息'
},
{
link: url('/me/currency'),
name: '我的YOHO币'
},
{
link: url('/me/setting'),
name: '个人设置'
},
{
link: url('/me/address'),
name: '收货地址'
}
];
// 头部导航面包屑
const getMeCrumb = name => {
return [
{
link: blk.config.sitUrl,
name: 'YOHO!BLK首页'
},
{
link: url('/me'),
name: '个人中心'
},
{
name: name ? name : '我的订单'
}
];
};
// 侧栏菜单
const getSideMenu = focus => {
let copiedNav = _.cloneDeep(navigation);
if (focus && _.some(copiedNav, {name: focus})) {
Object.assign(_.find(copiedNav, {name: focus}), {
focus: true
});
} else {
// 若没有传focus || focus不在navigation中,则默认focus第1个菜单
copiedNav[0].focus = true;
}
return copiedNav;
};
module.exports = {
getMeCrumb,
getSideMenu
};