Authored by htoooth

Merge branch 'master' into release/5.9

... ... @@ -16,11 +16,19 @@ const index = co(function* (channel) {
const removeBlack = (remoteIp) => {
let key = `pc:limiter:${remoteIp}`,
key10m = `pc:limiter:10m:${remoteIp}`;
key10m = `pc:limiter:10m:${remoteIp}`,
keyMax = `pc:limiter:max:${remoteIp}`,
key10mMax = `pc:limiter:10m:max:${remoteIp}`,
synchronizeKey = `pc:limiter:synchronize:${remoteIp}`,
spiderKey = `pc:limiter:spider:${remoteIp}`;
return Promise.all([
cache.delAsync(key),
cache.delAsync(key10m)
cache.delAsync(key10m),
cache.delAsync(keyMax),
cache.delAsync(key10mMax),
cache.delAsync(synchronizeKey),
cache.delAsync(spiderKey)
]);
};
... ...
... ... @@ -122,7 +122,7 @@
税      号:
</span>
<div class="row-content">
<input id="company-tax-num" class="company-tax-num" type="text" placeholder="请输入纳税人识别号">
<input id="company-tax-num" class="company-tax-num" type="text" placeholder="请输入正确的纳税人识别号">
<span class="input-tip company-tax-tip red hide">
<span class="iconfont">&#xe629;</span>
<em>请填写纳税人识别号</em>
... ...
... ... @@ -295,7 +295,7 @@ module.exports = class extends global.yoho.BaseModel {
ht = `${params.keywords}`;
} else {
nav = _this._getNav(params.id, menuData, params.url);
ht = _.last(nav).name;
ht = _.get(_.last(nav), 'name', '');
}
return {
... ...
... ... @@ -42,11 +42,14 @@ const index = (req, res, next) => {
return res.render('search/no-result', resData);
}
Object.assign(resData, {
title: `${queryKey}价格_图片_品牌_怎么样-YOHO!BUY有货`,
keywords: `${queryKey},${queryKey}价格,${queryKey}图片,${queryKey}怎么样,${queryKey}品牌,YOHO!BUY有货`,
description: `YOHO!BUY有货网yohobuy.com是国内专业的${queryKey}网上潮流购物商城,为您找到${_.get(resData, 'search.totalCount', 0)}${queryKey}、产品的详细参数,实时报价,价格行情,图片、评价、品牌等信息。买${queryKey},就上YOHO!BUY有货` // eslint-disable-line
});
if (queryKey) {
Object.assign(resData, {
title: `${queryKey}价格_图片_品牌_怎么样-YOHO!BUY有货`,
keywords: `${queryKey},${queryKey}价格,${queryKey}图片,${queryKey}怎么样,${queryKey}品牌,YOHO!BUY有货`,
description: `YOHO!BUY有货网yohobuy.com是国内专业的${queryKey}网上潮流购物商城,为您找到${_.get(resData, 'search.totalCount', 0)}${queryKey}、产品的详细参数,实时报价,价格行情,图片、评价、品牌等信息。买${queryKey},就上YOHO!BUY有货` // eslint-disable-line
});
}
res.render('search/index', resData);
});
... ...
... ... @@ -11,7 +11,7 @@ module.exports = (url, width, height) => {
<a href="javascript:;" class="video-close-btn"></a>
<object id="video_0" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"
classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
<param value="http://rescdn.yohoboys.com/res/new/boys/swf/util/VideoPlayerNew.swf?id=video_0&amp;url=${url}&amp;language=1&amp;sharepic=http://img01.yohoboys.com/contentimg/2016/06/12/14/0183fabea5332c5902cdd1d0d7fb63df04.jpg?imageMogr2/thumbnail/738x424|watermark/1/image/aHR0cDovL3Jlc2Nkbi55b2hvYm95cy5jb20vcmVzL25ldy9ib3lzL2ltYWdlcy9iYW5uZXJwbGF5LnBuZw==/dissolve/100/gravity/Center/dx/10/dy/10&amp;title1=Meet...Cody Sanderson &amp;shareurl=http://www.yohoboys.com/channel/detail/index/id/10657/time/1478052894&amp;coverpic=http://img01.yohoboys.com/contentimg/2016/06/12/14/0183fabea5332c5902cdd1d0d7fb63df04.jpg"
<param value="//cdn.yoho.cn/tool/VideoPlayerNew.swf?id=video_0&amp;url=${url}&amp;language=1&amp;sharepic=http://img01.yohoboys.com/contentimg/2016/06/12/14/0183fabea5332c5902cdd1d0d7fb63df04.jpg?imageMogr2/thumbnail/738x424|watermark/1/image/aHR0cDovL3Jlc2Nkbi55b2hvYm95cy5jb20vcmVzL25ldy9ib3lzL2ltYWdlcy9iYW5uZXJwbGF5LnBuZw==/dissolve/100/gravity/Center/dx/10/dy/10&amp;title1=Meet...Cody Sanderson &amp;shareurl=http://www.yohoboys.com/channel/detail/index/id/10657/time/1478052894&amp;coverpic=http://img01.yohoboys.com/contentimg/2016/06/12/14/0183fabea5332c5902cdd1d0d7fb63df04.jpg"
name="movie">
<param value="high" name="quality">
<param value="#ffffff" name="bgcolor">
... ... @@ -21,7 +21,7 @@ module.exports = (url, width, height) => {
<embed style="width: ${width}px;height: ${height}px;" id="flash" align="middle" pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" loop="false"
play="true" bgcolor="#ffffff" quality="high" wmode="transparent" name="vMessage"
src="http://rescdn.yohoboys.com/res/new/boys/swf/util/VideoPlayerNew.swf?id=video_0&amp;url=${url}&amp;language=1&amp;sharepic=http://img01.yohoboys.com/contentimg/2016/06/12/14/0183fabea5332c5902cdd1d0d7fb63df04.jpg?imageMogr2/thumbnail/738x424|watermark/1/image/aHR0cDovL3Jlc2Nkbi55b2hvYm95cy5jb20vcmVzL25ldy9ib3lzL2ltYWdlcy9iYW5uZXJwbGF5LnBuZw==/dissolve/100/gravity/Center/dx/10/dy/10&amp;title1=Meet...Cody Sanderson &amp;shareurl=http://www.yohoboys.com/channel/detail/index/id/10657/time/1478052894&amp;coverpic=${url}?vframe/jpg/offset/0">
src="//cdn.yoho.cn/tool/VideoPlayerNew.swf?id=video_0&amp;url=${url}&amp;language=1&amp;sharepic=http://img01.yohoboys.com/contentimg/2016/06/12/14/0183fabea5332c5902cdd1d0d7fb63df04.jpg?imageMogr2/thumbnail/738x424|watermark/1/image/aHR0cDovL3Jlc2Nkbi55b2hvYm95cy5jb20vcmVzL25ldy9ib3lzL2ltYWdlcy9iYW5uZXJwbGF5LnBuZw==/dissolve/100/gravity/Center/dx/10/dy/10&amp;title1=Meet...Cody Sanderson &amp;shareurl=http://www.yohoboys.com/channel/detail/index/id/10657/time/1478052894&amp;coverpic=${url}?vframe/jpg/offset/0">
</object>
</div> `;
};
... ...
... ... @@ -64,7 +64,7 @@ const setSearchData = (result, params, channel) => {
_.get(finalResult, 'search.leftContent.sort', {}));
filters.checkedConditions.conditions = _.concat(filters.checkedConditions.conditions,
finalResult.search.leftContent.checked);
_.get(finalResult, 'search.leftContent.checked', []));
Object.assign(finalResult.search,
searchHandler.handlePathNavData({total: result[2].data.total }, params, 'search', channel),
... ...
... ... @@ -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);
}
... ... @@ -58,10 +63,11 @@ const domains = (req, res) => {
* @param next
*/
const history = (req, res, next) => {
const encId = aes.encryptionUid(req.user.uid);
const uid = req.user.uid;
const encId = aes.encryptionUid(uid);
const endTime = req.body.endTime;
clientApi.getMsgHistory(encId, endTime)
clientApi.getMsgHistory(uid, encId, endTime)
.then(result => {
res.json(result);
}).catch(next);
... ... @@ -74,7 +80,10 @@ const history = (req, res, next) => {
* @param next
*/
const saveEval = (req, res, next) => {
const params = {};
const uid = req.user.uid;
const params = {
uid
};
params.stars = req.body.stars;
params.promoter = req.body.promoter;
... ... @@ -102,9 +111,12 @@ const saveEval = (req, res, next) => {
* @param next
*/
const queryReason = (req, res, next) => {
const uid = req.user.uid;
const type = req.body.type;
const encryptedUid = aes.encryptionUid(uid);
clientApi.queryReason(type)
clientApi.queryReason(uid, encryptedUid, type)
.then(result => {
res.json(result);
}).catch(next);
... ... @@ -117,11 +129,12 @@ const queryReason = (req, res, next) => {
* @param next
*/
const saveMessage = (req, res, next) => {
const uid = req.user.uid;
const content = req.body.content;
const encId = req.body.encryptedUid;
const cvId = req.body.conversationId;
clientApi.saveMessage(content, encId, cvId)
clientApi.saveMessage(content, encId, cvId, uid)
.then(result => {
res.json(result);
}).catch(next);
... ...
... ... @@ -32,8 +32,9 @@ let urls = {
* @param { string } encryptedUid 用户ID
* @return { Object } 最近10条订单
*/
const getLastTenOrders = (encryptedUid) => {
const getLastTenOrders = (uid, encryptedUid) => {
return api.post(urls.lastTen, {
uid,
encryptedUid
});
};
... ... @@ -43,8 +44,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
});
};
/**
... ... @@ -65,8 +69,10 @@ const getCsSetting = (type) => {
* @param { string } endTime 截止时间
* @return { Array } 历史聊天记录
*/
const getMsgHistory = (encryptedUid, endTime) => {
const getMsgHistory = (uid, encryptedUid, endTime) => {
let params = {
uid,
encryptedUid
};
... ... @@ -91,9 +97,11 @@ const saveEval = (params) => {
* @param cvId
* @returns {*}
*/
const queryReason = (type) => {
const queryReason = (uid, encryptedUid, type) => {
const params = {
type
uid,
type,
encryptedUid
};
return api.post(urls.evalReason, params);
... ... @@ -106,8 +114,9 @@ const queryReason = (type) => {
* @param cvId 会话ID
* @returns {*}
*/
const saveMessage = (content, encId, cvId) => {
const saveMessage = (content, encId, cvId, uid) => {
const params = {
uid,
content,
encryptedUid: encId,
conversationId: cvId
... ...
... ... @@ -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';
... ... @@ -25,9 +25,9 @@ const getClientData = (type, encryptedUid) => {
let apiMethod = [
clientAPI.getCsSetting(type),
clientAPI.getMsgHistory(encryptedUid),
clientAPI.getLastTenOrders(encryptedUid),
clientAPI.getQas()
clientAPI.getMsgHistory(uid, encryptedUid),
clientAPI.getLastTenOrders(uid, encryptedUid),
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;
... ...
... ... @@ -5,6 +5,7 @@ const logger = global.yoho.logger;
const ip = require('./rules/ip-list');
const userAgent = require('./rules/useragent');
const qpsLimiter = require('./rules/qps-limit');
const asynchronous = require('./rules/asynchronous');
// const fakerLimiter = require('./rules/faker-limit');
const captchaPolicy = require('./policies/captcha');
... ... @@ -53,7 +54,8 @@ module.exports = (req, res, next) => {
Promise.all([
limiter(userAgent, captchaPolicy, context),
limiter(ip, captchaPolicy, context),
limiter(qpsLimiter, captchaPolicy, context)
limiter(qpsLimiter, captchaPolicy, context),
limiter(asynchronous, captchaPolicy, context)
// limiter(fakerLimiter, reporterPolicy, context)
]).then((results) => {
... ...
'use strict';
const cache = global.yoho.cache.master;
const _ = require('lodash');
const logger = global.yoho.logger;
const ASYNCHRONOUSPAGES = {
'/product/index/isFavoriteShop': 1,
'/common/suggestfeedback': 1,
'/product/detail/hotarea': 1,
'/common/getbanner': 1,
'/passport/cert/headerTip': 1
};
function isNormalSpider(userAgent) {
let normalReg = /(spider)|(bot.html)/i;
if (normalReg.test(userAgent)) {
return true;
} else {
return false;
}
}
module.exports = (limiter, policy) => {
const ua = limiter.req.header('User-Agent');
const synchronizeKey = `pc:limiter:synchronize:${limiter.remoteIp}`; // 同步
const asynchronousKey = `pc:limiter:asynchronous:${limiter.remoteIp}`; // 异步
const spiderKey = `pc:limiter:spider:${limiter.remoteIp}`; // 异步
// 正常蜘蛛直接过
if (isNormalSpider(ua)) {
return Promise.resolve(true);
}
const req = limiter.req,
res = limiter.res;
res.on('render', function() {
cache.incrAsync(synchronizeKey, 1).catch(e=>console.log(e)); // eslint-disable-line
});
return cache.getMultiAsync([synchronizeKey, asynchronousKey, spiderKey]).then((results) => {
logger.debug(results);
if (results[spiderKey]) {
return Promise.resolve(policy);
}
// 默认数据设置
if (!results[synchronizeKey] && !_.isNumber(results[synchronizeKey])) {
cache.setAsync(synchronizeKey, 1, 600);
}
// 默认数据设置
if (ASYNCHRONOUSPAGES[req.path] > 0) {
cache.setAsync(asynchronousKey, 1, 600);
cache.setAsync(synchronizeKey, 1, 600);
}
if (results[synchronizeKey] > 10 && !results[asynchronousKey]) {
cache.setAsync(spiderKey, 1, 60 * 60 * 24);
return Promise.resolve(policy);
}
return Promise.resolve(true);
});
};
... ...
{
"name": "yohobuy-node",
"version": "5.8.4",
"version": "5.8.7",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -237,6 +237,7 @@ function _loadPage() {
// 接入人工客服需要评价
processInfo.manual = true;
processInfo.savedEval = false;
// 显示评价&隐藏人工
edit.setIcons({
... ... @@ -607,6 +608,12 @@ function _loadPage() {
serviceApi.history(data)
.done(function(res) {
if (res && res.code === 401) {
window.onbeforeunload = null;
return location.href = '//www.yohobuy.com/signin.html?refer=' + // eslint-disable-line
encodeURIComponent(location.href);
}
if (res && res.code === 200) {
if (processInfo.hasMore) {
msgList = res.data.records || [];
... ... @@ -690,7 +697,13 @@ function _loadPage() {
encryptedUid: encryptedUid,
conversationId: socketConfCM.conversationId
})
.done(function() {})
.done(function(res) {
if (res && res.code === 401) {
window.onbeforeunload = null;
return location.href = '//www.yohobuy.com/signin.html?refer=' + // eslint-disable-line
encodeURIComponent(location.href);
}
})
.always(function() {
lMsg.modal('hide');
});
... ...
... ... @@ -36,6 +36,12 @@ var _fetchReason = (function() {
type: YOHO_CS
})
.done(function(res) {
if (res && res.code === 401) {
window.onbeforeunload = null;
return location.href = '//www.yohobuy.com/signin.html?refer=' + // eslint-disable-line
encodeURIComponent(location.href);
}
if (res.code === 200) {
cache = res.data;
render(cache);
... ... @@ -131,6 +137,12 @@ function _evalSubmit() {
$btnEval.hide();
processSign.savedEval = true;
if (res && res.code === 401) {
window.onbeforeunload = null;
return location.href = '//www.yohobuy.com/signin.html?refer=' + // eslint-disable-line
encodeURIComponent(location.href);
}
if (res && res.code === 200) {
send.completeEval();
self.close();
... ...
... ... @@ -1675,7 +1675,7 @@
}
input {
width: 210px;
width: 220px;
height: 30px;
padding: 0 10px;
background: #f5f5f5;
... ...
User-Agent: *
Disallow: /*?*
Disallow: /passport/
Disallow: /help
Disallow: signin.html
... ...