Merge branch 'feature/ufo' of http://git.yoho.cn/fe/yoho-app-web into feature/ufo
Showing
3 changed files
with
29 additions
and
22 deletions
@@ -34,23 +34,30 @@ const request = async({url, method, reqParams = {}, context}) => { | @@ -34,23 +34,30 @@ const request = async({url, method, reqParams = {}, context}) => { | ||
34 | 'User-Agent': 'yoho/nodejs' | 34 | 'User-Agent': 'yoho/nodejs' |
35 | }; | 35 | }; |
36 | 36 | ||
37 | - if (apiInfo.service) { | ||
38 | - return await serviceApi.get(`${apiInfo.api}${apiInfo.path}`, params, { | ||
39 | - cache: cache, | ||
40 | - code: 200, | ||
41 | - headers | ||
42 | - }); | ||
43 | - } else if (apiInfo.ufo) { | ||
44 | - return await ufoAPI[method](`${apiInfo.path || ''}`, params, { | ||
45 | - cache: cache, | ||
46 | - code: 200, | ||
47 | - headers | ||
48 | - }); | ||
49 | - } else { | ||
50 | - return await yohoApi[method](`${apiInfo.path || ''}`, params, { | ||
51 | - code: 200, | ||
52 | - cache: cache, | ||
53 | - headers | 37 | + try { |
38 | + if (apiInfo.service) { | ||
39 | + return await serviceApi.get(`${apiInfo.api}${apiInfo.path}`, params, { | ||
40 | + cache: cache, | ||
41 | + code: 200, | ||
42 | + headers | ||
43 | + }); | ||
44 | + } else if (apiInfo.ufo) { | ||
45 | + return await ufoAPI[method](`${apiInfo.path || ''}`, params, { | ||
46 | + cache: cache, | ||
47 | + code: 200, | ||
48 | + headers | ||
49 | + }); | ||
50 | + } else { | ||
51 | + return await yohoApi[method](`${apiInfo.path || ''}`, params, { | ||
52 | + code: 200, | ||
53 | + cache: cache, | ||
54 | + headers | ||
55 | + }); | ||
56 | + } | ||
57 | + } catch (error) { | ||
58 | + return Promise.reject({ | ||
59 | + code: error.code || 500, | ||
60 | + message: error.message || '服务器错误' | ||
54 | }); | 61 | }); |
55 | } | 62 | } |
56 | }; | 63 | }; |
@@ -9,7 +9,7 @@ | @@ -9,7 +9,7 @@ | ||
9 | <span class="unit">码</span> | 9 | <span class="unit">码</span> |
10 | </div> | 10 | </div> |
11 | <div class="middle"> | 11 | <div class="middle"> |
12 | - <p class="size-store">¥{{value.goodsInfo.goodPrice}},{{value.goodsInfo.storageNum}}个库存</p> | 12 | + <p class="size-store">¥{{value.goodsInfo.price}},{{value.goodsInfo.storageNum}}个库存</p> |
13 | <p class="low-price">当前最低价¥{{value.goodsInfo.leastPrice}}</p> | 13 | <p class="low-price">当前最低价¥{{value.goodsInfo.leastPrice}}</p> |
14 | </div> | 14 | </div> |
15 | <div class="right"> | 15 | <div class="right"> |
@@ -71,11 +71,11 @@ module.exports = async(req, res, next) => { | @@ -71,11 +71,11 @@ module.exports = async(req, res, next) => { | ||
71 | return res.json({ | 71 | return res.json({ |
72 | code: 400 | 72 | code: 400 |
73 | }); | 73 | }); |
74 | - } catch (e) { | ||
75 | - logger.error(e); | 74 | + } catch (error) { |
75 | + logger.error(error); | ||
76 | return res.json({ | 76 | return res.json({ |
77 | - code: 400, | ||
78 | - message: e | 77 | + code: error.code || 500, |
78 | + message: error.message || '服务器错误' | ||
79 | }); | 79 | }); |
80 | } | 80 | } |
81 | }; | 81 | }; |
-
Please register or login to post a comment