Authored by 徐炜

Merge remote-tracking branch 'origin/release/customer-service2' into release/customer-service2

# Conflicts:
#	app.js
@@ -45,7 +45,7 @@ app.locals.version = pkg.version; @@ -45,7 +45,7 @@ app.locals.version = pkg.version;
45 45
46 // zookeeper 46 // zookeeper
47 if (config.zookeeperServer) { 47 if (config.zookeeperServer) {
48 - require('yoho-zookeeper')(config.zookeeperServer, 'pc', app.locals.pc = {}); 48 + require('yoho-zookeeper')(config.zookeeperServer, 'pc', app.locals.pc = {}, global.yoho.cache);
49 } 49 }
50 50
51 app.set('subdomain offset', 2); 51 app.set('subdomain offset', 2);
@@ -99,7 +99,6 @@ try { @@ -99,7 +99,6 @@ try {
99 const errorHanlder = require('./doraemon/middleware/error-handler'); 99 const errorHanlder = require('./doraemon/middleware/error-handler');
100 const setPageInfo = require('./doraemon/middleware/set-pageinfo'); 100 const setPageInfo = require('./doraemon/middleware/set-pageinfo');
101 const pageCache = require('./doraemon/middleware/page-cache'); 101 const pageCache = require('./doraemon/middleware/page-cache');
102 - const secretSwitch = require('./doraemon/middleware/secret-switch');  
103 const devtool = require('./doraemon/middleware/devtools'); 102 const devtool = require('./doraemon/middleware/devtools');
104 103
105 // YOHO 前置中间件 104 // YOHO 前置中间件
@@ -111,7 +110,6 @@ try { @@ -111,7 +110,6 @@ try {
111 app.use(user()); 110 app.use(user());
112 app.use(seo()); 111 app.use(seo());
113 app.use(setPageInfo()); 112 app.use(setPageInfo());
114 - app.use(secretSwitch());  
115 app.use(pageCache()); 113 app.use(pageCache());
116 114
117 if (app.locals.devEnv) { 115 if (app.locals.devEnv) {
1 -/**  
2 - * 设置cache controller  
3 - * @author: xiaoxiao<xiaoxiao.hao@yoho.cn>  
4 - * @date: 2016/12/21  
5 - */  
6 -  
7 -'use strict';  
8 -const cache = global.yoho.cache;  
9 -  
10 -const index = (req, res, next) => {  
11 - const param = req.query['com.yohobuy.customerservice.enabled'];  
12 - let status = param === 'true';  
13 -  
14 - cache.set('customerServiceSwitch', status, 0).then(result => {  
15 - res.json(result);  
16 - }).catch(next);  
17 -  
18 -};  
19 -  
20 -module.exports = {  
21 - index  
22 -};  
@@ -10,12 +10,9 @@ const router = require('express').Router(); // eslint-disable-line @@ -10,12 +10,9 @@ const router = require('express').Router(); // eslint-disable-line
10 const cRoot = './controllers'; 10 const cRoot = './controllers';
11 11
12 const ads = require(`${cRoot}/ads`); // 第三方广告平台对接 12 const ads = require(`${cRoot}/ads`); // 第三方广告平台对接
13 -const secretSwitch = require(`${cRoot}/secret-switch`);  
14 13
15 // Your controller here 14 // Your controller here
16 15
17 router.get('/ads', ads.jump); 16 router.get('/ads', ads.jump);
18 17
19 -router.get('/secret-switch', secretSwitch.index); // 设置cache  
20 -  
21 module.exports = router; 18 module.exports = router;
@@ -34,7 +34,7 @@ const bindController = require(`${cRoot}/3party-bind`); @@ -34,7 +34,7 @@ const bindController = require(`${cRoot}/3party-bind`);
34 // const AddressController = require(`${cRoot}/address`); 34 // const AddressController = require(`${cRoot}/address`);
35 // const GiftController = require(`${cRoot}/gift`); 35 // const GiftController = require(`${cRoot}/gift`);
36 36
37 -const homeNav = (req, res) => { 37 +const homeNav = (req) => {
38 return [ 38 return [
39 { 39 {
40 title: '交易管理', 40 title: '交易管理',
@@ -56,12 +56,12 @@ const homeNav = (req, res) => { @@ -56,12 +56,12 @@ const homeNav = (req, res) => {
56 56
57 /* {name: '我的投诉', href: '/home/complaints'}, */ 57 /* {name: '我的投诉', href: '/home/complaints'}, */
58 {name: '我的信息', href: '/home/message', count: 0}, 58 {name: '我的信息', href: '/home/message', count: 0},
59 - {  
60 - name: '在线客服',  
61 - href: res.locals.customerServiceSwitch ? 59 + {
  60 + name: '在线客服',
  61 + href: _.get(req.app.locals.pc, 'clientService.new', false) ?
62 '/service/client' : 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&amp;configID=149091&amp;jid=8732423409', 62 '/service/client' : 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&amp;configID=149091&amp;jid=8732423409',
63 - isBlank: true  
64 - } 63 + isBlank: true
  64 + }
65 ] 65 ]
66 }, 66 },
67 { 67 {
@@ -74,11 +74,11 @@ const homeNav = (req, res) => { @@ -74,11 +74,11 @@ const homeNav = (req, res) => {
74 ] 74 ]
75 } 75 }
76 ]; 76 ];
77 -} 77 +};
78 78
79 -const getActiveNav = (req, res)=>{ 79 +const getActiveNav = (req)=>{
80 80
81 - let mHomeNav = _.cloneDeep(homeNav(req, res)); 81 + let mHomeNav = _.cloneDeep(homeNav(req));
82 82
83 return mHomeNav.map((item) => { 83 return mHomeNav.map((item) => {
84 item.subNav = item.subNav.map((nav) => { 84 item.subNav = item.subNav.map((nav) => {
@@ -108,7 +108,7 @@ const getActiveNav = (req, res)=>{ @@ -108,7 +108,7 @@ const getActiveNav = (req, res)=>{
108 108
109 const getHomeNav = (req, res, next) => { 109 const getHomeNav = (req, res, next) => {
110 res.locals.path = [{href: helpers.urlFormat('/'), name: 'YOHO!BUY 有货首页'}, {name: '个人中心'}]; 110 res.locals.path = [{href: helpers.urlFormat('/'), name: 'YOHO!BUY 有货首页'}, {name: '个人中心'}];
111 - res.locals.homeNav = getActiveNav(req, res); 111 + res.locals.homeNav = getActiveNav(req);
112 res.locals.userThumb = '//img10.static.yhbimg.com/headimg/' + 112 res.locals.userThumb = '//img10.static.yhbimg.com/headimg/' +
113 '2013/11/28/09/01cae078abe5fe320c88cdf4c220212688.gif?imageView/2/w/100/h/100'; 113 '2013/11/28/09/01cae078abe5fe320c88cdf4c220212688.gif?imageView/2/w/100/h/100';
114 next(); 114 next();
1 -const logger = global.yoho.logger;  
2 -  
3 -const secretSwitch = () => {  
4 - return (req, res, next) => {  
5 - // 获取客服开关,读cache  
6 - global.yoho.cache.get('customerServiceSwitch').then(result => {  
7 - Object.assign(res.locals, {  
8 - customerServiceSwitch: result || false  
9 - });  
10 - next();  
11 - }).catch((err) => {  
12 - logger.error(err);  
13 - next();  
14 - });  
15 - };  
16 -};  
17 -  
18 -module.exports = secretSwitch;  
@@ -189,7 +189,7 @@ @@ -189,7 +189,7 @@
189 </div> 189 </div>
190 <div class="left"> 190 <div class="left">
191 <span class="iconfont rgbf">&#xe602;</span> 191 <span class="iconfont rgbf">&#xe602;</span>
192 - <a href="{{#if customerServiceSwitch}}/service/client{{else}}http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&amp;configID=149091&amp;jid=8732423409{{/if}}" target="_blank"> 192 + <a href="{{#if @root.pc.clientService.new}}/service/client{{else}}http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&amp;configID=149091&amp;jid=8732423409{{/if}}" target="_blank">
193 <span class="red">便捷</span> 193 <span class="red">便捷</span>
194 <span class="rgbf">在线客服</span> 194 <span class="rgbf">在线客服</span>
195 </a> 195 </a>
@@ -60,7 +60,7 @@ @@ -60,7 +60,7 @@
60 "serve-favicon": "^2.3.0", 60 "serve-favicon": "^2.3.0",
61 "uuid": "^2.0.2", 61 "uuid": "^2.0.2",
62 "yoho-node-lib": "0.2.2", 62 "yoho-node-lib": "0.2.2",
63 - "yoho-zookeeper": "^1.0.4" 63 + "yoho-zookeeper": "^1.0.6"
64 }, 64 },
65 "devDependencies": { 65 "devDependencies": {
66 "autoprefixer": "^6.3.6", 66 "autoprefixer": "^6.3.6",