Authored by 李奇

/helper/queryAllHelper 接口session_key添加

... ... @@ -7,6 +7,7 @@
'use strict';
const aes = require('./aes-pwd');
const helpers = global.yoho.helpers;
const common = require('../../../config/common');
const clientApi = require('../models/client-api');
const clientService = require('../models/client-service');
... ... @@ -16,10 +17,11 @@ const clientService = require('../models/client-service');
*/
const index = (req, res, next) => {
let type = 2;
let uid = req.user.uid;
let reg = /MSIE\s?[987]\.0/i;
let userAgent = req.headers['user-agent'];
let unSupport = reg.test(userAgent);
let encryptedUid = aes.encryptionUid(req.user.uid);
let encryptedUid = aes.encryptionUid(uid);
let domains = common.domains;
let imCs = domains.imCs;
let imSocket = domains.imSocket;
... ... @@ -36,8 +38,11 @@ const index = (req, res, next) => {
layout: false
});
} else {
clientService.getClientData(type, encryptedUid)
clientService.getClientData(uid, type, encryptedUid)
.then(result => {
if (result.code === 401) {
return res.redirect(helpers.urlFormat('/signin.html'));
}
res.render('client', Object.assign(data, result));
}).catch(next);
}
... ...
... ... @@ -43,8 +43,11 @@ const getLastTenOrders = (encryptedUid) => {
* @function getQas
* @return { Object } 问答列表
*/
const getQas = () => {
return api.post(urls.qas, {});
const getQas = (uid, encryptedUid) => {
return api.post(urls.qas, {
uid,
encryptedUid
});
};
/**
... ...
... ... @@ -17,7 +17,7 @@ const clientAPI = require('./client-api');
* @param { string } encryptedUid
* @return { Object } 客服设置
*/
const getClientData = (type, encryptedUid) => {
const getClientData = (uid, type, encryptedUid) => {
const logoSize = '136x40';
const qcSize = '135x135';
const advSize = '160x335';
... ... @@ -27,7 +27,7 @@ const getClientData = (type, encryptedUid) => {
clientAPI.getCsSetting(type),
clientAPI.getMsgHistory(encryptedUid),
clientAPI.getLastTenOrders(encryptedUid),
clientAPI.getQas()
clientAPI.getQas(uid, encryptedUid)
];
return Promise.all(apiMethod)
... ... @@ -38,6 +38,14 @@ const getClientData = (type, encryptedUid) => {
let records = [];
let hasHistory = false;
if (res[1].code === 401 ||
res[2].code === 401 ||
res[3].code === 401) {
return {
code: 401
};
}
if (res[0] && res[0].code === 200) {
if (res[0].data.config) {
csSetting = res[0].data.config;
... ...