Showing
7 changed files
with
197 additions
and
51 deletions
@@ -26,7 +26,7 @@ const online = (req, res, next) => { | @@ -26,7 +26,7 @@ const online = (req, res, next) => { | ||
26 | let uid = req.user.uid; | 26 | let uid = req.user.uid; |
27 | 27 | ||
28 | if (!integerTest.test(orderCode)) { | 28 | if (!integerTest.test(orderCode)) { |
29 | - //不合法订单号 | 29 | + // 不合法订单号 |
30 | return next(); | 30 | return next(); |
31 | } | 31 | } |
32 | 32 | ||
@@ -37,7 +37,7 @@ const online = (req, res, next) => { | @@ -37,7 +37,7 @@ const online = (req, res, next) => { | ||
37 | let amount = _.toNumber(order.paymentAmount); | 37 | let amount = _.toNumber(order.paymentAmount); |
38 | 38 | ||
39 | if (!order.orderCode) { | 39 | if (!order.orderCode) { |
40 | - //不合法订单号 | 40 | + // 不合法订单号 |
41 | return next(); | 41 | return next(); |
42 | } | 42 | } |
43 | 43 | ||
@@ -91,7 +91,7 @@ const toPay = (req, res, next) => { | @@ -91,7 +91,7 @@ const toPay = (req, res, next) => { | ||
91 | let user = req.user; | 91 | let user = req.user; |
92 | 92 | ||
93 | if (!integerTest.test(orderCode)) { | 93 | if (!integerTest.test(orderCode)) { |
94 | - //不合法订单号 | 94 | + // 不合法订单号 |
95 | return next(); | 95 | return next(); |
96 | } | 96 | } |
97 | 97 | ||
@@ -125,7 +125,7 @@ const weixinQr = (req, res, next) => { | @@ -125,7 +125,7 @@ const weixinQr = (req, res, next) => { | ||
125 | let uid = req.user.uid; | 125 | let uid = req.user.uid; |
126 | 126 | ||
127 | if (!integerTest.test(code)) { | 127 | if (!integerTest.test(code)) { |
128 | - //不合法订单号 | 128 | + // 不合法订单号 |
129 | return next(); | 129 | return next(); |
130 | } | 130 | } |
131 | 131 |
apps/shopping/models/bank.js
0 → 100644
1 | +/** | ||
2 | + * Created by TaoHuang on 2016/7/18. | ||
3 | + */ | ||
4 | +'use strict'; | ||
5 | + | ||
6 | +const Bank = { | ||
7 | + getList: () => { | ||
8 | + return { | ||
9 | + { | ||
10 | + id: 12, | ||
11 | + name: '中国银行', | ||
12 | + value: 'BOCB2C', | ||
13 | + ico: '//static.yohobuy.com/images/pay/icon/zhongguo.png' | ||
14 | + }, | ||
15 | + { | ||
16 | + id: 12, | ||
17 | + name: '中国农业银行', | ||
18 | + value: 'ABC', | ||
19 | + ico: '//static.yohobuy.com/images/pay/icon/nongye.png' | ||
20 | + }, | ||
21 | + { | ||
22 | + id: 12, | ||
23 | + name: '平安银行', | ||
24 | + value: 'SPABANK', | ||
25 | + ico: '//static.yohobuy.com/images/pay/icon/pingan.png' | ||
26 | + }, | ||
27 | + { | ||
28 | + id: 12, | ||
29 | + name: '中国民生银行', | ||
30 | + value: 'CMBC', | ||
31 | + ico: '//static.yohobuy.com/images/pay/icon/minsheng.png' | ||
32 | + }, | ||
33 | + { | ||
34 | + id: 12, | ||
35 | + name: '中国工商银行', | ||
36 | + value: 'ICBCB2C', | ||
37 | + ico: '//static.yohobuy.com/images/pay/icon/gongshang.png' | ||
38 | + }, | ||
39 | + { | ||
40 | + id: 12, | ||
41 | + name: '浦发银行', | ||
42 | + value: 'SPDB', | ||
43 | + ico: '//static.yohobuy.com/images/pay/icon/pufa.png' | ||
44 | + }, | ||
45 | + { | ||
46 | + id: 12, | ||
47 | + name: '北京农商银行', | ||
48 | + value: 'BJRCB', | ||
49 | + ico: '//static.yohobuy.com/images/pay/icon/beijingnongshang.png' | ||
50 | + }, | ||
51 | + { | ||
52 | + id: 12, | ||
53 | + name: '杭州银行', | ||
54 | + value: 'HZCBB2C', | ||
55 | + ico: '//static.yohobuy.com/images/pay/icon/hangzhou.png' | ||
56 | + }, | ||
57 | + { | ||
58 | + id: 12, | ||
59 | + name: '招商银行', | ||
60 | + value: 'CMB', | ||
61 | + ico: '//static.yohobuy.com/images/pay/icon/zhaoshang.png' | ||
62 | + }, | ||
63 | + { | ||
64 | + id: 12, | ||
65 | + name: '兴业银行', | ||
66 | + value: 'CIB', | ||
67 | + ico: '//static.yohobuy.com/images/pay/icon/xingye.png' | ||
68 | + }, | ||
69 | + { | ||
70 | + id: 12, | ||
71 | + name: '富滇银行', | ||
72 | + value: 'FDB', | ||
73 | + ico: '//static.yohobuy.com/images/pay/icon/fudian.png' | ||
74 | + }, | ||
75 | + { | ||
76 | + id: 12, | ||
77 | + name: '中国光大银行', | ||
78 | + value: 'CEBDEBIT', | ||
79 | + ico: '//static.yohobuy.com/images/pay/icon/guangda.png' | ||
80 | + }, | ||
81 | + { | ||
82 | + id: 12, | ||
83 | + name: '中国建设银行', | ||
84 | + value: 'CCB', | ||
85 | + ico: '//static.yohobuy.com/images/pay/icon/zhongguojianshe.png' | ||
86 | + }, | ||
87 | + { | ||
88 | + id: 12, | ||
89 | + name: '广发银行', | ||
90 | + value: 'GDB', | ||
91 | + ico: '//static.yohobuy.com/images/pay/icon/guangfa.png' | ||
92 | + }, | ||
93 | + { | ||
94 | + id: 12, | ||
95 | + name: '中国邮政储蓄', | ||
96 | + value: 'POSTGC', | ||
97 | + ico: '//static.yohobuy.com/images/pay/icon/zhongguoyouzhengchuxu.png' | ||
98 | + }, | ||
99 | + { | ||
100 | + id: 12, | ||
101 | + name: '上海银行', | ||
102 | + value: 'SHBANK', | ||
103 | + ico: '//static.yohobuy.com/images/pay/icon/shanghai.png' | ||
104 | + }, | ||
105 | + { | ||
106 | + id: 12, | ||
107 | + name: '宁波银行', | ||
108 | + value: 'NBBANK', | ||
109 | + ico: '//static.yohobuy.com/images/pay/icon/ningbo.png' | ||
110 | + } | ||
111 | + }; | ||
112 | + } | ||
113 | +}; | ||
114 | + | ||
115 | +module.exports = Bank; |
@@ -8,14 +8,14 @@ | @@ -8,14 +8,14 @@ | ||
8 | 8 | ||
9 | const api = global.yoho.API; | 9 | const api = global.yoho.API; |
10 | 10 | ||
11 | -//获取支付宝等平台支付方式列表 | 11 | +// 获取支付宝等平台支付方式列表 |
12 | const getPayProvider = () => { | 12 | const getPayProvider = () => { |
13 | return api.get('', { | 13 | return api.get('', { |
14 | method: 'web.SpaceOrders.getPaymentList' | 14 | method: 'web.SpaceOrders.getPaymentList' |
15 | }); | 15 | }); |
16 | }; | 16 | }; |
17 | 17 | ||
18 | -//获取单个支付方式相关详细信息 | 18 | +// 获取单个支付方式相关详细信息 |
19 | const getPaymentInfo = (id) => { | 19 | const getPaymentInfo = (id) => { |
20 | return api.get('', { | 20 | return api.get('', { |
21 | method: 'web.SpaceOrders.getPaymentById', | 21 | method: 'web.SpaceOrders.getPaymentById', |
@@ -23,7 +23,7 @@ const getPaymentInfo = (id) => { | @@ -23,7 +23,7 @@ const getPaymentInfo = (id) => { | ||
23 | }); | 23 | }); |
24 | }; | 24 | }; |
25 | 25 | ||
26 | -/*获取上次使用的支付方式*/ | 26 | +/* 获取上次使用的支付方式*/ |
27 | const getBankByOrder = (code) => { | 27 | const getBankByOrder = (code) => { |
28 | return api.get('', { | 28 | return api.get('', { |
29 | method: 'web.SpaceOrders.getOrderPayBank', | 29 | method: 'web.SpaceOrders.getOrderPayBank', |
@@ -31,7 +31,7 @@ const getBankByOrder = (code) => { | @@ -31,7 +31,7 @@ const getBankByOrder = (code) => { | ||
31 | }); | 31 | }); |
32 | }; | 32 | }; |
33 | 33 | ||
34 | -/*记录支付方式*/ | 34 | +/* 记录支付方式*/ |
35 | const setOrderPayBank = (code, payment, bankCode) => { | 35 | const setOrderPayBank = (code, payment, bankCode) => { |
36 | return api.get('', { | 36 | return api.get('', { |
37 | method: 'web.SpaceOrders.addOrderPayBank', | 37 | method: 'web.SpaceOrders.addOrderPayBank', |
@@ -41,7 +41,7 @@ const setOrderPayBank = (code, payment, bankCode) => { | @@ -41,7 +41,7 @@ const setOrderPayBank = (code, payment, bankCode) => { | ||
41 | }); | 41 | }); |
42 | }; | 42 | }; |
43 | 43 | ||
44 | -/*更改支付方式*/ | 44 | +/* 更改支付方式*/ |
45 | const updateOrderPayBank = (code, payment, bankCode) => { | 45 | const updateOrderPayBank = (code, payment, bankCode) => { |
46 | return api.get('', { | 46 | return api.get('', { |
47 | method: 'web.SpaceOrders.modifyOrderPayBank', | 47 | method: 'web.SpaceOrders.modifyOrderPayBank', |
@@ -51,7 +51,7 @@ const updateOrderPayBank = (code, payment, bankCode) => { | @@ -51,7 +51,7 @@ const updateOrderPayBank = (code, payment, bankCode) => { | ||
51 | }); | 51 | }); |
52 | }; | 52 | }; |
53 | 53 | ||
54 | -/*发送支付确认*/ | 54 | +/* 发送支付确认*/ |
55 | const sendPayConfirm = (code, payment, uid) => { | 55 | const sendPayConfirm = (code, payment, uid) => { |
56 | return api.get('', { | 56 | return api.get('', { |
57 | method: 'app.SpaceOrders.payConfirm', | 57 | method: 'app.SpaceOrders.payConfirm', |
@@ -61,7 +61,7 @@ const sendPayConfirm = (code, payment, uid) => { | @@ -61,7 +61,7 @@ const sendPayConfirm = (code, payment, uid) => { | ||
61 | }); | 61 | }); |
62 | }; | 62 | }; |
63 | 63 | ||
64 | -/*选择支付,校验时间间隔,插入数据,为用户取消订单做准备<用户支付取消订单,10分钟间隔>。*/ | 64 | +/* 选择支付,校验时间间隔,插入数据,为用户取消订单做准备<用户支付取消订单,10分钟间隔>。*/ |
65 | const savePrePayInfo = (code, payment, uid) => { | 65 | const savePrePayInfo = (code, payment, uid) => { |
66 | return api.get('', { | 66 | return api.get('', { |
67 | method: 'app.order.savePrePayInfo', | 67 | method: 'app.order.savePrePayInfo', |
@@ -12,6 +12,7 @@ const Promise = require('bluebird'); | @@ -12,6 +12,7 @@ const Promise = require('bluebird'); | ||
12 | const co = Promise.coroutine; | 12 | const co = Promise.coroutine; |
13 | const camelCase = global.yoho.camelCase; | 13 | const camelCase = global.yoho.camelCase; |
14 | const OrderData = require('./order'); | 14 | const OrderData = require('./order'); |
15 | +const payHelpersBank = require('./../helpers/bank'); | ||
15 | const logger = global.yoho.logger; | 16 | const logger = global.yoho.logger; |
16 | 17 | ||
17 | 18 | ||
@@ -28,34 +29,48 @@ const payments = { | @@ -28,34 +29,48 @@ const payments = { | ||
28 | */ | 29 | */ |
29 | const getOnlinePayProvider = () => { | 30 | const getOnlinePayProvider = () => { |
30 | return api.getPayProvider().then(result => { | 31 | return api.getPayProvider().then(result => { |
32 | + let payPattern = [], nav = []; | ||
33 | + | ||
31 | if (!(result.code && result.code === 200)) { | 34 | if (!(result.code && result.code === 200)) { |
32 | - return []; | 35 | + return payPattern; |
33 | } | 36 | } |
34 | 37 | ||
35 | - let online = _(result.data) | ||
36 | - .filter(i => _.includes(_.values(payments), i.id)) | ||
37 | - .map(i => { | ||
38 | - return { | ||
39 | - id: i.id, | ||
40 | - name: i.payName, | ||
41 | - img: i.payIcon, | ||
42 | - selected: i.id === payments.alipay | ||
43 | - }; | ||
44 | - }) | ||
45 | - .value(); | ||
46 | - | ||
47 | - let nav = [ | ||
48 | - { | ||
49 | - id: 'onlinePay', | ||
50 | - name: '支付宝等平台', | ||
51 | - selected: true | 38 | + // 处理支付宝等平台数据 |
39 | + _.each(result.data, val => { | ||
40 | + // 去除icon为空的 | ||
41 | + if (_.isEmpty(val.payIcon)) { | ||
42 | + return true; | ||
52 | } | 43 | } |
53 | - ]; | ||
54 | 44 | ||
55 | - return { | ||
56 | - type: nav, | ||
57 | - onlinePay: online | ||
58 | - }; | 45 | + nav.push({ |
46 | + id: val.id, | ||
47 | + name: val.payName, | ||
48 | + value: val.id + '_platform', | ||
49 | + img: val.payIcon | ||
50 | + }); | ||
51 | + }); | ||
52 | + payPattern.push({ | ||
53 | + name: '支付宝等平台', | ||
54 | + children: nav | ||
55 | + }); | ||
56 | + | ||
57 | + // 处理使用银行卡数据 | ||
58 | + nav = []; | ||
59 | + _.each(payHelpersBank.getList(), (val, key) => { | ||
60 | + nav.push({ | ||
61 | + id: 12, | ||
62 | + name: val.name, | ||
63 | + value: '12_' + key, | ||
64 | + img: val.ico | ||
65 | + }); | ||
66 | + }); | ||
67 | + payPattern.push({ | ||
68 | + name: '使用银行卡', | ||
69 | + selected: true, | ||
70 | + children: nav | ||
71 | + }); | ||
72 | + | ||
73 | + return payPattern; | ||
59 | }); | 74 | }); |
60 | }; | 75 | }; |
61 | 76 |
@@ -44,26 +44,27 @@ | @@ -44,26 +44,27 @@ | ||
44 | </div> | 44 | </div> |
45 | {{/order}} | 45 | {{/order}} |
46 | 46 | ||
47 | - {{# pay}} | 47 | + {{#if pay}} |
48 | <div class="pay-type"> | 48 | <div class="pay-type"> |
49 | <div class="pay-nav"> | 49 | <div class="pay-nav"> |
50 | <ul class="tabs clearfix"> | 50 | <ul class="tabs clearfix"> |
51 | - {{#each type}} | ||
52 | - <li{{#if selected}} class="active"{{/if}} data-type="{{id}}">{{name}}</li> | ||
53 | - {{/each}} | 51 | + {{# pay}} |
52 | + <li{{#if selected}} class="active"{{/if}}>{{name}}</li> | ||
53 | + {{/pay}} | ||
54 | </ul> | 54 | </ul> |
55 | </div> | 55 | </div> |
56 | - | ||
57 | - <div id="online"> | ||
58 | - {{# onlinePay}} | ||
59 | - <div class="pay-type-icon online-pay{{#if selected}} active{{/if}}" data-name="{{name}}" data-id="{{id}}"> | ||
60 | - <img src="{{img}}"> | ||
61 | - <span class="choose-tag iconfont"></span> | ||
62 | - </div> | ||
63 | - {{/ onlinePay}} | ||
64 | - </div> | 56 | + {{# pay}} |
57 | + <div class="pay-icon {{#unless selected}} hide{{/unless}}"> | ||
58 | + {{# children}} | ||
59 | + <div class="pay-type-icon online-pay{{#if selected}} active{{/if}}" data-name="{{name}}" data-id="{{id}}" data-value="{{value}}"> | ||
60 | + <img src="{{img}}"> | ||
61 | + <span class="choose-tag iconfont"></span> | ||
62 | + </div> | ||
63 | + {{/children}} | ||
64 | + </div> | ||
65 | + {{/pay}} | ||
65 | </div> | 66 | </div> |
66 | - {{/ pay}} | 67 | + {{/if}} |
67 | 68 | ||
68 | <div class="pay-ctrl"> | 69 | <div class="pay-ctrl"> |
69 | <span id="go-pay-btn" class="btn btn-shape right" data-order="{{order.orderCode}}">去<em id="pay-type-name">支付宝</em>支付</span> | 70 | <span id="go-pay-btn" class="btn btn-shape right" data-order="{{order.orderCode}}">去<em id="pay-type-name">支付宝</em>支付</span> |
@@ -9,6 +9,9 @@ var $orderDetail = $('.order-detail'), | @@ -9,6 +9,9 @@ var $orderDetail = $('.order-detail'), | ||
9 | 9 | ||
10 | var Dialog = require('../plugins/dialog'); | 10 | var Dialog = require('../plugins/dialog'); |
11 | 11 | ||
12 | +var $payTypeIcon = $('.pay-type-icon'), | ||
13 | + $payIcon = $('.pay-icon'); | ||
14 | + | ||
12 | var tpl = '<div class="pay-page-tips">' + | 15 | var tpl = '<div class="pay-page-tips">' + |
13 | '<h3>请您在新打开的页面完成付款</h3>' + | 16 | '<h3>请您在新打开的页面完成付款</h3>' + |
14 | '<p>付款完成前请不要关闭此窗口</p>' + | 17 | '<p>付款完成前请不要关闭此窗口</p>' + |
@@ -40,7 +43,7 @@ $orderDetailCtrl.click(function() { | @@ -40,7 +43,7 @@ $orderDetailCtrl.click(function() { | ||
40 | $orderDetail.slideToggle('slow'); | 43 | $orderDetail.slideToggle('slow'); |
41 | }); | 44 | }); |
42 | 45 | ||
43 | -$('.pay-type-icon').click(function() { | 46 | +$payTypeIcon.click(function() { |
44 | var $this = $(this); | 47 | var $this = $(this); |
45 | 48 | ||
46 | if ($this.hasClass('active')) { | 49 | if ($this.hasClass('active')) { |
@@ -48,12 +51,24 @@ $('.pay-type-icon').click(function() { | @@ -48,12 +51,24 @@ $('.pay-type-icon').click(function() { | ||
48 | } | 51 | } |
49 | 52 | ||
50 | // 切换选中状态 | 53 | // 切换选中状态 |
51 | - $this.siblings('.active').removeClass('active'); | 54 | + $payTypeIcon.removeClass('active'); |
52 | $this.addClass('active'); | 55 | $this.addClass('active'); |
53 | 56 | ||
54 | $('#pay-type-name').text($this.data('name')); | 57 | $('#pay-type-name').text($this.data('name')); |
55 | }); | 58 | }); |
56 | 59 | ||
60 | +// 切换支付方式tabs 委托事件 | ||
61 | +$('.pay-nav .tabs').click(function(event) { | ||
62 | + var $li = $(event.target).closest('li'); | ||
63 | + | ||
64 | + if ($li.length <= 0) { | ||
65 | + return true; | ||
66 | + } | ||
67 | + | ||
68 | + $li.addClass('active').siblings('li').removeClass('active'); | ||
69 | + $payIcon.eq($li.index()).removeClass('hide').siblings('.pay-icon').addClass('hide'); | ||
70 | + | ||
71 | +}); | ||
57 | 72 | ||
58 | function showDialog() { | 73 | function showDialog() { |
59 | infoDaialog.show(); | 74 | infoDaialog.show(); |
-
Please register or login to post a comment