Authored by weiqingting

Merge branch 'develop' of http://git.dev.yoho.cn/platform/yohobuy-portal-fe into develop

... ... @@ -23,12 +23,25 @@ window.GOLABDATA={
},
fire:function(key){
var that=this;
if (!this.registerEvent || !this.registerEvent[key]) return;
var listeners=that.registerEvent[key];
var args=[].slice.call(arguments,1);
for(var i in listeners){
return listeners[i].apply(this,args);
if (!this.registerEvent) return;
if(key){
if(!this.registerEvent[key])return;
var listeners=that.registerEvent[key];
var args=[].slice.call(arguments,1);
for(var i in listeners){
return listeners[i].apply(this,args);
}
}else{
var map={},args=[].slice.call(arguments,1);
for(var key in that.registerEvent){
var listeners=that.registerEvent[key];
for(var i in listeners){
map[key]=listeners[i].apply(this,args);
}
}
return map;
}
}
};
... ...
... ... @@ -50,11 +50,11 @@ if(window.NETSALEDATA) {
});
$(document).on('change','.washTips', function() {
var items = $("#washTips").val().split("|");
for (var i = 0; i < items.length; i++) {
washTipsList[i] = {"sortId":parseInt(items[i])};
}
});
var items = $("#washTips").val().split("|");
for (var i = 0; i < items.length; i++) {
washTipsList[i] = {"sortId":parseInt(items[i])};
}
});
$(document).on('click', "#propertySave", function() {
... ... @@ -72,7 +72,18 @@ if(window.NETSALEDATA) {
// body...
});
});
window.GOLABDATA.on('TYcaizhi', function() {
var washTips = $("#washTips").val() || "";
var productMaterial = $("#material").val() || "";
return {
"washTips": washTips.replace(/\|/g, ","),
"productMaterial": productMaterial.replace(/\|/g, ",")
};
});
}
{//搜索关键词
var searchKeys = "";
if(window.NETSALEDATA.productExtBo) {
... ... @@ -118,7 +129,17 @@ if(window.NETSALEDATA) {
});
});
window.GOLABDATA.on('TYsearchKey', function() {
var washTips = $("#washTips").val() || "";
var productMaterial = $("#material").val() || "";
return {
"searchKeys": searchKeys
};
});
}
{//尺寸信息
var sizeInfo = {};
if(window.NETSALEDATA.sizeInfo) {
... ... @@ -126,6 +147,8 @@ if(window.NETSALEDATA) {
}
$("#body").html(common.util.__template2($("#sizeifo-template").html(),sizeInfo));
}
{//搜索优先级
var searchSortList = [];
if(window.NETSALEDATA.searchSortList) {
... ... @@ -160,27 +183,38 @@ if(window.NETSALEDATA) {
}
}
window.NETSALEDATA.searchSortList = item;
searchSortList = item;
$('#sort-save').on('click', function () {
common.util.__ajax({
url:'/netSale/saveSearchSort',
data:{searchSortList:JSON.stringify(window.NETSALEDATA.searchSortList)}
data:{searchSortList:JSON.stringify(searchSortList)}
},function() {
});
});
$("#sort0").on('change', function() {
window.NETSALEDATA.searchSortList[0].intValue = parseInt($("#sort0").val());
searchSortList[0].intValue = parseInt($("#sort0").val());
});
$("#sort1").on('change', function() {
window.NETSALEDATA.searchSortList[1].intValue = parseInt($("#sort1").val());
searchSortList[1].intValue = parseInt($("#sort1").val());
});
$("#sort2").on('change', function() {
window.NETSALEDATA.searchSortList[2].intValue = parseInt($("#sort2").val());
searchSortList[2].intValue = parseInt($("#sort2").val());
});
window.GOLABDATA.on('TYsearchSort', function() {
if(!searchSortList[0] || !searchSortList[1] || !searchSortList[2])
return "请将搜索排序填写完整!";
return {
"searchSortList": JSON.stringify(searchSortList)
};
});
}
}
\ No newline at end of file
}
... ...
... ... @@ -45,6 +45,7 @@ module.exports = function(proxyRoute) {
}
//删除提交内容长度,代理会改变长度
delete options.headers['content-length'];
delete options.headers["accept-encoding"];
//设置代理host
options.headers['host'] = config.url.replace('http://','');
if(!req.session.gray) {
... ... @@ -56,13 +57,14 @@ module.exports = function(proxyRoute) {
logger.log('info','grayroute: request options: %j',options,{});
//发起代理请求
if(req.is('html')) {
if(req.headers['accept'].indexOf('text/html')>-1) {
request(options,function(err,res,body) {
if(err) {
logger.log('error','grayroute: request error:',err);
ress.status(500).send('');
} else {
setGrayCookie(req,res);
var ContentType = res.caseless.get('Content-Type');
ress.append('Content-Type',ContentType);
ress.status(res.statusCode).send(body);
}
});
... ... @@ -85,19 +87,4 @@ module.exports = function(proxyRoute) {
next();
}
}
}
/**
* 灰度cookie设置
* @param {Object} req express request
* @param {Object} res request的响应
*/
function setGrayCookie(req,res) {
//cookie透传到老系统
var cookie = res.caseless.get('set-cookie');
//如果没有设置到session
if(cookie && cookie.length>0 && !req.session.gray) {
req.session.gray = cookie[0];
}
return cookie;
}
\ No newline at end of file
... ...