Authored by ccbikai

搜索空字符串问题

... ... @@ -23,7 +23,7 @@ exports.fetchProducts = (req, res, next) => {
const params = {
page: req.query.page || 1,
order: req.query.order || 1,
query: req.query.query
query: (req.query.query || '').trim()
};
model.products(params)
... ...
... ... @@ -15,23 +15,17 @@ const search = {
method: 'app.search.li'
}, params);
delete data.client_type;
delete data.client_secret;
return api.post('', data, {
return api.get('', data, {
cache: true,
code: 200
})
.then(result => {
if (!result.hasOwnProperty('code')) {
result.code = 200;
}
if (result.code === 200) {
prettyFilter(result.data.filter);
result = camelCase(result);
result.data.productList = processProductList(result.data.productList, {gender: params.gender});
}
return result;
});
}).then(result => {
if (result.data) {
prettyFilter(result.data.filter);
result = camelCase(result);
result.data.productList = processProductList(result.data.productList, {gender: params.gender});
}
return result;
});
}
};
... ...
... ... @@ -69,20 +69,20 @@
}
this.inSearching = true;
console.log(nextPage);
return $.get(this.url, {
order: this.order, // 排序 信息
query: this.query,
page: nextPage
})
.done(res => {
if (res.code === 200) {
if (res.data) {
self.page = res.data.page;
self.totalPage = res.data.pageTotal;
self.$set('productList', self.productList.concat(res.data.productList));
}
})
.fail(error => {
.fail(() => {
tip('网络出错~');
})
.always(() => {
... ... @@ -128,7 +128,4 @@
});
}
};
</script>
<style>
</style>
... ...