Authored by weiqingting

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

@@ -23,12 +23,25 @@ window.GOLABDATA={ @@ -23,12 +23,25 @@ window.GOLABDATA={
23 }, 23 },
24 fire:function(key){ 24 fire:function(key){
25 var that=this; 25 var that=this;
26 - if (!this.registerEvent || !this.registerEvent[key]) return;  
27 - var listeners=that.registerEvent[key];  
28 - var args=[].slice.call(arguments,1);  
29 - for(var i in listeners){  
30 - return listeners[i].apply(this,args); 26 + if (!this.registerEvent) return;
  27 + if(key){
  28 + if(!this.registerEvent[key])return;
  29 + var listeners=that.registerEvent[key];
  30 + var args=[].slice.call(arguments,1);
  31 + for(var i in listeners){
  32 + return listeners[i].apply(this,args);
  33 + }
  34 + }else{
  35 + var map={},args=[].slice.call(arguments,1);
  36 + for(var key in that.registerEvent){
  37 + var listeners=that.registerEvent[key];
  38 + for(var i in listeners){
  39 + map[key]=listeners[i].apply(this,args);
  40 + }
  41 + }
  42 + return map;
31 } 43 }
  44 +
32 } 45 }
33 }; 46 };
34 47
@@ -50,11 +50,11 @@ if(window.NETSALEDATA) { @@ -50,11 +50,11 @@ if(window.NETSALEDATA) {
50 }); 50 });
51 51
52 $(document).on('change','.washTips', function() { 52 $(document).on('change','.washTips', function() {
53 - var items = $("#washTips").val().split("|");  
54 - for (var i = 0; i < items.length; i++) {  
55 - washTipsList[i] = {"sortId":parseInt(items[i])};  
56 - }  
57 - }); 53 + var items = $("#washTips").val().split("|");
  54 + for (var i = 0; i < items.length; i++) {
  55 + washTipsList[i] = {"sortId":parseInt(items[i])};
  56 + }
  57 + });
58 58
59 $(document).on('click', "#propertySave", function() { 59 $(document).on('click', "#propertySave", function() {
60 60
@@ -72,7 +72,18 @@ if(window.NETSALEDATA) { @@ -72,7 +72,18 @@ if(window.NETSALEDATA) {
72 // body... 72 // body...
73 }); 73 });
74 }); 74 });
  75 +
  76 + window.GOLABDATA.on('TYcaizhi', function() {
  77 + var washTips = $("#washTips").val() || "";
  78 + var productMaterial = $("#material").val() || "";
  79 + return {
  80 + "washTips": washTips.replace(/\|/g, ","),
  81 + "productMaterial": productMaterial.replace(/\|/g, ",")
  82 + };
  83 + });
75 } 84 }
  85 +
  86 +
76 {//搜索关键词 87 {//搜索关键词
77 var searchKeys = ""; 88 var searchKeys = "";
78 if(window.NETSALEDATA.productExtBo) { 89 if(window.NETSALEDATA.productExtBo) {
@@ -118,7 +129,17 @@ if(window.NETSALEDATA) { @@ -118,7 +129,17 @@ if(window.NETSALEDATA) {
118 129
119 }); 130 });
120 }); 131 });
  132 +
  133 + window.GOLABDATA.on('TYsearchKey', function() {
  134 + var washTips = $("#washTips").val() || "";
  135 + var productMaterial = $("#material").val() || "";
  136 + return {
  137 + "searchKeys": searchKeys
  138 + };
  139 + });
121 } 140 }
  141 +
  142 +
