Authored by yyq

jsonp

@@ -8,14 +8,14 @@ const headerNav = (req, res, next) => { @@ -8,14 +8,14 @@ const headerNav = (req, res, next) => {
8 headerModel.getHeaderSubNav(channel).then(result => { 8 headerModel.getHeaderSubNav(channel).then(result => {
9 let resData = {code: 400}; 9 let resData = {code: 400};
10 10
11 - if (result && result.length) { 11 + if (result) {
12 Object.assign(resData, { 12 Object.assign(resData, {
13 code: 200, 13 code: 200,
14 - data: result[0] 14 + data: result
15 }); 15 });
16 } 16 }
17 17
18 - res.send(resData); 18 + res.jsonp(resData);
19 }).catch(next); 19 }).catch(next);
20 }; 20 };
21 21
@@ -299,15 +299,14 @@ async function requestHeaderData(type) { @@ -299,15 +299,14 @@ async function requestHeaderData(type) {
299 return Promise.resolve({headerData: _html}); 299 return Promise.resolve({headerData: _html});
300 } 300 }
301 301
302 -  
303 async function getHeaderSubNav(type) { 302 async function getHeaderSubNav(type) {
304 if (_.isEmpty(cacheNavData)) { 303 if (_.isEmpty(cacheNavData)) {
305 let res = await getHeaderNavAsync(); 304 let res = await getHeaderNavAsync();
306 305
307 - cacheNavData = _.get(setHeaderData(res.data, type), 'subNavGroup', []); 306 + cacheNavData = getSubNavGroup(res.data, type);
308 } 307 }
309 308
310 - return Promise.resolve(_.takeWhile(cacheNavData, o => { 309 + return Promise.resolve(_.find(cacheNavData, o => {
311 return o.subType === type; 310 return o.subType === type;
312 })); 311 }));
313 } 312 }
@@ -621,17 +621,12 @@ if (isSupportCss3Animation()) { @@ -621,17 +621,12 @@ if (isSupportCss3Animation()) {
621 621
622 this.loading = true; 622 this.loading = true;
623 623
624 - $.ajax({  
625 - url: '/common/header/nav',  
626 - type: 'GET',  
627 - data: {channel: this.channel},  
628 - }).done(function(res) { 624 + $.getJSON('//www.yohobuy.com/common/header/nav?callback=?', {channel: this.channel}, function(res) {
629 if (res.code === 200) { 625 if (res.code === 200) {
630 that.loaded = true; 626 that.loaded = true;
631 that.$base.html(subNavFn(res.data)); 627 that.$base.html(subNavFn(res.data));
632 that.reseatThirdMenu(); 628 that.reseatThirdMenu();
633 } 629 }
634 - }).always(function() {  
635 that.loading = false; 630 that.loading = false;
636 }); 631 });
637 }, 632 },