client.js
1.09 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
/**
* 客服用户端 controller
*
* @author: liqi <qi.li@yoho.cn>
* @date: 2016/11/4
*/
'use strict';
const aes = require('./aes-pwd');
const common = require('../../../config/common');
const clientService = require('../models/client-service');
/**
* 在线客服客户端
*/
const index = (req, res, next) => {
let reg = /MSIE\s?[987]\.0/i;
let userAgent = req.headers['user-agent'];
let unSupport = reg.test(userAgent);
let type = 2;
let imgSize = '86x120';
let encryptedUid = aes.encryptionUid(req.user.uid);
let data = {
encryptedUid,
layout: false
};
if (unSupport) {
res.render('unsupport', {
layout: false
});
} else {
clientService.getClientData(type, encryptedUid, imgSize)
.then(result => {
res.render('client', Object.assign(data, result));
})
.catch(next);
}
};
/**
* 在线客服客户端
*/
const domains = (req, res) => {
// 返回当前环境的配置信息
res.json(common.domains);
};
module.exports = {
index,
domains
};