Authored by yyq

jsonp

... ... @@ -8,14 +8,14 @@ const headerNav = (req, res, next) => {
headerModel.getHeaderSubNav(channel).then(result => {
let resData = {code: 400};
if (result && result.length) {
if (result) {
Object.assign(resData, {
code: 200,
data: result[0]
data: result
});
}
res.send(resData);
res.jsonp(resData);
}).catch(next);
};
... ...
... ... @@ -299,15 +299,14 @@ async function requestHeaderData(type) {
return Promise.resolve({headerData: _html});
}
async function getHeaderSubNav(type) {
if (_.isEmpty(cacheNavData)) {
let res = await getHeaderNavAsync();
cacheNavData = _.get(setHeaderData(res.data, type), 'subNavGroup', []);
cacheNavData = getSubNavGroup(res.data, type);
}
return Promise.resolve(_.takeWhile(cacheNavData, o => {
return Promise.resolve(_.find(cacheNavData, o => {
return o.subType === type;
}));
}
... ...
... ... @@ -621,17 +621,12 @@ if (isSupportCss3Animation()) {
this.loading = true;
$.ajax({
url: '/common/header/nav',
type: 'GET',
data: {channel: this.channel},
}).done(function(res) {
$.getJSON('//www.yohobuy.com/common/header/nav?callback=?', {channel: this.channel}, function(res) {
if (res.code === 200) {
that.loaded = true;
that.$base.html(subNavFn(res.data));
that.reseatThirdMenu();
}
}).always(function() {
that.loading = false;
});
},
... ...