help.js
2.38 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/**
* 帮助中心
* @author: jiangmin
* @date: 2016/07/25
*/
'use strict';
const helpModel = require('../models/help');
/**
* 根据id获取文章数据
* @param id
* @returns {*}
*/
/* const getData = (id)=> {
let contentData = helpModel.contentData().content;
for (var i = 0; i < contentData.length; i++) {
if (contentData[i].id === id) {
return contentData[i]
}
}
};*/
/**
* 根据id获取当前所在位置,拼接面包屑
* @param id
*/
const getNav = (id)=> {
let menuData = helpModel.menuData().menuData;
for (let i = 0; i < menuData.length; i++) {
if (menuData[i].subsets) {
for (let j = 0; j < menuData[i].subsets.length; j++) {
if (menuData[i].subsets[j].id === id) {
return [
{
name: menuData[i].text
}, {
name: menuData[i].subsets[j].text
}
];
}
}
} else {
if (menuData[i].id === id) {
return [
{
name: menuData[i].text
}
];
}
}
}
};
/**
* 主界面
*/
const index = (req, res,next) => {
let id = req.query.id || '11';
helpModel.getHelpDetail('81', 1, 15, '').then(result=> {
let content = {content: result.helpdetail_list[0].content};
let data = Object.assign(content, helpModel.menuData());
let nav = [
{
link: global.yoho.config.sitUrl,
name: 'YOHO!BLK首页'
},
{
name: '帮助中心'
}
];
if (!(typeof (getNav(id)) === "undefined")) {
nav = nav.concat(getNav(id));
}
res.display('detail', {
module: 'help',
page: 'help',
content: Object.assign({nav}, data)
});
}).catch(next);
/* let data = Object.assign(getData(id), helpModel.menuData());
let nav = [
{
link: global.yoho.config.sitUrl,
name: 'YOHO!BLK首页'
},
{
name: '帮助中心'
}
];
nav = nav.concat(getNav(id));
res.display('detail', {
module: 'help',
page: 'help',
content: Object.assign({nav}, data)
});*/
};
module.exports = {
index
};