122 {//尺寸信息 143 {//尺寸信息
123 var sizeInfo = {}; 144 var sizeInfo = {};
124 if(window.NETSALEDATA.sizeInfo) { 145 if(window.NETSALEDATA.sizeInfo) {
@@ -126,6 +147,8 @@ if(window.NETSALEDATA) { @@ -126,6 +147,8 @@ if(window.NETSALEDATA) {
126 } 147 }
127 $("#body").html(common.util.__template2($("#sizeifo-template").html(),sizeInfo)); 148 $("#body").html(common.util.__template2($("#sizeifo-template").html(),sizeInfo));
128 } 149 }
  150 +
  151 +
129 {//搜索优先级 152 {//搜索优先级
130 var searchSortList = []; 153 var searchSortList = [];
131 if(window.NETSALEDATA.searchSortList) { 154 if(window.NETSALEDATA.searchSortList) {
@@ -160,27 +183,38 @@ if(window.NETSALEDATA) { @@ -160,27 +183,38 @@ if(window.NETSALEDATA) {
160 } 183 }
161 } 184 }
162 185
163 - window.NETSALEDATA.searchSortList = item; 186 + searchSortList = item;
164 187
165 $('#sort-save').on('click', function () { 188 $('#sort-save').on('click', function () {
166 common.util.__ajax({ 189 common.util.__ajax({
167 url:'/netSale/saveSearchSort', 190 url:'/netSale/saveSearchSort',
168 - data:{searchSortList:JSON.stringify(window.NETSALEDATA.searchSortList)} 191 + data:{searchSortList:JSON.stringify(searchSortList)}
169 },function() { 192 },function() {
170 193
171 }); 194 });
172 }); 195 });
173 196
174 $("#sort0").on('change', function() { 197 $("#sort0").on('change', function() {
175 - window.NETSALEDATA.searchSortList[0].intValue = parseInt($("#sort0").val()); 198 + searchSortList[0].intValue = parseInt($("#sort0").val());
176 }); 199 });
177 200
178 $("#sort1").on('change', function() { 201 $("#sort1").on('change', function() {
179 - window.NETSALEDATA.searchSortList[1].intValue = parseInt($("#sort1").val()); 202 + searchSortList[1].intValue = parseInt($("#sort1").val());
180 }); 203 });
181 204
182 $("#sort2").on('change', function() { 205 $("#sort2").on('change', function() {
183 - window.NETSALEDATA.searchSortList[2].intValue = parseInt($("#sort2").val()); 206 + searchSortList[2].intValue = parseInt($("#sort2").val());
  207 + });
  208 +
  209 + window.GOLABDATA.on('TYsearchSort', function() {
  210 + if(!searchSortList[0] || !searchSortList[1] || !searchSortList[2])
  211 + return "请将搜索排序填写完整!";
  212 + return {
  213 + "searchSortList": JSON.stringify(searchSortList)
  214 + };
184 }); 215 });
185 } 216 }
186 -}  
  217 +
  218 +}
  219 +
  220 +
@@ -45,6 +45,7 @@ module.exports = function(proxyRoute) { @@ -45,6 +45,7 @@ module.exports = function(proxyRoute) {
45 } 45 }
46 //删除提交内容长度,代理会改变长度 46 //删除提交内容长度,代理会改变长度
47 delete options.headers['content-length']; 47 delete options.headers['content-length'];
  48 + delete options.headers["accept-encoding"];
48 //设置代理host 49 //设置代理host
49 options.headers['host'] = config.url.replace('http://',''); 50 options.headers['host'] = config.url.replace('http://','');
50 if(!req.session.gray) { 51 if(!req.session.gray) {
@@ -56,13 +57,14 @@ module.exports = function(proxyRoute) { @@ -56,13 +57,14 @@ module.exports = function(proxyRoute) {
56 logger.log('info','grayroute: request options: %j',options,{}); 57 logger.log('info','grayroute: request options: %j',options,{});
57 58
58 //发起代理请求 59 //发起代理请求
59 - if(req.is('html')) { 60 + if(req.headers['accept'].indexOf('text/html')>-1) {
60 request(options,function(err,res,body) { 61 request(options,function(err,res,body) {
61 if(err) { 62 if(err) {
62 logger.log('error','grayroute: request error:',err); 63 logger.log('error','grayroute: request error:',err);
63 ress.status(500).send(''); 64 ress.status(500).send('');
64 } else { 65 } else {
65 - setGrayCookie(req,res); 66 + var ContentType = res.caseless.get('Content-Type');
  67 + ress.append('Content-Type',ContentType);
66 ress.status(res.statusCode).send(body); 68 ress.status(res.statusCode).send(body);
67 } 69 }
68 }); 70 });
@@ -85,19 +87,4 @@ module.exports = function(proxyRoute) { @@ -85,19 +87,4 @@ module.exports = function(proxyRoute) {
85 next(); 87 next();
86 } 88 }
87 } 89 }
88 - }  
89 -  
90 - /**  
91 - * 灰度cookie设置  
92 - * @param {Object} req express request  
93 - * @param {Object} res request的响应  
94 - */  
95 - function setGrayCookie(req,res) {  
96 - //cookie透传到老系统  
97 - var cookie = res.caseless.get('set-cookie');  
98 - //如果没有设置到session  
99 - if(cookie && cookie.length>0 && !req.session.gray) {  
100 - req.session.gray = cookie[0];  
101 - }  
102 - return cookie;  
103 } 90 }