Merge branch 'feature/cart' of http://git.yoho.cn/fe/yohobuywap-node into feature/cart
Showing
17 changed files
with
345 additions
and
140 deletions
@@ -186,7 +186,7 @@ exports.selectAddress = (req, res, next) => { | @@ -186,7 +186,7 @@ exports.selectAddress = (req, res, next) => { | ||
186 | /** | 186 | /** |
187 | * 发票信息 | 187 | * 发票信息 |
188 | */ | 188 | */ |
189 | -exports.invoiceInfo = (req, res, next) => { | 189 | +exports.invoiceInfo = (req, res) => { |
190 | let uid = req.user.uid; | 190 | let uid = req.user.uid; |
191 | let cookieData = req.cookies['order-info']; | 191 | let cookieData = req.cookies['order-info']; |
192 | let orderInfo = JSON.parse(cookieData); | 192 | let orderInfo = JSON.parse(cookieData); |
@@ -205,6 +205,6 @@ exports.invoiceInfo = (req, res, next) => { | @@ -205,6 +205,6 @@ exports.invoiceInfo = (req, res, next) => { | ||
205 | pageHeader: headerData, | 205 | pageHeader: headerData, |
206 | module: 'cart', | 206 | module: 'cart', |
207 | page: 'select-invoice' | 207 | page: 'select-invoice' |
208 | - })).catch(next); | 208 | + })); |
209 | })(); | 209 | })(); |
210 | }; | 210 | }; |
1 | -/** | 1 | +/* |
2 | * 支付 | 2 | * 支付 |
3 | - * @author: jing.li<jing.li@yoho.cn> | ||
4 | - * @date: 2016/10/25 | 3 | + * @Author: Targaryen |
4 | + * @Date: 2017-01-04 15:17:51 | ||
5 | + * @Last Modified by: Targaryen | ||
6 | + * @Last Modified time: 2017-01-10 16:43:54 | ||
5 | */ | 7 | */ |
6 | 8 | ||
7 | 'use strict'; | 9 | 'use strict'; |
8 | 10 | ||
9 | const mRoot = '../models'; | 11 | const mRoot = '../models'; |
10 | const payModel = require(`${mRoot}/pay`); | 12 | const payModel = require(`${mRoot}/pay`); |
13 | +const payTool = payModel.payTool; | ||
11 | const headerModel = require('../../../doraemon/models/header'); // 头部model | 14 | const headerModel = require('../../../doraemon/models/header'); // 头部model |
12 | const co = require('bluebird').coroutine; | 15 | const co = require('bluebird').coroutine; |
13 | const helpers = global.yoho.helpers; | 16 | const helpers = global.yoho.helpers; |
14 | const Payment = require('../helpers/payment'); | 17 | const Payment = require('../helpers/payment'); |
18 | +const WxPay = require('../helpers/pay/wechat'); | ||
19 | +const common = require('../helpers/pay/common'); | ||
15 | 20 | ||
16 | /** | 21 | /** |
17 | * 支付中心 | 22 | * 支付中心 |
@@ -19,10 +24,12 @@ const Payment = require('../helpers/payment'); | @@ -19,10 +24,12 @@ const Payment = require('../helpers/payment'); | ||
19 | * @param res | 24 | * @param res |
20 | * @param next | 25 | * @param next |
21 | */ | 26 | */ |
22 | -const payCenter = (req, res, next) => { | 27 | +const payCenter = (req, res) => { |
23 | let orderCode = req.query.order_code; | 28 | let orderCode = req.query.order_code; |
24 | let uid = req.user.uid; | 29 | let uid = req.user.uid; |
25 | let sessionKey = req.session.TOKEN; | 30 | let sessionKey = req.session.TOKEN; |
31 | + let userAgent = req.get('User-Agent'); | ||
32 | + let hasWxShare = Boolean(userAgent.match(/MicroMessenger/i) && userAgent.match(/MicroMessenger/i).length > 0); | ||
26 | 33 | ||
27 | if (!orderCode || !uid) { | 34 | if (!orderCode || !uid) { |
28 | res.redirect('/'); | 35 | res.redirect('/'); |
@@ -32,47 +39,75 @@ const payCenter = (req, res, next) => { | @@ -32,47 +39,75 @@ const payCenter = (req, res, next) => { | ||
32 | sessionKey = sessionKey.substr(0, sessionKey.length - 8); | 39 | sessionKey = sessionKey.substr(0, sessionKey.length - 8); |
33 | } | 40 | } |
34 | 41 | ||
35 | - let headerData = headerModel.setNav({ | ||
36 | - navTitle: '支付中心' | ||
37 | - }); | 42 | + co(function* () { |
43 | + let orderDetail = yield payModel.payCenter({ | ||
44 | + orderCode: orderCode, | ||
45 | + uid: uid | ||
46 | + }); | ||
38 | 47 | ||
39 | - let responseData = { | ||
40 | - pageHeader: headerData, | ||
41 | - module: 'cart', | ||
42 | - page: 'pay', | ||
43 | - title: '支付中心 | Yoho!Buy有货 | 潮流购物逛不停' | ||
44 | - }; | 48 | + if (hasWxShare) { |
49 | + let openId = req.cookies['weixinOpenId' + orderCode]; | ||
45 | 50 | ||
46 | - payModel.payCenter({ | ||
47 | - orderCode: orderCode, | ||
48 | - uid: uid, | ||
49 | - sessionKey: sessionKey | ||
50 | - }).then(result => { | ||
51 | - res.render('pay/pay-center', Object.assign(responseData, result, { | ||
52 | - isOldUser: Boolean(req.cookies._isOldUser && req.cookies._isOldUser === '4'), | ||
53 | - })); | ||
54 | - }).catch(next); | 51 | + if (!openId) { |
52 | + let getOpenidResult = yield WxPay.getOpenid(req.query.code, req.originalUrl); | ||
53 | + | ||
54 | + if (getOpenidResult.openid) { | ||
55 | + openId = getOpenidResult.openid; | ||
56 | + } | ||
57 | + | ||
58 | + if (getOpenidResult.redirectUrl) { | ||
59 | + return res.redirect(getOpenidResult.redirectUrl); | ||
60 | + } | ||
55 | 61 | ||
62 | + if (openId) { | ||
63 | + res.cookie('weixinOpenId' + orderCode, openId, { | ||
64 | + domain: 'yohobuy.com', | ||
65 | + expires: new Date(Date.now() + 24 * 60 * 60 * 1000) | ||
66 | + }); | ||
67 | + } | ||
68 | + } | ||
69 | + } | ||
56 | 70 | ||
71 | + let responseData = { | ||
72 | + pageHeader: headerModel.setNav({ | ||
73 | + navTitle: '支付中心' | ||
74 | + }), | ||
75 | + module: 'cart', | ||
76 | + page: 'pay', | ||
77 | + title: '支付中心 | Yoho!Buy有货 | 潮流购物逛不停', | ||
78 | + payAppInfo: payTool.payAppInfo(orderCode), | ||
79 | + orderCode: orderCode, | ||
80 | + hasWxShare: hasWxShare, | ||
81 | + orderTotal: orderDetail.payment_amount || 0, | ||
82 | + orderTotalFormat: parseInt(orderDetail.payment_amount, 10), | ||
83 | + orderCount: payTool.calBuyNumCount(orderDetail.order_goods), | ||
84 | + uid: uid, | ||
85 | + isOldUser: Boolean(req.cookies._isOldUser && req.cookies._isOldUser === '4') | ||
86 | + }; | ||
87 | + | ||
88 | + res.render('pay/pay-center', responseData); | ||
89 | + })(); | ||
57 | }; | 90 | }; |
58 | 91 | ||
59 | /** | 92 | /** |
60 | - * 支付宝跳转页 | 93 | + * 统一支付入口 |
61 | * @param req | 94 | * @param req |
62 | * @param res | 95 | * @param res |
63 | */ | 96 | */ |
64 | -const goAlipay = (req, res, next) => { | 97 | +const pay = (req, res, next) => { |
65 | let orderCode = req.query.order_code; | 98 | let orderCode = req.query.order_code; |
66 | let user = req.user; | 99 | let user = req.user; |
67 | let uid = req.user.uid; | 100 | let uid = req.user.uid; |
68 | let sessionKey = req.session.TOKEN; | 101 | let sessionKey = req.session.TOKEN; |
69 | let payment = req.query.payment; | 102 | let payment = req.query.payment; |
103 | + let paymentCode = common.getPaymentCode(payment); | ||
104 | + let openId = req.cookies['weixinOpenId' + orderCode]; | ||
70 | 105 | ||
71 | if (!orderCode || !uid || !sessionKey) { | 106 | if (!orderCode || !uid || !sessionKey) { |
72 | - res.redirect('/'); | 107 | + return res.redirect('/'); |
73 | } | 108 | } |
74 | 109 | ||
75 | - co(function*() { | 110 | + co(function* () { |
76 | let orderDetail = yield payModel.getOtherDetail({ | 111 | let orderDetail = yield payModel.getOtherDetail({ |
77 | uid: uid, | 112 | uid: uid, |
78 | orderCode: orderCode, | 113 | orderCode: orderCode, |
@@ -95,11 +130,17 @@ const goAlipay = (req, res, next) => { | @@ -95,11 +130,17 @@ const goAlipay = (req, res, next) => { | ||
95 | }).redirect(url); | 130 | }).redirect(url); |
96 | } | 131 | } |
97 | 132 | ||
98 | - Payment.pay(user, orderDetail.data, payment, req.protocol).then(result => { | ||
99 | - if (result && result.data && result.data.href) { | ||
100 | - res.redirect(result.data.href); | 133 | + Payment.pay(user, orderDetail.data, payment, { |
134 | + protocol: req.protocol, | ||
135 | + openId: openId | ||
136 | + }).then(result => { | ||
137 | + if (result && paymentCode === payModel.payments.wechat) { | ||
138 | + return res.json(result); | ||
139 | + } | ||
140 | + if (result && result.data && result.data.href && paymentCode === payModel.payments.alipay) { | ||
141 | + return res.redirect(result.data.href); | ||
101 | } else { | 142 | } else { |
102 | - res.redirect('/'); | 143 | + return res.redirect('/'); |
103 | } | 144 | } |
104 | }).catch(next); | 145 | }).catch(next); |
105 | })(); | 146 | })(); |
@@ -184,7 +225,7 @@ const payAli = (req, res, next) => { | @@ -184,7 +225,7 @@ const payAli = (req, res, next) => { | ||
184 | 225 | ||
185 | module.exports = { | 226 | module.exports = { |
186 | payCenter, | 227 | payCenter, |
187 | - goAlipay, | 228 | + pay, |
188 | payCod, | 229 | payCod, |
189 | payAli | 230 | payAli |
190 | }; | 231 | }; |
@@ -69,6 +69,15 @@ const common = { | @@ -69,6 +69,15 @@ const common = { | ||
69 | } | 69 | } |
70 | }); | 70 | }); |
71 | }); | 71 | }); |
72 | + }, | ||
73 | + getPaymentCode(payment) { | ||
74 | + let paymentPars = payment.split('_'); | ||
75 | + | ||
76 | + if (paymentPars.length !== 2) { | ||
77 | + return false; | ||
78 | + } else { | ||
79 | + return paymentPars[0] * 1; | ||
80 | + } | ||
72 | } | 81 | } |
73 | }; | 82 | }; |
74 | 83 |
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: Targaryen | ||
5 | + * @Last Modified time: 2017-01-09 17:53:16 | ||
5 | */ | 6 | */ |
7 | + | ||
6 | 'use strict'; | 8 | 'use strict'; |
9 | +const config = global.yoho.config; | ||
10 | +const WxPayConfig = config.WxPayConfig; | ||
11 | +const _ = require('lodash'); | ||
12 | +const logger = global.yoho.logger; | ||
13 | +const rp = require('request-promise'); | ||
14 | +const Promise = require('bluebird'); | ||
15 | +const co = Promise.coroutine; | ||
16 | +const sign = require('./sign'); | ||
17 | +const md5 = require('md5'); | ||
18 | +const common = require('./common'); | ||
19 | + | ||
20 | +/** | ||
21 | + * 微信支付相关工具类 | ||
22 | + */ | ||
23 | +const tools = { | ||
24 | + | ||
25 | + /** | ||
26 | + * 拼接签名字符串 | ||
27 | + */ | ||
28 | + toUrlParams(urlObj) { | ||
29 | + let buff = ''; | ||
30 | + | ||
31 | + _.forEach(urlObj, (value, key) => { | ||
32 | + if (key !== 'sign') { | ||
33 | + buff += key + '=' + value + '&'; | ||
34 | + } | ||
35 | + }); | ||
36 | + | ||
37 | + buff = _.trimEnd(buff, '&'); | ||
7 | 38 | ||
8 | -const ServiceAPI = global.yoho.ServiceAPI; | ||
9 | -const helpers = global.yoho.helpers; | 39 | + return buff; |
40 | + }, | ||
41 | + | ||
42 | + /** | ||
43 | + * 构造获取code的url连接 | ||
44 | + */ | ||
45 | + createOauthUrlForCode(redirectUrl) { | ||
46 | + let urlObj = { | ||
47 | + appid: WxPayConfig.appId, | ||
48 | + redirect_uri: redirectUrl, | ||
49 | + response_type: 'code', | ||
50 | + scope: 'snsapi_base', | ||
51 | + state: 'STATE#wechat_redirect', | ||
52 | + }; | ||
53 | + | ||
54 | + let bizString = tools.toUrlParams(urlObj); | ||
55 | + | ||
56 | + return 'https://open.weixin.qq.com/connect/oauth2/authorize?' + bizString; | ||
57 | + }, | ||
58 | + | ||
59 | + /** | ||
60 | + * 构造获取open和access_toke的url地址 | ||
61 | + */ | ||
62 | + createOauthUrlForOpenid(code) { | ||
63 | + let urlObj = { | ||
64 | + appid: WxPayConfig.appId, | ||
65 | + secret: WxPayConfig.appSecret, | ||
66 | + code: code, | ||
67 | + grant_type: 'authorization_code' | ||
68 | + }; | ||
69 | + | ||
70 | + let bizString = tools.toUrlParams(urlObj); | ||
71 | + | ||
72 | + return 'https://api.weixin.qq.com/sns/oauth2/access_token?' + bizString; | ||
73 | + }, | ||
74 | + | ||
75 | + /** | ||
76 | + * 通过code从工作平台获取openid机器access_token | ||
77 | + */ | ||
78 | + getOpenidFromMp(code) { | ||
79 | + let uri = tools.createOauthUrlForOpenid(code); | ||
80 | + | ||
81 | + let rpOption = { | ||
82 | + method: 'POST', | ||
83 | + uri: uri, | ||
84 | + body: { | ||
85 | + some: 'payload' | ||
86 | + }, | ||
87 | + json: true | ||
88 | + }; | ||
89 | + | ||
90 | + return rp(rpOption).then(resultFromWx => { | ||
91 | + return resultFromWx && resultFromWx.openid; | ||
92 | + }).catch(err => { | ||
93 | + logger.error(err); | ||
94 | + }); | ||
95 | + }, | ||
10 | 96 | ||
97 | + /** | ||
98 | + * 微信统一下单接口 | ||
99 | + */ | ||
100 | + unifiedOrder(params) { | ||
101 | + let unifiedParams = { | ||
102 | + appid: WxPayConfig.appId, | ||
103 | + mch_id: WxPayConfig.mchId, | ||
104 | + notify_url: WxPayConfig.notifyUrl, | ||
105 | + device_info: 'WEB', | ||
106 | + nonce_str: common.nonceStr(), | ||
107 | + body: '有货订单号:' + params.orderCode, | ||
108 | + out_trade_no: 'YOHOBuy_' + params.orderCode, | ||
109 | + total_fee: params.totalFee * 100, | ||
110 | + trade_type: 'JSAPI', | ||
111 | + openid: params.openId, | ||
112 | + sign_type: 'MD5' | ||
113 | + }; | ||
114 | + let signStr = md5(sign.raw(unifiedParams) + '&key=' + WxPayConfig.key).toUpperCase(); | ||
115 | + | ||
116 | + _.assign(unifiedParams, { sign: signStr }); | ||
117 | + | ||
118 | + let xml = common.toXml(unifiedParams); | ||
119 | + | ||
120 | + let xmlParams = { | ||
121 | + method: 'POST', | ||
122 | + uri: 'https://api.mch.weixin.qq.com/pay/unifiedorder', | ||
123 | + headers: { | ||
124 | + 'Content-Type': 'application/x-www-form-urlencoded' | ||
125 | + }, | ||
126 | + body: xml, | ||
127 | + timeout: 1000 | ||
128 | + }; | ||
129 | + | ||
130 | + return co(function* () { | ||
131 | + let xmlResult = yield rp(xmlParams); | ||
132 | + let jsonResult = yield common.xml2Obj(xmlResult); | ||
133 | + | ||
134 | + return jsonResult && jsonResult.xml; | ||
135 | + })(); | ||
136 | + } | ||
137 | +}; | ||
138 | + | ||
139 | +// TODO 微信支付 | ||
11 | const Wechat = { | 140 | 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}`; | 141 | + /** |
142 | + * 支付中心微信支付相关处理 | ||
143 | + */ | ||
144 | + getOpenid(code, originalUrl) { | ||
145 | + if (!code) { | ||
146 | + let baseUrl = 'http://m.yohobuy.com' + originalUrl; | ||
147 | + let redirectUrl = tools.createOauthUrlForCode(baseUrl); | ||
148 | + | ||
149 | + return Promise.resolve({ redirectUrl: redirectUrl }); | ||
150 | + } else { | ||
151 | + return tools.getOpenidFromMp(code).then(openid => { | ||
152 | + return { openid: openid }; | ||
153 | + }); | ||
154 | + } | ||
155 | + }, | ||
156 | + | ||
157 | + /** | ||
158 | + * 异步拉起微信支付相关处理 | ||
159 | + */ | ||
160 | + pay(user, order, openId) { | ||
20 | 161 | ||
162 | + return co(function* () { | ||
163 | + let unifiedOrderResult = yield tools.unifiedOrder({ | ||
164 | + orderCode: order.order_code, | ||
165 | + totalFee: parseFloat(order.payment_amount), | ||
166 | + openId: openId | ||
167 | + }); | ||
168 | + | ||
169 | + if (unifiedOrderResult) { | ||
170 | + let nonceStr = common.nonceStr(); | ||
171 | + | ||
172 | + let resParams = { | ||
173 | + appId: unifiedOrderResult.appid, | ||
174 | + timeStamp: parseInt(Date.parse(new Date()) / 1000, 10), | ||
175 | + nonceStr: nonceStr, | ||
176 | + package: 'prepay_id=' + unifiedOrderResult.prepay_id, | ||
177 | + signType: 'MD5', | ||
178 | + }; | ||
179 | + | ||
180 | + let paySign = md5(sign.raw(resParams) + '&key=' + WxPayConfig.key).toUpperCase(); | ||
181 | + | ||
182 | + _.assign(resParams, { paySign: paySign }); | ||
21 | return { | 183 | return { |
22 | code: 200, | 184 | code: 200, |
23 | data: { | 185 | data: { |
24 | - href: helpers.urlFormat(url) | 186 | + jsApiParameters: resParams |
25 | } | 187 | } |
26 | }; | 188 | }; |
27 | } else { | 189 | } else { |
28 | - return { | ||
29 | - code: 400, | ||
30 | - message: result.message | ||
31 | - }; | 190 | + return {}; |
32 | } | 191 | } |
33 | - }); | 192 | + |
193 | + })(); | ||
34 | } | 194 | } |
35 | }; | 195 | }; |
36 | 196 |
1 | /** | 1 | /** |
2 | * 各种支付的入口 | 2 | * 各种支付的入口 |
3 | - * TAR NOTE: 本项目中仅支持支付宝和微信支付,其他支付方式需调试 | 3 | + * TAR NOTE: 本项目中仅支持支付宝支付,微信支付,其他支付方式需调试 |
4 | * @author: jiangfeng<jeff.jiang@yoho.cn> | 4 | * @author: jiangfeng<jeff.jiang@yoho.cn> |
5 | * @date: 16/7/22 | 5 | * @date: 16/7/22 |
6 | */ | 6 | */ |
@@ -14,22 +14,23 @@ const Wechat = require('./pay/wechat'); | @@ -14,22 +14,23 @@ const Wechat = require('./pay/wechat'); | ||
14 | const Promise = require('bluebird'); | 14 | const Promise = require('bluebird'); |
15 | const co = Promise.coroutine; | 15 | const co = Promise.coroutine; |
16 | const logger = global.yoho.logger; | 16 | const logger = global.yoho.logger; |
17 | +const common = require('./pay/common'); | ||
17 | 18 | ||
18 | const Payment = { | 19 | const Payment = { |
19 | - pay(user, order, payType, protocol) { | 20 | + |
21 | + /** | ||
22 | + * 统一支付入口 | ||
23 | + * reqParams: 需要从 controller 传递的参数,支付宝需要 req.protocol,微信需要 openId | ||
24 | + */ | ||
25 | + pay(user, order, payType, reqParams) { | ||
20 | return co(function*() { | 26 | return co(function*() { |
21 | let result = { | 27 | let result = { |
22 | code: 400, | 28 | code: 400, |
23 | message: '获取支付方式信息失败' | 29 | message: '获取支付方式信息失败' |
24 | }; | 30 | }; |
25 | - let paymentPars = payType.split('_'); | ||
26 | let payInfo; | 31 | let payInfo; |
27 | let bankCode = ''; | 32 | let bankCode = ''; |
28 | 33 | ||
29 | - if (paymentPars.length !== 2) { | ||
30 | - return result; | ||
31 | - } | ||
32 | - | ||
33 | if (!order.order_code) { | 34 | if (!order.order_code) { |
34 | result.message = '没有找到该订单'; | 35 | result.message = '没有找到该订单'; |
35 | return result; | 36 | return result; |
@@ -45,11 +46,14 @@ const Payment = { | @@ -45,11 +46,14 @@ const Payment = { | ||
45 | // return result; | 46 | // return result; |
46 | // } | 47 | // } |
47 | 48 | ||
48 | - let method = paymentPars[0] * 1; | 49 | + let method = common.getPaymentCode(payType); |
50 | + | ||
51 | + if (!method) { | ||
52 | + return result; | ||
53 | + } | ||
49 | 54 | ||
50 | if (method === PayModel.payments.wechat) { | 55 | if (method === PayModel.payments.wechat) { |
51 | - // 如果是微信支付,不需要调用获取支付方式详情接口 | ||
52 | - result = yield Wechat.pay(user, order, { id: PayModel.payments.wechat }); | 56 | + result = yield Wechat.pay(user, order, reqParams.openId); |
53 | } else { | 57 | } else { |
54 | payInfo = yield PayModel.getPaymentInfo(method); | 58 | payInfo = yield PayModel.getPaymentInfo(method); |
55 | 59 | ||
@@ -59,12 +63,7 @@ const Payment = { | @@ -59,12 +63,7 @@ const Payment = { | ||
59 | 63 | ||
60 | switch (payInfo.id) { | 64 | switch (payInfo.id) { |
61 | case PayModel.payments.alipay: | 65 | case PayModel.payments.alipay: |
62 | - result = Alipay.pay(user, order, payInfo, protocol); | ||
63 | - break; | ||
64 | - case PayModel.payments.alibank: | ||
65 | - bankCode = paymentPars[1]; | ||
66 | - payInfo.bankCode = bankCode; // 设置默认银行 | ||
67 | - result = Alibank.pay(user, order, payInfo, protocol); | 66 | + result = Alipay.pay(user, order, payInfo, reqParams.protocol); |
68 | break; | 67 | break; |
69 | default: | 68 | default: |
70 | break; | 69 | break; |
@@ -73,11 +73,13 @@ const processInvoiceData = (orderInfo, mobile, addresslist) => { | @@ -73,11 +73,13 @@ const processInvoiceData = (orderInfo, mobile, addresslist) => { | ||
73 | id: 11, | 73 | id: 11, |
74 | text: '日用品' | 74 | text: '日用品' |
75 | }, | 75 | }, |
76 | - { | ||
77 | - choosed: invoiceType === 3, | ||
78 | - id: 3, | ||
79 | - text: '办公用品' | ||
80 | - }, | 76 | + |
77 | + // 暂停办公用品开票 | ||
78 | + // { | ||
79 | + // choosed: invoiceType === 3, | ||
80 | + // id: 3, | ||
81 | + // text: '办公用品' | ||
82 | + // }, | ||
81 | { | 83 | { |
82 | choosed: invoiceType === 6, | 84 | choosed: invoiceType === 6, |
83 | id: 6, | 85 | id: 6, |
@@ -19,7 +19,7 @@ const logger = global.yoho.logger; | @@ -19,7 +19,7 @@ const logger = global.yoho.logger; | ||
19 | // 支付方式 | 19 | // 支付方式 |
20 | const payments = { | 20 | const payments = { |
21 | alipay: 33, | 21 | alipay: 33, |
22 | - wechat: 36, | 22 | + wechat: 22, |
23 | alibank: 42 | 23 | alibank: 42 |
24 | }; | 24 | }; |
25 | 25 | ||
@@ -27,10 +27,7 @@ const payments = { | @@ -27,10 +27,7 @@ const payments = { | ||
27 | const _getBanner = (param) => { | 27 | const _getBanner = (param) => { |
28 | return serviceAPI.get('operations/api/v5/resource/get', { | 28 | return serviceAPI.get('operations/api/v5/resource/get', { |
29 | content_code: param.contentCode | 29 | content_code: param.contentCode |
30 | - }, { | ||
31 | - code: 200 | ||
32 | - }).then((result) => { | ||
33 | - | 30 | + }, { code: 200 }).then((result) => { |
34 | result = result.data; | 31 | result = result.data; |
35 | 32 | ||
36 | return result; | 33 | return result; |
@@ -46,10 +43,7 @@ const _getOthersBuy2 = (param) => { | @@ -46,10 +43,7 @@ const _getOthersBuy2 = (param) => { | ||
46 | rec_pos: '100005', | 43 | rec_pos: '100005', |
47 | limit: 2, | 44 | limit: 2, |
48 | client_id: param.client_id | 45 | client_id: param.client_id |
49 | - }, { | ||
50 | - code: 200 | ||
51 | - }).then((result) => { | ||
52 | - | 46 | + }, { code: 200 }).then((result) => { |
53 | if (result && result.data && result.data.product_list) { | 47 | if (result && result.data && result.data.product_list) { |
54 | return productProcess.processProductList(result.data.product_list); | 48 | return productProcess.processProductList(result.data.product_list); |
55 | } | 49 | } |
@@ -64,12 +58,8 @@ const _getOtherDetail = (param) => { | @@ -64,12 +58,8 @@ const _getOtherDetail = (param) => { | ||
64 | uid: param.uid, | 58 | uid: param.uid, |
65 | order_code: param.orderCode, | 59 | order_code: param.orderCode, |
66 | session_key: param.sessionKey | 60 | session_key: param.sessionKey |
67 | - }, { | ||
68 | - code: 200 | ||
69 | - }).then((result) => { | ||
70 | - | 61 | + }, { code: 200 }).then(result => { |
71 | return result; | 62 | return result; |
72 | - | ||
73 | }); | 63 | }); |
74 | }; | 64 | }; |
75 | 65 | ||
@@ -98,7 +88,7 @@ const _getOthersBuy = (param) => { | @@ -98,7 +88,7 @@ const _getOthersBuy = (param) => { | ||
98 | * @param id | 88 | * @param id |
99 | */ | 89 | */ |
100 | const getBankByOrder = (id) => { | 90 | const getBankByOrder = (id) => { |
101 | - return co(function*() { | 91 | + return co(function* () { |
102 | let result = yield payApi.getBankByOrder(id); | 92 | let result = yield payApi.getBankByOrder(id); |
103 | 93 | ||
104 | if (result && result.code === 200 && result.data) { | 94 | if (result && result.code === 200 && result.data) { |
@@ -115,7 +105,7 @@ const getBankByOrder = (id) => { | @@ -115,7 +105,7 @@ const getBankByOrder = (id) => { | ||
115 | * @param bankCode | 105 | * @param bankCode |
116 | */ | 106 | */ |
117 | const setOrderPayBank = (code, payment, bankCode) => { | 107 | const setOrderPayBank = (code, payment, bankCode) => { |
118 | - return co(function*() { | 108 | + return co(function* () { |
119 | let data = yield payApi.setOrderPayBank(code, payment, bankCode); | 109 | let data = yield payApi.setOrderPayBank(code, payment, bankCode); |
120 | 110 | ||
121 | return data; | 111 | return data; |
@@ -127,7 +117,7 @@ const setOrderPayBank = (code, payment, bankCode) => { | @@ -127,7 +117,7 @@ const setOrderPayBank = (code, payment, bankCode) => { | ||
127 | * @param id | 117 | * @param id |
128 | */ | 118 | */ |
129 | const getPaymentInfo = (id) => { | 119 | const getPaymentInfo = (id) => { |
130 | - return co(function*() { | 120 | + return co(function* () { |
131 | let result = yield payApi.getPaymentInfo(id); | 121 | let result = yield payApi.getPaymentInfo(id); |
132 | 122 | ||
133 | if (result && result.code === 200 && result.data) { | 123 | if (result && result.code === 200 && result.data) { |
@@ -144,7 +134,7 @@ const getPaymentInfo = (id) => { | @@ -144,7 +134,7 @@ const getPaymentInfo = (id) => { | ||
144 | * @param uid | 134 | * @param uid |
145 | */ | 135 | */ |
146 | const sendPayConfirm = (code, payment, uid) => { | 136 | const sendPayConfirm = (code, payment, uid) => { |
147 | - return co(function*() { | 137 | + return co(function* () { |
148 | let data = yield payApi.sendPayConfirm(code, payment, uid); | 138 | let data = yield payApi.sendPayConfirm(code, payment, uid); |
149 | 139 | ||
150 | return data; | 140 | return data; |
@@ -174,7 +164,7 @@ const updateOrderPayment = (code, payment, uid) => { | @@ -174,7 +164,7 @@ const updateOrderPayment = (code, payment, uid) => { | ||
174 | * @param bankCode | 164 | * @param bankCode |
175 | */ | 165 | */ |
176 | const updateOrderPayBank = (code, payment, bankCode) => { | 166 | const updateOrderPayBank = (code, payment, bankCode) => { |
177 | - return co(function*() { | 167 | + return co(function* () { |
178 | let data = yield payApi.updateOrderPayBank(code, payment, bankCode); | 168 | let data = yield payApi.updateOrderPayBank(code, payment, bankCode); |
179 | 169 | ||
180 | return data; | 170 | return data; |
@@ -188,7 +178,7 @@ const updateOrderPayBank = (code, payment, bankCode) => { | @@ -188,7 +178,7 @@ const updateOrderPayBank = (code, payment, bankCode) => { | ||
188 | * @param sessionKey | 178 | * @param sessionKey |
189 | */ | 179 | */ |
190 | const procOrderData = (payResult, uid, sessionKey) => { | 180 | const procOrderData = (payResult, uid, sessionKey) => { |
191 | - return co(function*() { | 181 | + return co(function* () { |
192 | let orderCode = payResult.orderCode; | 182 | let orderCode = payResult.orderCode; |
193 | let result = { code: 400, message: '' }; | 183 | let result = { code: 400, message: '' }; |
194 | 184 | ||
@@ -254,7 +244,7 @@ const payTool = { | @@ -254,7 +244,7 @@ const payTool = { | ||
254 | payAppInfo(orderCode) { | 244 | payAppInfo(orderCode) { |
255 | return [{ | 245 | return [{ |
256 | appIcon: '', | 246 | appIcon: '', |
257 | - payLink: helpers.urlFormat('/cart/index/new/pay/goalipay', { | 247 | + payLink: helpers.urlFormat('/cart/index/new/pay', { |
258 | payment: payments.alipay + '_platform', | 248 | payment: payments.alipay + '_platform', |
259 | order_code: orderCode | 249 | order_code: orderCode |
260 | }), | 250 | }), |
@@ -301,17 +291,7 @@ const payCenter = (params) => { | @@ -301,17 +291,7 @@ const payCenter = (params) => { | ||
301 | uid: params.uid, | 291 | uid: params.uid, |
302 | orderCode: params.orderCode | 292 | orderCode: params.orderCode |
303 | }).then(result => { | 293 | }).then(result => { |
304 | - let resultData = _.get(result, 'data', {}); | ||
305 | - | ||
306 | - return { | ||
307 | - payAppInfo: payTool.payAppInfo(params.orderCode), | ||
308 | - orderCode: params.orderCode, | ||
309 | - hasWxShare: true, | ||
310 | - orderTotal: resultData.payment_amount || 0, | ||
311 | - orderTotalFormat: parseInt(resultData.payment_amount, 10), | ||
312 | - orderCount: payTool.calBuyNumCount(resultData.order_goods), | ||
313 | - uid: params.uid | ||
314 | - }; | 294 | + return _.get(result, 'data', {}); |
315 | }); | 295 | }); |
316 | }; | 296 | }; |
317 | 297 | ||
@@ -398,6 +378,7 @@ module.exports = { | @@ -398,6 +378,7 @@ module.exports = { | ||
398 | sendPayConfirm, | 378 | sendPayConfirm, |
399 | procOrderData, | 379 | procOrderData, |
400 | payCenter, | 380 | payCenter, |
381 | + payTool, | ||
401 | getPayCod, | 382 | getPayCod, |
402 | getPayAli | 383 | getPayAli |
403 | }; | 384 | }; |
@@ -26,9 +26,8 @@ router.post('/index/seckill/submit', seckill.submit); | @@ -26,9 +26,8 @@ router.post('/index/seckill/submit', seckill.submit); | ||
26 | router.get('/index/count', countController.cartCount); | 26 | router.get('/index/count', countController.cartCount); |
27 | router.get('/paySuccess/payCod', payController.payCod);// 支付成功,货到付款 | 27 | router.get('/paySuccess/payCod', payController.payCod);// 支付成功,货到付款 |
28 | 28 | ||
29 | -router.get('/index/new/pay', authMW, payController.payCenter);// 支付中心 | ||
30 | -router.get('/index/new/pay/goalipay', authMW, payController.goAlipay);// 跳支付宝支付 | ||
31 | -router.get('/index/new/pay/aliwapreturn', authMW, payController.payAli);// 支付宝付款支付成功 | 29 | +router.get('/index/new/pay', authMW, payController.pay);// 统一支付 URL,支持微信,支付宝 |
30 | +router.get('/index/new/pay/alipayresult', authMW, payController.payAli);// 支付宝付款支付成功 | ||
32 | 31 | ||
33 | router.get('/index/new/orderEnsure', authMW, order.orderEnsure); // 订单结算 | 32 | router.get('/index/new/orderEnsure', authMW, order.orderEnsure); // 订单结算 |
34 | router.get('/index/new/selectCoupon', authMW, order.selectCoupon); // 选择优惠券 页面 | 33 | router.get('/index/new/selectCoupon', authMW, order.selectCoupon); // 选择优惠券 页面 |
@@ -6,15 +6,15 @@ | @@ -6,15 +6,15 @@ | ||
6 | <div class="info"> | 6 | <div class="info"> |
7 | <span class="info-name">{{name}}</span> | 7 | <span class="info-name">{{name}}</span> |
8 | <span class="info-phone">{{phoneNum}}</span> | 8 | <span class="info-phone">{{phoneNum}}</span> |
9 | - <a href="/cart/index/selectAddress"><span class="info-address">{{addressInfo}}</span></a> | 9 | + <a href="/cart/index/new/selectAddress"><span class="info-address">{{addressInfo}}</span></a> |
10 | <i class="iconfont"></i> | 10 | <i class="iconfont"></i> |
11 | </div> | 11 | </div> |
12 | - <a class="rest" href="/cart/index/selectAddress">其他地址<span class="iconfont"></span></a> | 12 | + <a class="rest" href="/cart/index/new/selectAddress">其他地址<span class="iconfont"></span></a> |
13 | </div> | 13 | </div> |
14 | {{else}} | 14 | {{else}} |
15 | <div class="address block address-wrap not-address"> | 15 | <div class="address block address-wrap not-address"> |
16 | <i class="iconfont"></i> | 16 | <i class="iconfont"></i> |
17 | - <a class="choose" href="/cart/index/selectAddress">请选择收货地址<span class="iconfont"></span></a> | 17 | + <a class="choose" href="/cart/index/new/selectAddress">请选择收货地址<span class="iconfont"></span></a> |
18 | </div> | 18 | </div> |
19 | {{/if}} | 19 | {{/if}} |
20 | <section class="dispatch block"> | 20 | <section class="dispatch block"> |
@@ -142,7 +142,7 @@ const _getOrderStatus = (order, showLogistics) => { | @@ -142,7 +142,7 @@ const _getOrderStatus = (order, showLogistics) => { | ||
142 | /* 待付款 */ | 142 | /* 待付款 */ |
143 | Object.assign(result, { | 143 | Object.assign(result, { |
144 | unpaid: true, | 144 | unpaid: true, |
145 | - payUrl: helpers.urlFormat('/home/orders/pay', {order_code: order.order_code}) | 145 | + payUrl: helpers.urlFormat('/home/orders/paynew', {order_code: order.order_code}) |
146 | }); | 146 | }); |
147 | break; | 147 | break; |
148 | case 1: | 148 | case 1: |
@@ -70,7 +70,7 @@ const _getOrderStatus = (order, showLogistics) => { | @@ -70,7 +70,7 @@ const _getOrderStatus = (order, showLogistics) => { | ||
70 | /* 待付款 */ | 70 | /* 待付款 */ |
71 | Object.assign(result, { | 71 | Object.assign(result, { |
72 | unpaid: true, | 72 | unpaid: true, |
73 | - payUrl: helpers.urlFormat('/home/orders/pay', {order_code: order.orderCode}) | 73 | + payUrl: helpers.urlFormat('/home/orders/paynew', {order_code: order.orderCode}) |
74 | }); | 74 | }); |
75 | break; | 75 | break; |
76 | case 1: | 76 | case 1: |
@@ -216,7 +216,7 @@ const orderDetailData = (uid, orderCode) => { | @@ -216,7 +216,7 @@ const orderDetailData = (uid, orderCode) => { | ||
216 | obj = _.assign(obj, { | 216 | obj = _.assign(obj, { |
217 | thumb: data.goodsImage, | 217 | thumb: data.goodsImage, |
218 | name: data.productName, | 218 | name: data.productName, |
219 | - color: data.factoryColorName? data.factoryColorName : data.colorName, | 219 | + color: data.factoryColorName ? data.factoryColorName : data.colorName, |
220 | size: data.sizeName, | 220 | size: data.sizeName, |
221 | price: data.goodsPrice, | 221 | price: data.goodsPrice, |
222 | count: count | 222 | count: count |
@@ -313,8 +313,6 @@ const orderDetailData = (uid, orderCode) => { | @@ -313,8 +313,6 @@ const orderDetailData = (uid, orderCode) => { | ||
313 | cancelReason: resons | 313 | cancelReason: resons |
314 | }); | 314 | }); |
315 | 315 | ||
316 | - //console.log(orderDetail) | ||
317 | - | ||
318 | return orderDetail; | 316 | return orderDetail; |
319 | }); | 317 | }); |
320 | 318 |
@@ -29,6 +29,8 @@ const suggest = require(`${cRoot}/suggest`); | @@ -29,6 +29,8 @@ const suggest = require(`${cRoot}/suggest`); | ||
29 | const message = require(`${cRoot}/message`); | 29 | const message = require(`${cRoot}/message`); |
30 | const onlineService = require(`${cRoot}/onlineService`); | 30 | const onlineService = require(`${cRoot}/onlineService`); |
31 | 31 | ||
32 | +const payController = require('../cart/controllers/pay'); | ||
33 | + | ||
32 | // const myDetail = require(`${cRoot}/myDetail); | 34 | // const myDetail = require(`${cRoot}/myDetail); |
33 | 35 | ||
34 | 36 | ||
@@ -132,4 +134,7 @@ router.get('/installment/card-detail', installment.cardDetail); // 银行å¡è¯¦æ | @@ -132,4 +134,7 @@ router.get('/installment/card-detail', installment.cardDetail); // 银行å¡è¯¦æ | ||
132 | router.get('/installment/delBankCard', installment.delBankCard); // 删除绑定 | 134 | router.get('/installment/delBankCard', installment.delBankCard); // 删除绑定 |
133 | router.get('/installment/setMasterCard', installment.setMasterCard); // 切换主卡 | 135 | router.get('/installment/setMasterCard', installment.setMasterCard); // 切换主卡 |
134 | 136 | ||
137 | +// 支付中心 URL,由于微信安全限制,在现有 URL 后追加 new | ||
138 | +router.get('/orders/paynew', auth, payController.payCenter); | ||
139 | + | ||
135 | module.exports = router; | 140 | module.exports = router; |
@@ -98,6 +98,13 @@ module.exports = { | @@ -98,6 +98,13 @@ module.exports = { | ||
98 | alipayKey: 'kcxawi9bb07mzh0aq2wcirsf9znusobw', | 98 | alipayKey: 'kcxawi9bb07mzh0aq2wcirsf9znusobw', |
99 | sellerMail: 'zfb@yoho.cn', | 99 | sellerMail: 'zfb@yoho.cn', |
100 | merchantUrl: 'http://m.yohobuy.com/home/orders/detail?order_code=' | 100 | merchantUrl: 'http://m.yohobuy.com/home/orders/detail?order_code=' |
101 | + }, | ||
102 | + WxPayConfig: { | ||
103 | + appId: 'wx75e5a7c0c88e45c2', | ||
104 | + mchId: '1227694201', | ||
105 | + key: '7e6f3307b64cc87c79c472814b88f7fb', | ||
106 | + appSecret: 'ce21ae4a3f93852279175a167e54509b', | ||
107 | + notifyUrl: 'payment/alipay_notify', | ||
101 | } | 108 | } |
102 | }; | 109 | }; |
103 | 110 |
@@ -19,6 +19,9 @@ module.exports = app => { | @@ -19,6 +19,9 @@ module.exports = app => { | ||
19 | app.use('/activity', require('./apps/activity')); | 19 | app.use('/activity', require('./apps/activity')); |
20 | app.use('/cart', require('./apps/cart')); | 20 | app.use('/cart', require('./apps/cart')); |
21 | 21 | ||
22 | + // 微信支付的 URL 处理 | ||
23 | + app.use('/shopping', require('./apps/cart')); | ||
24 | + | ||
22 | // 分期付款 | 25 | // 分期付款 |
23 | app.use('/home', require('./apps/home')); | 26 | app.use('/home', require('./apps/home')); |
24 | 27 |
@@ -26,9 +26,9 @@ var $invoice = $('.invoice'), | @@ -26,9 +26,9 @@ var $invoice = $('.invoice'), | ||
26 | isTickets = $('#ticketsPage').val(), | 26 | isTickets = $('#ticketsPage').val(), |
27 | productSku = $('#productSku').val(), | 27 | productSku = $('#productSku').val(), |
28 | buyNumber = $('#buyNumber').val(), | 28 | buyNumber = $('#buyNumber').val(), |
29 | - headerTop = $("#yoho-header").outerHeight(), | ||
30 | - isYohoCoinClick = $coinLi.data('yoho-coin-click') * 1, //判断有货币是否可以单击 | ||
31 | - addressTop = $(".address-wrap").outerHeight(); | 29 | + headerTop = $('#yoho-header').outerHeight(), |
30 | + isYohoCoinClick = $coinLi.data('yoho-coin-click') * 1, // 判断有货币是否可以单击 | ||
31 | + addressTop = $('.address-wrap').outerHeight(); | ||
32 | 32 | ||
33 | var orderCont = window.cookie('order-info') && JSON.parse(window.cookie('order-info')); | 33 | var orderCont = window.cookie('order-info') && JSON.parse(window.cookie('order-info')); |
34 | var invoiceCont = { | 34 | var invoiceCont = { |
@@ -55,7 +55,8 @@ function invoiceInit() { | @@ -55,7 +55,8 @@ function invoiceInit() { | ||
55 | $('.invoice-type').text(invoiceCont[orderCont.invoiceType] + '(' + invoicesType[orderCont.invoicesType] + ')'); | 55 | $('.invoice-type').text(invoiceCont[orderCont.invoiceType] + '(' + invoicesType[orderCont.invoicesType] + ')'); |
56 | } else { | 56 | } else { |
57 | $('.invoice-type').text('服装(电子)'); | 57 | $('.invoice-type').text('服装(电子)'); |
58 | - //$('.invoice-type').text('服装(纸质)'); | 58 | + |
59 | + // $('.invoice-type').text('服装(纸质)'); | ||
59 | } | 60 | } |
60 | } | 61 | } |
61 | 62 | ||
@@ -193,15 +194,15 @@ function orderCompute() { | @@ -193,15 +194,15 @@ function orderCompute() { | ||
193 | skuList: isLimitGood() ? orderInfo('skuList') : undefined | 194 | skuList: isLimitGood() ? orderInfo('skuList') : undefined |
194 | }; | 195 | }; |
195 | 196 | ||
196 | - //门票 | 197 | + // 门票 |
197 | if (isTickets) { | 198 | if (isTickets) { |
198 | data = { | 199 | data = { |
199 | type: 'tickets', | 200 | type: 'tickets', |
200 | productSku: productSku, | 201 | productSku: productSku, |
201 | buyNumber: buyNumber, | 202 | buyNumber: buyNumber, |
202 | yohoCoin: yohoCoin | 203 | yohoCoin: yohoCoin |
203 | - } | ||
204 | - }; | 204 | + }; |
205 | + } | ||
205 | 206 | ||
206 | loading.showLoadingMask(); | 207 | loading.showLoadingMask(); |
207 | $.ajax({ | 208 | $.ajax({ |
@@ -306,7 +307,7 @@ function submitOrder() { | @@ -306,7 +307,7 @@ function submitOrder() { | ||
306 | // 货到付款的进入订单页面 | 307 | // 货到付款的进入订单页面 |
307 | url = '/home/orderDetail?order_code=' + res.data.order_code; | 308 | url = '/home/orderDetail?order_code=' + res.data.order_code; |
308 | } else { | 309 | } else { |
309 | - url = '/home/orders/pay?order_code=' + res.data.order_code; | 310 | + url = '/cart/index/new/pay?order_code=' + res.data.order_code; |
310 | } | 311 | } |
311 | 312 | ||
312 | /* tar add 161116 */ | 313 | /* tar add 161116 */ |
@@ -314,7 +315,7 @@ function submitOrder() { | @@ -314,7 +315,7 @@ function submitOrder() { | ||
314 | window._yas.sendCustomInfo({ | 315 | window._yas.sendCustomInfo({ |
315 | op: 'YB_SC_TOPAY_CLICK', | 316 | op: 'YB_SC_TOPAY_CLICK', |
316 | param: JSON.stringify({ | 317 | param: JSON.stringify({ |
317 | - C_ID: window._ChannelVary[cookie('_Channel')], | 318 | + C_ID: window._ChannelVary[window.cookie('_Channel')], |
318 | ORDER_CODE: res.data.order_code, | 319 | ORDER_CODE: res.data.order_code, |
319 | PRD_NUM: $('#goods-num').val(), | 320 | PRD_NUM: $('#goods-num').val(), |
320 | ORDER_AMOUNT: res.data.order_amount, | 321 | ORDER_AMOUNT: res.data.order_amount, |
@@ -528,7 +529,7 @@ function ticketsConfirm() { | @@ -528,7 +529,7 @@ function ticketsConfirm() { | ||
528 | } | 529 | } |
529 | 530 | ||
530 | // 校验手机号 | 531 | // 校验手机号 |
531 | -$ticketsMobile.blur(function(e) { | 532 | +$ticketsMobile.blur(function() { |
532 | var reg = /^[0123456789]{1,30}$/; | 533 | var reg = /^[0123456789]{1,30}$/; |
533 | var mobile = $ticketsMobile.val(); | 534 | var mobile = $ticketsMobile.val(); |
534 | 535 |
@@ -7,10 +7,10 @@ var loading = require('../plugin/loading'), | @@ -7,10 +7,10 @@ var loading = require('../plugin/loading'), | ||
7 | 7 | ||
8 | 8 | ||
9 | // 点击微信显示加载 | 9 | // 点击微信显示加载 |
10 | -var $loadingToast = $(".loading-toast"); | 10 | +var $loadingToast = $('.loading-toast'); |
11 | 11 | ||
12 | /* TODO 影响加载此段 JS */ | 12 | /* TODO 影响加载此段 JS */ |
13 | -// var theOrderCode = document.getElementById('ordercode').value; | 13 | +var theOrderCode = document.getElementById('ordercode').value; |
14 | 14 | ||
15 | var wxPayEl = document.getElementById('weixin'), | 15 | var wxPayEl = document.getElementById('weixin'), |
16 | wxHammer = wxPayEl && new Hammer(wxPayEl); | 16 | wxHammer = wxPayEl && new Hammer(wxPayEl); |
@@ -36,9 +36,9 @@ if ($('#goods-list').length === 0) { | @@ -36,9 +36,9 @@ if ($('#goods-list').length === 0) { | ||
36 | $('.maybe-like').hide(); | 36 | $('.maybe-like').hide(); |
37 | } | 37 | } |
38 | 38 | ||
39 | -//隐藏微信分享选项 | 39 | +// 隐藏微信分享选项 |
40 | if (window.wx) { | 40 | if (window.wx) { |
41 | - wx.hideOptionMenu(); | 41 | + window.wx.hideOptionMenu(); |
42 | } | 42 | } |
43 | 43 | ||
44 | function onBridgeReady() { | 44 | function onBridgeReady() { |
@@ -61,14 +61,13 @@ if (typeof WeixinJSBridge === undefined) { | @@ -61,14 +61,13 @@ if (typeof WeixinJSBridge === undefined) { | ||
61 | 61 | ||
62 | // 调用微信JS api 支付 | 62 | // 调用微信JS api 支付 |
63 | function jsApiCall(orderCode, jsApiParameters) { | 63 | function jsApiCall(orderCode, jsApiParameters) { |
64 | - $loadingToast.addClass("hide"); | 64 | + $loadingToast.addClass('hide'); |
65 | 65 | ||
66 | // 防止重复操作弹框 | 66 | // 防止重复操作弹框 |
67 | window.WeixinJSBridge && window.WeixinJSBridge.invoke( | 67 | window.WeixinJSBridge && window.WeixinJSBridge.invoke( |
68 | 'getBrandWCPayRequest', | 68 | 'getBrandWCPayRequest', |
69 | jsApiParameters, | 69 | jsApiParameters, |
70 | - function(res) { | ||
71 | - | 70 | + function() { |
72 | window.location.href = '/home/orders/detail?order_code=' + orderCode + '&openId=true'; | 71 | window.location.href = '/home/orders/detail?order_code=' + orderCode + '&openId=true'; |
73 | } | 72 | } |
74 | ); | 73 | ); |
@@ -78,7 +77,7 @@ function jsApiCall(orderCode, jsApiParameters) { | @@ -78,7 +77,7 @@ function jsApiCall(orderCode, jsApiParameters) { | ||
78 | function callpay(orderCode) { | 77 | function callpay(orderCode) { |
79 | var jsApiParameters; | 78 | var jsApiParameters; |
80 | 79 | ||
81 | - $loadingToast.removeClass("hide"); | 80 | + $loadingToast.removeClass('hide'); |
82 | if (typeof WeixinJSBridge === undefined) { | 81 | if (typeof WeixinJSBridge === undefined) { |
83 | if (document.addEventListener) { | 82 | if (document.addEventListener) { |
84 | document.addEventListener('WeixinJSBridgeReady', jsApiCall, false); | 83 | document.addEventListener('WeixinJSBridgeReady', jsApiCall, false); |
@@ -89,9 +88,10 @@ function callpay(orderCode) { | @@ -89,9 +88,10 @@ function callpay(orderCode) { | ||
89 | } else { | 88 | } else { |
90 | $.ajax({ | 89 | $.ajax({ |
91 | type: 'GET', | 90 | type: 'GET', |
92 | - url: '/shopping/pay/wechatwapapi', | 91 | + url: '/cart/index/new/pay', |
93 | data: { | 92 | data: { |
94 | - 'order_code': orderCode | 93 | + order_code: orderCode, |
94 | + payment: '22_platform', | ||
95 | }, | 95 | }, |
96 | dataType: 'json', | 96 | dataType: 'json', |
97 | success: function(res) { | 97 | success: function(res) { |
@@ -106,7 +106,7 @@ function callpay(orderCode) { | @@ -106,7 +106,7 @@ function callpay(orderCode) { | ||
106 | tip.show('请刷新本页面,完成微信支付'); | 106 | tip.show('请刷新本页面,完成微信支付'); |
107 | }, | 107 | }, |
108 | complete: function() { | 108 | complete: function() { |
109 | - $loadingToast.addClass("hide"); | 109 | + $loadingToast.addClass('hide'); |
110 | } | 110 | } |
111 | }); | 111 | }); |
112 | } | 112 | } |
@@ -177,7 +177,7 @@ function showPage() { | @@ -177,7 +177,7 @@ function showPage() { | ||
177 | function bindTouchedEvent() { | 177 | function bindTouchedEvent() { |
178 | var $boxs = $('.box'); | 178 | var $boxs = $('.box'); |
179 | 179 | ||
180 | - $boxs.on('touchstart', function(e) { | 180 | + $boxs.on('touchstart', function() { |
181 | $(this).addClass('bytouch'); | 181 | $(this).addClass('bytouch'); |
182 | }).on('touchend touchcancel', function() { | 182 | }).on('touchend touchcancel', function() { |
183 | $boxs.removeClass('bytouch'); | 183 | $boxs.removeClass('bytouch'); |
@@ -23,7 +23,7 @@ var $invoiceNotice = $('.invoice-notice'), | @@ -23,7 +23,7 @@ var $invoiceNotice = $('.invoice-notice'), | ||
23 | isModifyTel = false; | 23 | isModifyTel = false; |
24 | 24 | ||
25 | var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/, | 25 | var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/, |
26 | - linkUrl = $('.address-more').val() || '/cart/index/orderEnsure?cartType=ordinary'; | 26 | + linkUrl = $('.address-more').val() || '/cart/index/new/orderEnsure?cartType=ordinary'; |
27 | 27 | ||
28 | var C_ID = window._ChannelVary[window.cookie('_Channel')] || 1; | 28 | var C_ID = window._ChannelVary[window.cookie('_Channel')] || 1; |
29 | 29 |
-
Please register or login to post a comment