pay.js
3.17 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/**
* 支付页面
*/
//切换选项卡
var $ = require('yoho.jquery'),
$choseTag = $('.mode div'),
$mode = $('.mode'),
$showPayImg = $('#show-pay-img'),
$btnty = $('#btnby'),
$lightBox = $('.light-box'),
$choosePay = $('#choosePay').val(),
$chooseMoid = $('.mode div[id="' + $choosePay + '"]').parent().data('value'),
$showValue = $choosePay ? $chooseMoid : $('.mode').eq(0).data('value'),
$payUrl = $('#payUrl').val(),
$modeData,
activeTab,
imgAlt,
imgSrc,
payment,
orderCode = $('.order-num').text(),
orderCount = $('.order-num').siblings('strong').text();
$.jqtab = function(tabtit, tabcon) {
$(tabtit + ' li').click(function() {
activeTab = $(this).find('a').attr('tab');
$(tabtit + ' li').removeClass('thistab');
$(this).addClass('thistab');
$(tabcon).hide();
$('#' + activeTab).fadeIn();
return false;
});
};
$.jqtab('#tabs', '.tab-con');
//选项卡点击
function choosed() {
if ($choosePay) {
$('.mode div[id="' + $choosePay + '"]').addClass('choosed-tag').parent().addClass('choose-type');
} else {
$mode.eq(0).addClass('choose-type').show();
$mode.eq(0).find('div').addClass('choosed-tag');
}
$btnty.attr('value', '前往' + $('#' + $chooseMoid).attr('alt'));
$showPayImg.attr('src', $('#' + $chooseMoid).attr('src'));
}
choosed();
$mode.click(function() {
$modeData = $(this).data();
$showValue = $modeData.value;
imgAlt = $('#' + $showValue).attr('alt');
imgSrc = $('#' + $showValue).attr('src');
$mode.removeClass('choose-type');
$(this).addClass('choose-type');
$choseTag.removeClass('choosed-tag');
$(this).find('.borer-tag').addClass('choosed-tag');
$btnty.attr('value', '前往' + imgAlt);
$showPayImg.attr('src', imgSrc);
return false;
});
$('.close').click(function() {
$lightBox.hide();
});
$('.change').click(function() {
$lightBox.hide();
});
//支付方式选择按钮
function getData(payment, orderCode) {
$.ajax({
type: 'get',
url: '/common/addpaymentinterval',
dataType: 'json',
data: {
orderCode: orderCode,
payment: payment
}
});
}
$('#btnby').click(function() {
payment = $('.choose-type').attr('data-id');
orderCode = $('.order-num').text();
getData(payment, orderCode);
// 埋点
window.addPoint('YB_SC_PAYMENT_TOPAY_CLICK', {ORDER_CODE: orderCode, ORDER_AMOUNT: orderCount, PAY_STYLE: payment});
window.open($payUrl + '?order_code=' + orderCode + '&payment_type=' + $showValue);
$lightBox.show();
});
//发送支付确认
$('.pay-over').unbind('click').bind('click', function() {
var _this = this;
$.post('/shopping/pay/sendPay',
{
orderCode: orderCode,
paymentId: payment
},
function() {
window.location.href = $(_this).data('url');
}
);
});
$(function() {
// 默认埋点
window.addPoint('YB_SC_PAYMENT', {ORDER_CODE: orderCode, ORDER_AMOUNT: orderCount});
})