Authored by ccbikai

增加查询用户信息

@@ -149,13 +149,16 @@ exports.filter = (req, res) => { @@ -149,13 +149,16 @@ exports.filter = (req, res) => {
149 149
150 exports.search = (req, res) => { 150 exports.search = (req, res) => {
151 let params = Object.assign({}, req.query); 151 let params = Object.assign({}, req.query);
  152 + let uid = req.user.uid || 0;
  153 +
  154 + saleModel.getSearchData(params, uid).then((result) => {
  155 + let vipLevel = result[1].curLevel;
152 156
153 - saleModel.getSearchData(params).then((result) => {  
154 res.render('product', { 157 res.render('product', {
155 layout: false, 158 layout: false,
156 params: params, 159 params: params,
157 - goods: result,  
158 - saleVip: req.query.saleType === '2' && !req.user.uid 160 + goods: result[0],
  161 + saleVip: (req.query.saleType === '2' && !uid) || vipLevel === '1'
159 }); 162 });
160 }); 163 });
161 }; 164 };
@@ -189,18 +189,35 @@ exports.getFilterData = (params) => { @@ -189,18 +189,35 @@ exports.getFilterData = (params) => {
189 }); 189 });
190 }; 190 };
191 191
  192 +const getUserProfile = (uid) => {
  193 + return api.get('', sign.apiSign({
  194 + method: 'app.passport.profile',
  195 + uid: uid
  196 + }), true);
  197 +};
  198 +
192 /** 199 /**
193 * 获取商品数据 200 * 获取商品数据
194 */ 201 */
195 -exports.getSearchData = (params) => {  
196 - return searchSales(params).then((result) => {  
197 - if (result && result.code === 200) {  
198 - return productProcess.processProductList(result.data.product_list || []);  
199 - } else {  
200 - logger.error('SALE 商品搜索返回 code 不是 200');  
201 - return {};  
202 - }  
203 - }); 202 +exports.getSearchData = (params, uid) => {
  203 + return Promise.all([
  204 + searchSales(params).then((result) => {
  205 + if (result && result.code === 200) {
  206 + return productProcess.processProductList(result.data.product_list || []);
  207 + } else {
  208 + logger.error('SALE 商品搜索返回 code 不是 200');
  209 + return [];
  210 + }
  211 + }),
  212 + getUserProfile(uid).then((result) => {
  213 + if (result && result.code === 200) {
  214 + return camelCase(result.data.vip_info);
  215 + } else {
  216 + logger.error('获取用户信息返回 code 不是 200');
  217 + return {};
  218 + }
  219 + })
  220 + ]);
204 }; 221 };
205 222
206 /** 223 /**