help.js
3.27 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**
* 帮助中心
* @author: jiangmin
* @date: 2016/07/25
*/
'use strict';
const helpModel = require('../models/help-service');
const simpleHeaderModel = require('../../../doraemon/models/simple-header');
const _ = require('lodash');
exports.index = (req, res, next) => {
let siteUrl = global.yoho.config.siteUrl;
let channel = req.query.channel ? req.query.channel : 'boys';
req.ctx(helpModel).helpData(channel).then(result => {
if (result.content.menuData.length === 0) {
return next();
}
res.render('help', Object.assign({
module: 'help',
page: 'help-index',
content: Object.assign({
siteUrl: siteUrl,
isHelp: true,
pathNav: [
{
href: siteUrl,
name: 'YOHO!BUY 有货首页'
},
{
name: '帮助中心'
}
]
}, result.content)
}, result.headerData));
}).catch(next);
};
/**
* 详情
*/
exports.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,
channel: req.query.channel ? req.query.channel : 'boys',
url: req.originalUrl,
page: q.page || 1
};
let nav = [
{
href: global.yoho.config.siteUrl,
name: 'YOHO!BUY 有货首页'
},
{
name: '帮助中心',
href: '/help'
}
];
req.ctx(helpModel).detailData(params).then(result => {
let newData = result.newData;
let headerData = result.headerData;
let protocolUrl = '';
if (+req.query.id === 254) {
protocolUrl = 'https://cdn.yoho.cn/yohobuy/pdf/YOHO!BUY有货用户服务协议2.pdf';
}
if (+req.query.id === 256) {
protocolUrl = 'https://cdn.yoho.cn/yohobuy/pdf/YOHO!BUY有货隐私条款.pdf';
}
if (result.newData.data.menuData.length === 0) {
return next();
}
if (!(typeof(newData.nav) === 'undefined')) {
nav = nav.concat(newData.nav);
}
Object.assign(res.locals, _.get(newData, 'data.seoData', {}));
res.render('detail', Object.assign({
module: 'help',
page: 'help',
protocolUrl: protocolUrl,
content: Object.assign({
isHelp: true,
pathNav: nav,
helpQuery: req.query.helpQuery
}, newData.data),
qid: q.helpQuery ? false : params.id
}, headerData));
}).catch(next);
};
// 帮助搜索功能
exports.search = (req, res, next) => {
req.ctx(helpModel).searchData(req.query).then(result => {
res.json(result);
}).catch(next);
};
// 获取在线客服的链接
exports.onlineService = (req, res, next) => {
req.ctx(helpModel).onlineService().then(url => {
res.json(url);
}).catch(next);
};
exports.qualificationInfo = (req, res) => {
res.render('qualification-info', {
page: 'qualification',
simpleHeader: simpleHeaderModel.setSimpleHeaderData(),
});
};