repayment-list.page.js
3.6 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/**
* 分期还款
* @author: wsl<shuiling.wang@yoho.cn>
* @date: 2016/08/04
*/
let $ = require('yoho-jquery'),
Repayment = require('./repayment'),
tip = require('js/plugin/tip'),
bp = require('./burying-point');
let CHECKBOX_SELECTOR = '.repay-list input';
let curTermNo = {
1: 1,
3: 2,
6: 3,
9: 4,
12: 5
};
let repayment = new Repayment({
onGetSelection: function() {
let ret = [];
$(CHECKBOX_SELECTOR + ':checked').each(function(key, item) {
let li = $(item).parents('li');
let data = {
index: li.index(),
orderCode: li.data('billNo'),
termNo: li.data('currterm'),
amount: parseFloat(li.data('curramt')),
fee: parseFloat(li.data('currfee')) + 0
};
ret.push(data);
});
return ret;
},
onGetSelectableCount: function() {
return $(CHECKBOX_SELECTOR).length;
},
onDeselectAll: function() {
$(CHECKBOX_SELECTOR + ':checked').prop('checked', false);
return [];
},
onSelectAll: function() {
$(CHECKBOX_SELECTOR + ':not(:checked)').prop('checked', true);
return this.getSelection();
}
});
require('./overdue-notice');
$(CHECKBOX_SELECTOR + ':checkbox').click(function() {
let isSkipped = false,
self = this,
billNo = $(self).parent().data('billNo'),
li = $('li[data-bill-no=' + billNo + ']'),
selection = li.find('input:checked'),
lastIndex = li.eq(0).data('currterm');
selection.parent().each(function(index, sel) {
let key = $(sel).data('currterm');
if ((key + 1) - lastIndex > 1) {
isSkipped = true;
} else {
lastIndex = key + 1;
}
});
if (isSkipped) {
setTimeout(function() {
tip.show('同一个分期订单不能跨期还款,请按时间顺序还款');
}, 0);
return false;
}
repayment.update();
});
repayment.update();
$(window).load(function() {
// 统计:各模块的落地页进入时
bp.setContYas({
op: 'YB_INST_REPAYMENT',
appop: 'YB_H5_INST_REPAYMENT_C'
}, {
POS_ID: $('.repayment-list-page').data('posId')
}, true);
});
// 统计yas 需要传的参数
function countYasParams() {
let curBillNo = '';
let opt = {
billNoAll: '',
termNoAll: ''
};
$(CHECKBOX_SELECTOR + ':checked').each(function(key, item) {
curBillNo = $(item).parent().data('billNo');
if (opt.billNoAll.indexOf(curBillNo) < 0) {
opt.billNoAll += (key !== 0) ? ',' : '';
opt.termNoAll += (key !== 0) ? ',' : '';
opt.billNoAll += curBillNo;
opt.termNoAll += curTermNo[$(item).parent().data('terms')];
}
});
return opt;
}
// 统计:立即还款按钮点击时
$('.repayment-btn').on('click', function() {
let opt = countYasParams();
bp.setContYas({
op: 'YB_INST_TOPAY_CLICK',
appop: 'YB_H5_INST_TOPAY_C'
}, {
POS_ID: $('.repayment-list-page').data('posId'),
ORDER_CODE: opt.billNoAll,
INST_STYLE: opt.termNoAll
}, true);
});
// 统计:列表项点击右边箭头时
$('.list-right a').on('click', function() {
let li = $(this).parents('li');
bp.setContYas({
op: 'YB_INST_TOPAY_INFO',
appop: 'YB_H5_INST_TOPAY_INFO_C'
}, {
POS_ID: $('.repayment-list-page').data('posId'),
ORDER_CODE: li.data('billNo'),
INST_STYLE: curTermNo[li.data('terms')],
PERIODS: li.data('currterm')
}, true);
});