Authored by ccbikai

增加查询用户信息

... ... @@ -149,13 +149,16 @@ exports.filter = (req, res) => {
exports.search = (req, res) => {
let params = Object.assign({}, req.query);
let uid = req.user.uid || 0;
saleModel.getSearchData(params, uid).then((result) => {
let vipLevel = result[1].curLevel;
saleModel.getSearchData(params).then((result) => {
res.render('product', {
layout: false,
params: params,
goods: result,
saleVip: req.query.saleType === '2' && !req.user.uid
goods: result[0],
saleVip: (req.query.saleType === '2' && !uid) || vipLevel === '1'
});
});
};
... ...
... ... @@ -189,18 +189,35 @@ exports.getFilterData = (params) => {
});
};
const getUserProfile = (uid) => {
return api.get('', sign.apiSign({
method: 'app.passport.profile',
uid: uid
}), true);
};
/**
* 获取商品数据
*/
exports.getSearchData = (params) => {
return searchSales(params).then((result) => {
if (result && result.code === 200) {
return productProcess.processProductList(result.data.product_list || []);
} else {
logger.error('SALE 商品搜索返回 code 不是 200');
return {};
}
});
exports.getSearchData = (params, uid) => {
return Promise.all([
searchSales(params).then((result) => {
if (result && result.code === 200) {
return productProcess.processProductList(result.data.product_list || []);
} else {
logger.error('SALE 商品搜索返回 code 不是 200');
return [];
}
}),
getUserProfile(uid).then((result) => {
if (result && result.code === 200) {
return camelCase(result.data.vip_info);
} else {
logger.error('获取用户信息返回 code 不是 200');
return {};
}
})
]);
};
/**
... ...