help.js
1.91 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
/**
* 帮助中心
* @author: jiangmin
* @date: 2016/07/25
*/
'use strict';
const helpModel = require('../models/help');
const index = (req, res, next) => {
let siteUrl = global.yoho.config.siteUrl;
helpModel.helpData().then(result => {
res.display('help', {
module: 'help',
page: 'help-index',
content: Object.assign({
siteUrl: siteUrl,
nav: [
{
link: siteUrl,
name: 'YOHO!BLK首页'
},
{
name: '帮助中心'
}
]
}, result)
});
}).catch(next);
};
/**
* 详情
*/
const detail = (req, res, next) => {
let q = req.query;
let params = {
id: parseInt(q.id || 1, 10),
contId: +req.query.contId || 0,
keywords: req.query.helpQuery
};
let nav = [
{
link: global.yoho.config.siteUrl,
name: 'YOHO!BLK首页'
},
{
name: '帮助中心',
link: '/help/index'
}
];
helpModel.detailData(params).then(result => {
if (!(typeof (result.nav) === 'undefined')) {
nav = nav.concat(result.nav);
}
res.display('detail', {
module: 'help',
page: 'help',
content: Object.assign({nav}, result.data),
qid: q.helpQuery ? false : params.id
});
}).catch(next);
};
// 帮助搜索功能
const search = (req, res, next) => {
helpModel.searchData(req.query).then(result => {
res.json(result);
}).catch(next);
};
// 获取在线客服的链接
const onlineService = (req, res, next) => {
helpModel.onlineService().then(url => {
res.json(url);
}).catch(next);
};
module.exports = {
index,
detail,
search,
onlineService
};