Authored by 周少峰

Merge branch 'release/customer-service'

... ... @@ -99,6 +99,7 @@ try {
const errorHanlder = require('./doraemon/middleware/error-handler');
const setPageInfo = require('./doraemon/middleware/set-pageinfo');
const pageCache = require('./doraemon/middleware/page-cache');
const secretSwitch = require('./doraemon/middleware/secret-switch');
// YOHO 前置中间件
app.use(subDomain());
... ... @@ -109,7 +110,7 @@ try {
app.use(user());
app.use(seo());
app.use(setPageInfo());
app.use(secretSwitch());
app.use(pageCache());
require('./dispatch')(app);
... ...
/**
* 设置cache controller
* @author: xiaoxiao<xiaoxiao.hao@yoho.cn>
* @date: 2016/12/21
*/
'use strict';
const cache = global.yoho.cache;
const index = (req, res, next) => {
const param = req.query['com.yohobuy.customerservice.enabled'];
let status = param === 'true';
cache.set('customerServiceSwitch', status, 0).then(result => {
res.json(result);
}).catch(next);
};
module.exports = {
index
};
... ...
... ... @@ -13,6 +13,7 @@ var multipart = require('connect-multiparty');
var multipartMiddleware = multipart();
const rvCtrl = require(`${cRoot}/recent-view`);
const cache = require(`${cRoot}/secret-switch`);
const uploadCtrl = require(`${cRoot}/upload`);
const erp2goods = require(`${cRoot}/erp2goods`);
const getBanner = require(`${cRoot}/getBanner`);
... ... @@ -24,6 +25,8 @@ router.post('/upload/image', multipartMiddleware, uploadCtrl.uploadImg);
router.get('/erp2goods', erp2goods.find);
router.get('/secret-switch', cache.index); // 设置cache
router.get('/getbanner', getBanner.index);
router.get('/passport', passport.index);
... ...
... ... @@ -34,44 +34,51 @@ const bindController = require(`${cRoot}/3party-bind`);
// const AddressController = require(`${cRoot}/address`);
// const GiftController = require(`${cRoot}/gift`);
const homeNav = [
{
title: '交易管理',
subNav: [
{name: '我的订单', href: '/home/orders', catchs: ['/home/orders', '/home/index']},
{name: '我的收藏', href: '/home/favorite'},
{name: '我的有货币', href: '/home/currency'},
{name: '我的红包', href: '/home/redenvelopes'},
{name: '我的优惠券', href: '/home/coupons'},
{name: '我的VIP', href: '/home/vip'}
]
},
{
title: '服务中心',
subNav: [
{name: '我的退/换货', href: '/home/returns'},
{name: '我的咨询', href: '/home/consult'},
{name: '我的评论', href: '/home/comment'},
/* {name: '我的投诉', href: '/home/complaints'}, */
{name: '我的信息', href: '/home/message', count: 0},
{name: '在线客服', href: 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&amp;configID=149091&amp;jid=8732423409', isBlank: true}
]
},
{
title: '个人信息管理',
subNav: [
{name: '编辑个人资料', href: '/home/user'},
{name: '账号安全', href: '/home/account'},
{name: '地址管理', href: '/home/address'},
{name: '兑换礼品卡', href: '/home/gift'}
]
}
];
const getActiveNav = (req)=>{
let mHomeNav = _.cloneDeep(homeNav);
const homeNav = (req, res) => {
return [
{
title: '交易管理',
subNav: [
{name: '我的订单', href: '/home/orders', catchs: ['/home/orders', '/home/index']},
{name: '我的收藏', href: '/home/favorite'},
{name: '我的有货币', href: '/home/currency'},
{name: '我的红包', href: '/home/redenvelopes'},
{name: '我的优惠券', href: '/home/coupons'},
{name: '我的VIP', href: '/home/vip'}
]
},
{
title: '服务中心',
subNav: [
{name: '我的退/换货', href: '/home/returns'},
{name: '我的咨询', href: '/home/consult'},
{name: '我的评论', href: '/home/comment'},
/* {name: '我的投诉', href: '/home/complaints'}, */
{name: '我的信息', href: '/home/message', count: 0},
{
name: '在线客服',
href: res.locals.customerServiceSwitch ?
'/service/client' : 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&amp;configID=149091&amp;jid=8732423409',
isBlank: true
}
]
},
{
title: '个人信息管理',
subNav: [
{name: '编辑个人资料', href: '/home/user'},
{name: '账号安全', href: '/home/account'},
{name: '地址管理', href: '/home/address'},
{name: '兑换礼品卡', href: '/home/gift'}
]
}
];
}
const getActiveNav = (req, res)=>{
let mHomeNav = _.cloneDeep(homeNav(req, res));
return mHomeNav.map((item) => {
item.subNav = item.subNav.map((nav) => {
... ... @@ -101,7 +108,7 @@ const getActiveNav = (req)=>{
const getHomeNav = (req, res, next) => {
res.locals.path = [{href: helpers.urlFormat('/'), name: 'YOHO!BUY 有货首页'}, {name: '个人中心'}];
res.locals.homeNav = getActiveNav(req);
res.locals.homeNav = getActiveNav(req, res);
res.locals.userThumb = '//img10.static.yhbimg.com/headimg/' +
'2013/11/28/09/01cae078abe5fe320c88cdf4c220212688.gif?imageView/2/w/100/h/100';
next();
... ...
... ... @@ -301,8 +301,8 @@ const _getSkuDataByProductBaseInfo = (data) => {
goodsGroup.total = 0;
goodsGroup.thumbs = [];
goodsGroup.size = [];
if(goodsGroup.title.length > 20){
goodsGroup.title = goodsGroup.title.substr(0,20) + '...';
if (goodsGroup.title.length > 20) {
goodsGroup.title = goodsGroup.title.substr(0, 20) + '...';
}
}
... ...
... ... @@ -10,6 +10,7 @@
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta content="telephone=no" name="format-detection" />
<meta content="email=no" name="format-detection" />
<meta name="renderer" content="webkit">
{{#if devEnv}}
<link rel="stylesheet" href="//localhost:5002/css/index.css">
{{^}}
... ...
... ... @@ -21,19 +21,16 @@ module.exports = {
// api: 'http://api-test3.yohops.com:9999/',
// service: 'http://service-test3.yohops.com:9999/',
//
// api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/',
api: 'http://192.168.102.205:8080/gateway/',
// api: 'http://dev-api.yohops.com:9999/',
service: 'http://dev-service.yohops.com:9999/',
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
// api: 'http://192.168.102.205:8080/gateway/',
// service: 'http://dev-service.yohops.com:9999/',
search: 'http://192.168.102.216:8080/yohosearch/',
imSocket: 'ws://socket.yohobuy.com:10240',
imCs: 'http://im.yohobuy.com/api',
imServer: 'http://im.yohobuy.com/server'
imSocket: 'wss://imsocket.yohobuy.com:443',
imCs: 'https://imhttp.yohobuy.com/api',
imServer: 'https://imhttp.yohobuy.com/server'
},
subDomains: {
host: '.yohobuy.com',
... ...
const logger = global.yoho.logger;
const secretSwitch = () => {
return (req, res, next) => {
// 获取客服开关,读cache
global.yoho.cache.get('customerServiceSwitch').then(result => {
Object.assign(res.locals, {
customerServiceSwitch: result || false
});
next();
}).catch((err) => {
logger.error(err);
next();
});
};
};
module.exports = secretSwitch;
... ...
... ... @@ -189,7 +189,7 @@
</div>
<div class="left">
<span class="iconfont rgbf">&#xe602;</span>
<a href="http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&amp;configID=149091&amp;jid=8732423409" target="_blank">
<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">
<span class="red">便捷</span>
<span class="rgbf">在线客服</span>
</a>
... ...
{
"name": "yohobuy-node",
"version": "5.3.2",
"version": "5.3.3",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -51,8 +51,9 @@ var tipTpl = require('hbs/service/tip.hbs'),
var processInfo = {
scrollLoad: false,
manual: false,
promoter: 1, // 评论发起者 1:客户自己 2:客服
savedEval: false // 是否保存过评论
completeClose: false, // 评价完成后关闭
promoter: 1, // 评论发起者 1:客户自己 2:客服
savedEval: false // 是否保存过评论
};
var key,
... ... @@ -513,9 +514,12 @@ function pageInit() {
/**
* 显示评价弹框
*/
function showEvalModal(isclose) {
function showEvalModal(cptClose) {
var $evalModal = $('#makeEvaluation');
// 评价完成后关闭
processInfo.completeClose = cptClose;
// 没有接入人工
if (!processInfo.manual) {
return;
... ... @@ -552,11 +556,6 @@ function pageInit() {
if (res && res.code === 200) {
// 评价原因
len && discontentHtml(len, data);
if (isclose) {
// 评价完成后,是否关闭窗口
window.close();
}
}
$evalModal.modal('show');
}
... ... @@ -937,6 +936,11 @@ function pageInit() {
socketConfCM.type = allRTs.EVAL_NOTICE;
socketConfCM.uuid = uuid.v4();
socketChat.send(socketConfCM);
// 完成后关闭
if (processInfo.completeClose) {
window.close();
}
}
},
error: function() {
... ...