Authored by 陈峰

Merge branch 'release/0606' into 'gray'

Release/0606



See merge request !1428
... ... @@ -11,27 +11,30 @@ class Hot extends global.yoho.BaseModel {
super(ctx);
}
list(params) {
let options = {
data: {
method: 'web.search.forseo',
sales: params.sales,
outlets: params.outlets,
stocknumber: params.stocknumber,
need_filter: params.need_filter,
query: params.query,
type: params.type,
page: params.page || 1,
limit: params.limit || 24,
order: params.order || 0
},
list(params, sort) {
let data = {
method: 'web.search.forseo',
sales: params.sales,
outlets: params.outlets,
stocknumber: params.stocknumber,
need_filter: params.need_filter,
query: params.query,
type: params.type,
page: params.page || 1,
limit: params.limit || 24,
order: params.order || 0
};
if (sort) {
delete data.query;
data.sort = sort;
}
return this.get({
data: data,
param: {
code: 200
}
};
return this.get(options).then(result => {
return result;
});
}
... ... @@ -57,6 +60,14 @@ class Hot extends global.yoho.BaseModel {
let redisData = JSON.parse(result[0][0]);
return this.list(Object.assign(params, {query: redisData.name})).then(listData => {
let sort = redisData.sort_id;
if (!sort || _.get(listData, 'data.total') > 0) {
return listData;
}
return this.list(params, sort);
}).then(listData => {
_.forEach(_.slice(redisData.data, 0, 12), value => {
build.push({
name: value.keyword,
... ...
... ... @@ -10,6 +10,7 @@ const sender = global.yoho.apmSender;
const config = global.yoho.config;
const hostname = require('os').hostname();
const routeEncode = require('./route-encode');
const pathWhiteList = require('./limiter/rules/path-white-list');
const _ = require('lodash');
const forceNoCache = (res) => {
... ... @@ -125,11 +126,13 @@ exports.serverError = () => {
udid,
code: err.code || 500,
path: `[${req.method}]${routeEncode.getRouter(req)}`,
url: encodeURIComponent(req.originalUrl)
url: encodeURIComponent(req.originalUrl),
ip: _.get(req, 'yoho.clientIp', '')
},
fields: {
message: err.message,
stack: err.stack
stack: err.stack,
useragent: req && req.get('user-agent')
}
});
}
... ... @@ -161,32 +164,34 @@ exports.serverError = () => {
}));
}
} else if (err.code === 9999991 || err.code === 9999992) {
let remoteIp = req.yoho.clientIp;
if (!_.includes(pathWhiteList(), req.path)) {
let remoteIp = req.yoho.clientIp;
const isHuman = await cache.getAsync(`${config.app}:limiter:api:ishuman:${remoteIp}`);
const isHuman = await cache.getAsync(`${config.app}:limiter:api:ishuman:${remoteIp}`);
if (!isHuman) {
if (remoteIp.indexOf(',') > 0) {
let arr = remoteIp.split(',');
if (!isHuman) {
if (remoteIp.indexOf(',') > 0) {
let arr = remoteIp.split(',');
remoteIp = arr[0];
}
cache.setAsync(`${config.app}:limiter:${remoteIp}`, 1, config.LIMITER_IP_TIME);
let limitAPI = helpers.urlFormat('/3party/check', {refer: req.get('Referer') || ''});
let limitPage = helpers.urlFormat('/3party/check', {
refer: req.protocol + '://' + req.get('host') + req.originalUrl
});
remoteIp = arr[0];
}
cache.setAsync(`${config.app}:limiter:${remoteIp}`, 1, config.LIMITER_IP_TIME);
req.session.apiLimitValidate = true;
if (req.xhr) {
return res.status(510).json({
code: err.code,
data: {refer: limitAPI}
let limitAPI = helpers.urlFormat('/3party/check', {refer: req.get('Referer') || ''});
let limitPage = helpers.urlFormat('/3party/check', {
refer: req.protocol + '://' + req.get('host') + req.originalUrl
});
}
return res.redirect(limitPage);
req.session.apiLimitValidate = true;
if (req.xhr) {
return res.status(510).json({
code: err.code,
data: {refer: limitAPI}
});
}
return res.redirect(limitPage);
}
}
return _err510(req, res, 510, err);
... ...
... ... @@ -5,6 +5,7 @@ const logger = global.yoho.logger;
const ip = require('./rules/ip-list');
const userAgent = require('./rules/useragent');
const ipWhiteList = require('./rules/ip-white-list');
const pathWhiteList = require('./rules/path-white-list');
const qpsLimiter = require('./rules/qps-limit');
const co = Promise.coroutine;
... ... @@ -32,31 +33,6 @@ const IP_WHITE_SEGMENT = [
'10.66.', // 内网IP段
'192.168.' // 内网IP段
];
const PATH_WHITE_LIST = [
'/3party/check',
'/3party/check/submit',
'/passport/captcha/get',
'/passport/img-check.jpg',
'/passport/geetest/register',
'/activity/individuation',
'/activity/individuation/coupon',
'/activity/share',
'/activity/wechat/share',
'/activity/wechat/1111',
'/api/switch',
'/passport/login/user',
'/sw.js',
'/manifest.json',
'/activity/sw.js',
'/activity/manifest.json',
'/hfxRaNY27L.txt',
'/activity/hfxRaNY27L.txt',
'/product/shop/hfxRaNY27L.txt',
'/product/hfxRaNY27L.txt',
'/.well-known/apple-app-site-association',
'/service/sitemap.xml',
'/node/status.html'
];
const limiter = (rule, policy, context) => {
return rule(context, policy);
... ... @@ -74,7 +50,7 @@ const _excluded = (req) => {
atWhiteList ||
_.includes(IP_WHITE_LIST, remoteIp) ||
_.includes(IP_WHITE_SEGMENT, remoteIpSegment) ||
_.includes(PATH_WHITE_LIST, req.path) ||
_.includes(pathWhiteList(), req.path) ||
req.xhr ||
!_.isEmpty(_.get(req, 'user.uid'))
);
... ...
const _ = require('lodash');
const logger = global.yoho.logger;
const cache = global.yoho.cache.master;
const WHITE_LIST_KEY = 'wap:limiter:whitelist:path';
const DEFAULT_PATH_WHITE_LIST = [
'/3party/check',
'/3party/check/submit',
'/passport/captcha/get',
'/passport/img-check.jpg',
'/passport/geetest/register',
'/activity/individuation',
'/activity/individuation/coupon',
'/activity/share',
'/activity/wechat/share',
'/activity/wechat/1111',
'/api/switch',
'/passport/login/user',
'/sw.js',
'/manifest.json',
'/activity/sw.js',
'/activity/manifest.json',
'/hfxRaNY27L.txt',
'/activity/hfxRaNY27L.txt',
'/product/shop/hfxRaNY27L.txt',
'/product/hfxRaNY27L.txt',
'/.well-known/apple-app-site-association',
'/service/sitemap.xml',
'/node/status.html',
'/product/seckill',
'/product/seckill/list',
'/product/seckill/remind',
'/product/seckill/get-product-list'
];
const cacheWhiteList = {
nowTime() {
return Date.parse(new Date()) / 1000;
},
getValue() {
if (this.updateTime || this.nowTime() - this.updateTime > 60 * 10) {
this.syncRemoteConfig();
}
return _.uniq(_.concat([], DEFAULT_PATH_WHITE_LIST, _.toArray(this.whiteList)));
},
syncRemoteConfig() {
if (this.syncing) {
return;
}
this.syncing = true;
cache.getAsync(WHITE_LIST_KEY).then(res => {
this.updateTime = this.nowTime();
if (!res) {
return;
}
this.whiteList = JSON.parse(res);
this.syncing = false;
}).catch((e) => {
this.syncing = false;
logger.debug('whitelist path parse error. ' + JSON.stringfy(e));
});
}
};
module.exports = () => {
return cacheWhiteList.getValue();
};
... ...
... ... @@ -19,13 +19,13 @@ module.exports = (limiter, policy) => {
let whitelist = [];
try {
blacklist = JSON.parse(args[0]);
blacklist = JSON.parse(args[0]) || [];
} catch (error) {
logger.error(error);
}
try {
whitelist = JSON.parse(args[1]);
whitelist = JSON.parse(args[1]) || [];
} catch (error) {
logger.error(error);
}
... ...
... ... @@ -30,14 +30,14 @@
window._yohoAppName = 'yohobuywap-node';
window._router = '{{_router}}';
!function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")});var n=r(13),o=r(14);n.init(),o.init()},function(e,t){e.exports=function(e,t,r){if(void 0===t){var n=null;if(document.cookie)for(var o=document.cookie.split(";"),i=0;i<o.length;i++){var d=(o[i]||"").trim();if(d.substring(0,e.length+1)==e+"="){n=decodeURIComponent(d.substring(e.length+1));break}}return n}r=r||{},null===t&&(t="",r.expires=-1);var a="";if(r.expires&&("number"==typeof r.expires||r.expires.toUTCString)){var u;"number"==typeof r.expires?(u=new Date,u.setTime(u.getTime()+24*r.expires*60*60*1e3)):u=r.expires,a="; expires="+u.toUTCString()}var p=r.path?"; path="+r.path:"",s=r.domain?"; domain="+r.domain:"",c=r.secure?"; secure":"";document.cookie=[e,"=",encodeURIComponent(t),a,p,s,c].join("")}},,function(e,t,r){var n=r(1),o=window._yohoAppName||"unknown",i={config:{reportUrl:"//badjs.yoho.cn/apm/yas2.gif"},stringify:function(e){for(var t=[],r=0;r<e.length;r++){var n=e[r],o=[];for(var i in n)n.hasOwnProperty(i)&&o.push(i+"::"+n[i]);t.push(o.join("$$"))}return t.join("**")},report:function(e,t){if(e){(new Image).src=this.config.reportUrl+"?s="+o+"&l="+e+"&t="+(new Date).getTime(),t&&t()}},getUdid:function(){return n("udid")||""||0},getUid:function(){return(n("_UID")||"").split("::")[1]||0},getReqId:function(){return n("docreqid")||0},getRoute:function(){return window._router||""}};e.exports=i},,,,,,,,,,function(e,t,r){var n=r(1),o=r(3),i="_errLog",d={writeError:function(e,t,r,d,a){var u=JSON.parse(n(i)||"[]");u.push({tp:"err",msg:e,sc:t,ln:r,cn:d,pt:encodeURIComponent(location.href),u:o.getUid(),ud:o.getUdid(),rid:o.getReqId(),st:JSON.stringify(a&&a.stack),r:o.getRoute()}),n(i,JSON.stringify(u)),u.length>=5&&this.reportError()},clearError:function(){n(i,"[]")},reportError:function(){var e=this,t=JSON.parse(n(i)||"[]"),r=o.stringify(t);o.report(r,function(){e.clearError()})},init:function(){var e=this;window.onerror=function(t,r,n,o,i){e.writeError(t,r,n,o,i)},this.reportError()}};e.exports=d},function(e,t,r){function n(e){var t=e.offsetTop;return null!==e.offsetParent&&(t+=n(e.offsetParent)),t}var o=r(3),i=window.screen.height,d=[],a=!1,u=!1,p=0,s=setInterval(function(){var e,t;if(a){if(d.length)for(e=0;e<d.length;e++){if(t=d[e],!t.complete){u=!1;break}u=!0}else u=!0;u&&(p=(new Date).getTime()-_timeStart,clearInterval(s))}else{var r=document.body&&document.body.querySelectorAll("img")||[];for(e=0;e<r.length;e++){t=r[e];var o=n(t);if(o>i){a=!0;break}o<=i&&!t.hasPushed&&(t.hasPushed=1,d.push(t))}}},0),c={reportTime:function(e){var t=o.stringify(e);o.report(t)},addEvent:function(){var e=this,t=[],r=encodeURIComponent(location.href),n=o.getUid(),i=o.getUdid(),d=o.getReqId(),c=window.performance&&window.performance.timing.navigationStart||0,f=o.getRoute();_timeStart=window._timeStart||0,document.addEventListener&&document.addEventListener("DOMContentLoaded",function(e){t.push({tp:"dcl",t:(new Date).getTime()-_timeStart,pt:r,u:n,ud:i,rid:d,r:f}),(document.body&&document.body.querySelectorAll("img")||[]).length||(a=!0)},!1),window.addEventListener&&window.addEventListener("load",function(o){t.push({tp:"ld",t:(new Date).getTime()-_timeStart,pt:r,u:n,ud:i,rid:d,r:f}),u=!0,a=!0,s&&clearInterval(s),p&&t.push({tp:"fs",t:p,pt:r,u:n,ud:i,rid:d,r:f}),t.push({tp:"pf",dcl:(window.performance&&window.performance.timing.domComplete||0)-c,ld:(window.performance&&window.performance.timing.loadEventStart||0)-c,pt:r,u:n,ud:i,rid:d,r:f}),e.reportTime(t)},!1)},init:function(){this.addEvent()}};e.exports=c}]);
!function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};t.m=e,t.c=r,t.p="",t(0)}({0:function(e,t,r){String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")});var n=r(16),o=r(19);n.init(),o.init()},1:function(e,t){e.exports=function(e,t,r){if(void 0===t){var n=null;if(document.cookie)for(var o=document.cookie.split(";"),i=0;i<o.length;i++){var a=(o[i]||"").trim();if(a.substring(0,e.length+1)==e+"="){n=decodeURIComponent(a.substring(e.length+1));break}}return n}r=r||{},null===t&&(t="",r.expires=-1);var d="";if(r.expires&&("number"==typeof r.expires||r.expires.toUTCString)){var u;"number"==typeof r.expires?(u=new Date,u.setTime(u.getTime()+24*r.expires*60*60*1e3)):u=r.expires,d="; expires="+u.toUTCString()}var c=r.path?"; path="+r.path:"",p=r.domain?"; domain="+r.domain:"",s=r.secure?"; secure":"";document.cookie=[e,"=",encodeURIComponent(t),d,c,p,s].join("")}},2:function(e,t,r){var n=r(1),o=window._yohoAppName||"unknown",i={config:{reportUrl:"//badjs.yoho.cn/apm/yas2.gif"},stringify:function(e){for(var t=[],r=0;r<e.length;r++){var n=e[r],o=[];for(var i in n)n.hasOwnProperty(i)&&o.push(i+"::"+n[i]);t.push(o.join("$$"))}return t.join("**")},report:function(e,t){if(e){(new Image).src=this.config.reportUrl+"?s="+o+"&l="+e+"&t="+(new Date).getTime(),t&&t()}},getUdid:function(){return n("udid")||""||0},getUid:function(){return(n("_UID")||"").split("::")[1]||0},getReqId:function(){return n("docreqid")||0},getRoute:function(){return window._router||""}};e.exports=i},3:function(e,t){e.exports=function(e,t){if(void 0===t){var t=null;return window.localStorage&&(t=window.localStorage.getItem(e)),t}window.localStorage&&window.localStorage.setItem(e,t)}},16:function(e,t,r){var n=r(3),o=r(2),i="_errLog",a={writeError:function(e,t,r,a,d){var u=JSON.parse(n(i)||"[]");u.push({tp:"err",msg:e,sc:t,ln:r,cn:a,pt:encodeURIComponent(location.href),u:o.getUid(),ud:o.getUdid(),rid:o.getReqId(),st:JSON.stringify(d&&d.stack),r:o.getRoute()}),n(i,JSON.stringify(u)),u.length>=3&&this.reportError()},clearError:function(){n(i,"[]")},reportError:function(){var e=this,t=JSON.parse(n(i)||"[]"),r=o.stringify(t);o.report(r,function(){e.clearError()})},init:function(){var e=this;window.onerror=function(t,r,n,o,i){e.writeError(t,r,n,o,i)},this.reportError()}};e.exports=a},19:function(e,t,r){function n(e){var t=e.offsetTop;return null!==e.offsetParent&&(t+=n(e.offsetParent)),t}var o=r(2),i=window.screen.height,a=[],d=!1,u=!1,c=0,p=setInterval(function(){var e,t;if(d){if(a.length)for(e=0;e<a.length;e++){if(t=a[e],!t.complete){u=!1;break}u=!0}else u=!0;u&&(c=(new Date).getTime()-_timeStart,clearInterval(p))}else{var r=document.body&&document.body.querySelectorAll("img")||[];for(e=0;e<r.length;e++){t=r[e];var o=n(t);if(o>i){d=!0;break}o<=i&&!t.hasPushed&&(t.hasPushed=1,a.push(t))}}},0),s={reportTime:function(e){var t=o.stringify(e);o.report(t)},addEvent:function(){var e=this,t=[],r=encodeURIComponent(location.href),n=o.getUid(),i=o.getUdid(),a=o.getReqId(),s=window.performance&&window.performance.timing.navigationStart||0,f=o.getRoute();_timeStart=window._timeStart||0,document.addEventListener&&document.addEventListener("DOMContentLoaded",function(e){t.push({tp:"dcl",t:(new Date).getTime()-_timeStart,pt:r,u:n,ud:i,rid:a,r:f}),(document.body&&document.body.querySelectorAll("img")||[]).length||(d=!0)},!1),window.addEventListener&&window.addEventListener("load",function(o){t.push({tp:"ld",t:(new Date).getTime()-_timeStart,pt:r,u:n,ud:i,rid:a,r:f}),u=!0,d=!0,p&&clearInterval(p),c&&t.push({tp:"fs",t:c,pt:r,u:n,ud:i,rid:a,r:f}),t.push({tp:"pf",dcl:(window.performance&&window.performance.timing.domComplete||0)-s,ld:(window.performance&&window.performance.timing.loadEventStart||0)-s,pt:r,u:n,ud:i,rid:a,r:f}),e.reportTime(t)},!1)},init:function(){this.addEvent()}};e.exports=s}});
{{/ifand}}
</script>
<script>
{{#ifand isProduction wap.open.webperf}}
!function(t){function n(r){if(e[r])return e[r].exports;var i=e[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}var e={};n.m=t,n.c=e,n.p="",n(0)}({0:function(t,n,e){var r=e(1),i=e(2),o="_perfLog",a=e(16),c=e(17);({init:function(t){this.debug=t,this.dataList=[],this.isRunning=!1,a.init(this.debug),c.init(this.debug),this.report();var n=this;window.addEventListener&&window.addEventListener("load",function(){setTimeout(function(){n.collect()},0)})},collect:function(){try{var t=c.collect(),n=a.collect();this.chunkWrite(t);for(var e=0;e<n.length;e++)this.chunkWrite(n[e])}catch(t){this.debug&&console.log(t)}},getMeta:function(){return{pt:encodeURIComponent(window.location.href),u:i.getUid(),ud:i.getUdid(),rid:i.getReqId(),r:i.getRoute()}},jsonConcat:function(t,n){for(var e in n)t[e]=n[e];return t},write:function(t){this.jsonConcat(t,this.getMeta());var n=JSON.parse(r(o)||"[]");n.push(t),r(o,JSON.stringify(n)),n.length>=5&&this.report()},report:function(){var t=this,n=JSON.parse(r(o)||"[]"),e=i.stringify(n);i.report(e,function(){t.clear()})},clear:function(){r(o,"[]")},chunkWrite:function(t){function n(){if(0!==e.dataList.length){var t=e.dataList.shift();e.write(t),setTimeout(n,10)}}var e=this;this.dataList.push(t),this.isRunning||(this.isRunning=!0,n())}}).init()},1:function(t,n){t.exports=function(t,n,e){if(void 0===n){var r=null;if(document.cookie)for(var i=document.cookie.split(";"),o=0;o<i.length;o++){var a=(i[o]||"").trim();if(a.substring(0,t.length+1)==t+"="){r=decodeURIComponent(a.substring(t.length+1));break}}return r}e=e||{},null===n&&(n="",e.expires=-1);var c="";if(e.expires&&("number"==typeof e.expires||e.expires.toUTCString)){var s;"number"==typeof e.expires?(s=new Date,s.setTime(s.getTime()+24*e.expires*60*60*1e3)):s=e.expires,c="; expires="+s.toUTCString()}var u=e.path?"; path="+e.path:"",f=e.domain?"; domain="+e.domain:"",d=e.secure?"; secure":"";document.cookie=[t,"=",encodeURIComponent(n),c,u,f,d].join("")}},2:function(t,n,e){var r=e(1),i=window._yohoAppName||"unknown",o={config:{reportUrl:"//badjs.yoho.cn/apm/yas2.gif"},stringify:function(t){for(var n=[],e=0;e<t.length;e++){var r=t[e],i=[];for(var o in r)r.hasOwnProperty(o)&&i.push(o+"::"+r[o]);n.push(i.join("$$"))}return n.join("**")},report:function(t,n){if(t){(new Image).src=this.config.reportUrl+"?s="+i+"&l="+t+"&t="+(new Date).getTime(),n&&n()}},getUdid:function(){return r("udid")||""||0},getUid:function(){return(r("_UID")||"").split("::")[1]||0},getReqId:function(){return r("docreqid")||0},getRoute:function(){return window._router||""}};t.exports=o},16:function(t,n){var e={init:function(t){if(this.enable=!0,this.debug=t,!("performance"in window&&"getEntriesByType"in window.performance&&window.performance.getEntriesByType("resource")instanceof Array))return void(this.enable=!1);this.whiteList=[/\/\/img\d*.static.yhbimg.com/,/\/\/cdn.yoho.cn/]},print:function(){var t=document.getElementById("debug"),n=this.formatDebugInfo();if(t)t.innerHTML+=n;else{var e=document.createElement("div");e.id="debug",e.innerHTML=n,document.body.appendChild(e)}},formatDebugInfo:function(){for(var t="<p>resource object: <br/>",n=this.getData(),e=0;e<n.length;e++)t+=JSON.stringify(n[e],null,2)+"<br/>";return t+="</p>"},filter:function(t){for(var n=0;n<this.whiteList.length;n++)if(this.whiteList[n].test(t))return!0;return!1},getData:function(){var t=window.performance.getEntriesByType("resource"),n=[],e={};for(var r in t){var i=t[r];if(this.filter(i.name)){var o={tp:"resource",mtp:i.initiatorType||"unknown",id:i.name||"unknown",dt:Math.floor(i.domainLookupEnd-i.domainLookupStart||0),tt:Math.floor(i.connectEnd-i.connectStart||0),rt:Math.floor(i.responseEnd-i.responseStart||0),rrt:Math.floor(i.responseEnd-i.fetchStart||0)};i.initiatorType in e?e[i.initiatorType].push(o):e[i.initiatorType]=[o]}}for(var a in e){for(var c=e[a],s=c.length,u={tp:"rs",mtp:a,dt:0,tt:0,rt:0,rrt:0},f=0;f<c.length;f++){var d=c[f];u.dt+=d.dt,u.tt+=d.tt,u.rt+=d.rt,u.rrt+=d.rrt}u.dt=Math.floor(u.dt/s),u.tt=Math.floor(u.tt/s),u.rt=Math.floor(u.rt/s),u.rrt=Math.floor(u.rrt/s),n.push(u)}return n},collect:function(){return this.enable?(this.debug&&this.print(),this.getData()):[]}};t.exports=e},17:function(t,n){var e=function(){function t(){return{tp:"tm",mtp:"html",dt:Math.floor(n),tt:Math.floor(e),rt:Math.floor(r),domt:Math.floor(o),et:Math.floor(i),ot:Math.floor(a),rtt:Math.floor(c),sw:screen.width||1,sh:screen.height||1,pf:navigator.platform||"unknown"}}var n=performance.timing.domainLookupEnd-(performance.timing.domainLookupStart||0),e=performance.timing.connectEnd-(performance.timing.connectStart||0),r=performance.timing.responseEnd-(performance.timing.responseStart||0),i=performance.timing.responseStart-(performance.timing.navigationStart||0),o=performance.timing.domContentLoadedEventEnd-(performance.timing.domLoading||0),a=performance.timing.domContentLoadedEventEnd-(performance.timing.navigationStart||0),c=(performance.timing.loadEventEnd||performance.timing.domComplete)-(performance.timing.navigationStart||0);return{collect:function(){return t()},print:function(){var t=document.getElementById("debug"),n=this.formatDebugInfo();if(t)t.innerHTML+=n;else{var e=document.createElement("div");e.id="debug",e.innerHTML=n,document.body.appendChild(e)}},formatDebugInfo:function(){var t="<p>";return t+="timing object : "+JSON.stringify(this.collect(),null,2)+"<br/>",t+="url: "+decodeURIComponent(window.location.href)+"<br/>",t+="</p>"}}},r={init:function(t){if(this.enable=!0,this.debug=t,!("performance"in window))return void(this.enable=!1)},collect:function(){if(this.enable){var t=e(),n=t.collect();return this.debug&&t.print(),n}}};t.exports=r}});
!function(t){function n(r){if(e[r])return e[r].exports;var i=e[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}var e={};n.m=t,n.c=e,n.p="",n(0)}([function(t,n,e){var r=e(3),i=e(2),o="_perfLog",a=e(17),c=e(18);({init:function(t){this.debug=t,this.dataList=[],this.isRunning=!1,a.init(this.debug),c.init(this.debug),this.report();var n=this;window.addEventListener&&window.addEventListener("load",function(){setTimeout(function(){n.collect()},0)})},collect:function(){try{var t=c.collect(),n=a.collect();this.chunkWrite(t);for(var e=0;e<n.length;e++)this.chunkWrite(n[e])}catch(t){this.debug&&console.log(t)}},getMeta:function(){return{pt:encodeURIComponent(window.location.href),u:i.getUid(),ud:i.getUdid(),rid:i.getReqId(),r:i.getRoute()}},jsonConcat:function(t,n){for(var e in n)t[e]=n[e];return t},write:function(t){this.jsonConcat(t,this.getMeta());var n=JSON.parse(r(o)||"[]");n.push(t),r(o,JSON.stringify(n)),n.length>=3&&this.report()},report:function(){var t=this,n=JSON.parse(r(o)||"[]"),e=i.stringify(n);i.report(e,function(){t.clear()})},clear:function(){r(o,"[]")},chunkWrite:function(t){function n(){if(0!==e.dataList.length){var t=e.dataList.shift();e.write(t),setTimeout(n,10)}}var e=this;this.dataList.push(t),this.isRunning||(this.isRunning=!0,n())}}).init()},function(t,n){t.exports=function(t,n,e){if(void 0===n){var r=null;if(document.cookie)for(var i=document.cookie.split(";"),o=0;o<i.length;o++){var a=(i[o]||"").trim();if(a.substring(0,t.length+1)==t+"="){r=decodeURIComponent(a.substring(t.length+1));break}}return r}e=e||{},null===n&&(n="",e.expires=-1);var c="";if(e.expires&&("number"==typeof e.expires||e.expires.toUTCString)){var u;"number"==typeof e.expires?(u=new Date,u.setTime(u.getTime()+24*e.expires*60*60*1e3)):u=e.expires,c="; expires="+u.toUTCString()}var s=e.path?"; path="+e.path:"",f=e.domain?"; domain="+e.domain:"",d=e.secure?"; secure":"";document.cookie=[t,"=",encodeURIComponent(n),c,s,f,d].join("")}},function(t,n,e){var r=e(1),i=window._yohoAppName||"unknown",o={config:{reportUrl:"//badjs.yoho.cn/apm/yas2.gif"},stringify:function(t){for(var n=[],e=0;e<t.length;e++){var r=t[e],i=[];for(var o in r)r.hasOwnProperty(o)&&i.push(o+"::"+r[o]);n.push(i.join("$$"))}return n.join("**")},report:function(t,n){if(t){(new Image).src=this.config.reportUrl+"?s="+i+"&l="+t+"&t="+(new Date).getTime(),n&&n()}},getUdid:function(){return r("udid")||""||0},getUid:function(){return(r("_UID")||"").split("::")[1]||0},getReqId:function(){return r("docreqid")||0},getRoute:function(){return window._router||""}};t.exports=o},function(t,n){t.exports=function(t,n){if(void 0===n){var n=null;return window.localStorage&&(n=window.localStorage.getItem(t)),n}window.localStorage&&window.localStorage.setItem(t,n)}},,,,,,,,,,,,,,function(t,n){var e={init:function(t){if(this.enable=!0,this.debug=t,!("performance"in window&&"getEntriesByType"in window.performance&&window.performance.getEntriesByType("resource")instanceof Array))return void(this.enable=!1);this.whiteList=[/\/\/img\d*.static.yhbimg.com/,/\/\/cdn.yoho.cn/]},print:function(){var t=document.getElementById("debug"),n=this.formatDebugInfo();if(t)t.innerHTML+=n;else{var e=document.createElement("div");e.id="debug",e.innerHTML=n,document.body.appendChild(e)}},formatDebugInfo:function(){for(var t="<p>resource object: <br/>",n=this.getData(),e=0;e<n.length;e++)t+=JSON.stringify(n[e],null,2)+"<br/>";return t+="</p>"},filter:function(t){for(var n=0;n<this.whiteList.length;n++)if(this.whiteList[n].test(t))return!0;return!1},getData:function(){var t=window.performance.getEntriesByType("resource"),n=[],e={};for(var r in t){var i=t[r];if(this.filter(i.name)){var o={tp:"resource",mtp:i.initiatorType||"unknown",id:i.name||"unknown",dt:Math.floor(i.domainLookupEnd-i.domainLookupStart||0),tt:Math.floor(i.connectEnd-i.connectStart||0),rt:Math.floor(i.responseEnd-i.responseStart||0),rrt:Math.floor(i.responseEnd-i.fetchStart||0)};i.initiatorType in e?e[i.initiatorType].push(o):e[i.initiatorType]=[o]}}for(var a in e){for(var c=e[a],u=c.length,s={tp:"rs",mtp:a,dt:0,tt:0,rt:0,rrt:0},f=0;f<c.length;f++){var d=c[f];s.dt+=d.dt,s.tt+=d.tt,s.rt+=d.rt,s.rrt+=d.rrt}s.dt=Math.floor(s.dt/u),s.tt=Math.floor(s.tt/u),s.rt=Math.floor(s.rt/u),s.rrt=Math.floor(s.rrt/u),n.push(s)}return n},collect:function(){return this.enable?(this.debug&&this.print(),this.getData()):[]}};t.exports=e},function(t,n){var e=function(){function t(){return{tp:"tm",mtp:"html",dt:Math.floor(n),tt:Math.floor(e),rt:Math.floor(r),domt:Math.floor(o),et:Math.floor(i),ot:Math.floor(a),rtt:Math.floor(c),sw:screen.width||1,sh:screen.height||1,pf:navigator.platform||"unknown"}}var n=performance.timing.domainLookupEnd-(performance.timing.domainLookupStart||0),e=performance.timing.connectEnd-(performance.timing.connectStart||0),r=performance.timing.responseEnd-(performance.timing.responseStart||0),i=performance.timing.responseStart-(performance.timing.navigationStart||0),o=performance.timing.domContentLoadedEventEnd-(performance.timing.domLoading||0),a=performance.timing.domContentLoadedEventEnd-(performance.timing.navigationStart||0),c=(performance.timing.loadEventEnd||performance.timing.domComplete)-(performance.timing.navigationStart||0);return{collect:function(){return t()},print:function(){var t=document.getElementById("debug"),n=this.formatDebugInfo();if(t)t.innerHTML+=n;else{var e=document.createElement("div");e.id="debug",e.innerHTML=n,document.body.appendChild(e)}},formatDebugInfo:function(){var t="<p>";return t+="timing object : "+JSON.stringify(this.collect(),null,2)+"<br/>",t+="url: "+decodeURIComponent(window.location.href)+"<br/>",t+="</p>"}}},r={init:function(t){if(this.enable=!0,this.debug=t,!("performance"in window))return void(this.enable=!1)},collect:function(){if(this.enable){var t=e(),n=t.collect();return this.debug&&t.print(),n}}};t.exports=r}]);
{{/ifand}}
</script>
... ...
{
"name": "yohobuywap-node",
"version": "6.6.10",
"version": "6.6.11",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ... @@ -86,7 +86,7 @@
"xml2js": "^0.4.19",
"yoho-express-session": "^2.0.0",
"yoho-md5": "^2.0.0",
"yoho-node-lib": "=0.6.13",
"yoho-node-lib": "=0.6.15",
"yoho-zookeeper": "^1.0.9"
},
"devDependencies": {
... ...
... ... @@ -23,21 +23,14 @@ let _ChannelVary = {
require('./common/share');
function cookie(name) {
let cookies = document.cookie,
cookieVal;
var re = new RegExp(name + '=([^;$]*)', 'i'),
matchPattern = '$1';
if (cookies) {
cookies = cookies.split(';');
for (let i = 0; i < cookies.length; i++) {
if (cookies[i].indexOf(name) > -1) {
cookieVal = decodeURIComponent($.trim(cookies[i].replace(name + '=', '')));
break;
}
}
try {
return re.test(decodeURIComponent(document.cookie)) ? RegExp[matchPattern] : '';
} catch (e) {
return decodeURIComponent(re.test(document.cookie) ? RegExp[matchPattern] : '');
}
return cookieVal;
}
function setCookie(name, value, options) {
... ...
... ... @@ -49,8 +49,12 @@ $(document).ajaxError((event, xhr) => {
window.location.href = `/signin.html?refer=${encodeURIComponent(window.location.href)}`;
}
}
} else if (xhr.status === 510 && xhr.responseJSON.data && xhr.responseJSON.data.refer) {
window.location.href = xhr.responseJSON.data.refer;
} else if (xhr.status === 510) {
if (xhr.responseJSON.data && xhr.responseJSON.data.refer) {
window.location.href = xhr.responseJSON.data.refer;
} else if (xhr.responseJSON.message) {
tip.show(xhr.responseJSON.message);
}
} else if (xhr.status === 403 && xhr.responseJSON.code === 4403) {
tip.show(xhr.responseJSON.message);
setTimeout(function() {
... ...