pay.page.js
1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
* Created by TaoHuang on 2016/7/18.
*/
var $ = require('yoho-jquery');
var $orderDetail = $('.order-detail');
var Dialog = require('../plugins/dialog').Dialog;
var tpl = '<div class="pay-page-tips">' +
'<h3>请您在新打开的页面完成付款</h3>' +
'<p>付款完成前请不要关闭此窗口</p>' +
'<p>完成付款后请根据您的情况点击下面的按钮</p>' +
'<div><a href="/me/order"><span class="btn">已完成付款</span></a>' +
'<span class="btn white close-btn">更换支付方式</span>' +
'</div>' +
'</div>';
var infoDaialog = new Dialog({
className: 'pay-info-dialog',
content: tpl,
keep: true
});
// 展开详情/收起详情
$('#order-detail-ctrl').click(function() {
var $this = $(this);
$this.toggleClass('shrink');
if ($this.hasClass('shrink')) {
// 收起状态
$this.find('em').text('展开详情');
} else {
// 展开状态
$this.find('em').text('收起详情');
}
$orderDetail.toggleClass('hide');
});
$('.pay-type-icon').click(function() {
var $this = $(this);
if ($this.hasClass('active')) {
return;
}
// 切换选中状态
$this.siblings('.active').removeClass('active');
$this.addClass('active');
$('#pay-type-name').text($this.data('name'));
});
function showDialog() {
infoDaialog.show();
$('.pay-page-tips .btn.close-btn').off().on('click', function() {
infoDaialog.close();
});
}
// 去支付
$('#go-pay-btn').click(function() {
var payType = $('.pay-type-icon.active').data('id');
var order = $(this).data('order');
$.ajax({
type: 'POST',
url: '/shopping/pay/online/go',
async: false,
data: {
code: order,
method: payType
}
}).then(function(data) {
if (data.code === 200) {
window.open(data.data.href);
showDialog();
}
});
});
console.log(window.history);