Authored by 李奇

/helper/queryAllHelper 接口session_key添加

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