Showing
1 changed file
with
30 additions
and
27 deletions
1 | -/** | ||
2 | - * | ||
3 | - * @author: jiangfeng<jeff.jiang@yoho.cn> | ||
4 | - * @date: 16/9/8 | 1 | +/* |
2 | + * @Author: Targaryen | ||
3 | + * @Date: 2017-01-03 17:42:41 | ||
4 | + * @Last Modified by: mikey.zhaopeng | ||
5 | + * @Last Modified time: 2017-01-03 18:07:44 | ||
5 | */ | 6 | */ |
7 | + | ||
6 | 'use strict'; | 8 | 'use strict'; |
7 | 9 | ||
8 | -const ServiceAPI = global.yoho.ServiceAPI; | ||
9 | -const helpers = global.yoho.helpers; | 10 | +/** |
11 | + * 微信支付相关工具类 | ||
12 | + */ | ||
13 | +const tools = { | ||
14 | + createOauthUrlForCode(redirectUrl) { | ||
15 | + return redirectUrl; | ||
16 | + }, | ||
17 | + getOpenidFromMp(code) { | ||
18 | + return code; | ||
19 | + } | ||
20 | +}; | ||
10 | 21 | ||
22 | +// TODO 微信支付 | ||
11 | const Wechat = { | 23 | const Wechat = { |
12 | - pay(user, order, info) { | ||
13 | - return ServiceAPI.get('payment/weixin_data', { | ||
14 | - order_code: order.order_code, | ||
15 | - payment_code: info.id, | ||
16 | - app_key: 'blkpc' | ||
17 | - }).then(result => { | ||
18 | - if (result && result.code === 200 && result.data) { | ||
19 | - let url = `/shopping/pay/online/weixin?url=${result.data.codeUrl}&code=${order.order_code}`; | 24 | + GetOpenid(req, res) { |
25 | + let code = req.query.code; | ||
26 | + | ||
27 | + if (!code) { | ||
28 | + let baseUrl = 'http://m.yohobuy.com' + req.originalUrl; | ||
29 | + let url = tools.createOauthUrlForCode(baseUrl); | ||
30 | + | ||
31 | + res.redirectUrl(url); | ||
32 | + } else { | ||
33 | + let openid = tools.getOpenidFromMp(code); | ||
20 | 34 | ||
21 | - return { | ||
22 | - code: 200, | ||
23 | - data: { | ||
24 | - href: helpers.urlFormat(url) | ||
25 | - } | ||
26 | - }; | ||
27 | - } else { | ||
28 | - return { | ||
29 | - code: 400, | ||
30 | - message: result.message | ||
31 | - }; | ||
32 | - } | ||
33 | - }); | 35 | + return openid; |
36 | + } | ||
34 | } | 37 | } |
35 | }; | 38 | }; |
36 | 39 |
-
Please register or login to post a comment