|
@@ -5,162 +5,65 @@ |
|
@@ -5,162 +5,65 @@ |
5
|
*/
|
5
|
*/
|
6
|
|
6
|
|
7
|
var $ = require('yoho-jquery'),
|
7
|
var $ = require('yoho-jquery'),
|
|
|
8
|
+ Repayment = require('./repayment'),
|
8
|
tip = require('../plugin/tip');
|
9
|
tip = require('../plugin/tip');
|
9
|
|
10
|
|
10
|
-var $currAmt = $('.repayment-bottom').find('.curr-amt'),
|
|
|
11
|
- $currFee = $('.repayment-bottom').find('.curr-fee'),
|
|
|
12
|
- $servePrice = $('.serve-price');
|
11
|
+var CHECKBOX_SELECTOR = '.repay-list input';
|
|
|
12
|
+var repayment = new Repayment({
|
|
|
13
|
+ onGetSelection: function() {
|
|
|
14
|
+ var ret = [];
|
13
|
|
15
|
|
14
|
-require('./overdue-notice');
|
|
|
15
|
-
|
|
|
16
|
-// 选择分期统计
|
|
|
17
|
-function totalChecked(index) {
|
|
|
18
|
- var total = 0;
|
|
|
19
|
-
|
|
|
20
|
- // 按时间顺序选择还款,不可以跨期
|
|
|
21
|
- $('.repay-list input').each(function(key, item) {
|
|
|
22
|
- if (key < index && $(item).is(':checked')) {
|
|
|
23
|
- total++;
|
|
|
24
|
- }
|
|
|
25
|
- });
|
|
|
26
|
-
|
|
|
27
|
- return total;
|
|
|
28
|
-}
|
|
|
29
|
-
|
|
|
30
|
-// 取消分期统计
|
|
|
31
|
-function totalCancelChecked(index) {
|
|
|
32
|
- var total = 0;
|
|
|
33
|
-
|
|
|
34
|
- $('.repay-list input').each(function(key, item) {
|
|
|
35
|
- if (key > index && $(item).is(':checked')) {
|
|
|
36
|
- total++;
|
|
|
37
|
- }
|
|
|
38
|
- });
|
|
|
39
|
-
|
|
|
40
|
- return total;
|
|
|
41
|
-}
|
|
|
42
|
-
|
|
|
43
|
-$('.repay-list label').on('click', function() {
|
|
|
44
|
- var li = $(this).parents('li'),
|
|
|
45
|
- index = li.index(),
|
|
|
46
|
- $input = $(this).prev(),
|
|
|
47
|
- currAmt = +$currAmt.html(),
|
|
|
48
|
- currFee = +$currFee.html(),
|
|
|
49
|
- amt = +li.attr('data-curramt'),
|
|
|
50
|
- fee = +li.attr('data-currfee'),
|
|
|
51
|
- count = 0,
|
|
|
52
|
- total = 0;
|
16
|
+ $(`${CHECKBOX_SELECTOR}:checked`).each(function(key, item) {
|
|
|
17
|
+ var li = $(item).parents('li');
|
53
|
|
18
|
|
54
|
- if ($input.is(':checked')) {
|
|
|
55
|
- total = totalCancelChecked(index);
|
19
|
+ var data = {
|
|
|
20
|
+ index: li.index(),
|
|
|
21
|
+ orderCode: li.attr('data-billno'),
|
|
|
22
|
+ termNo: li.attr('data-termNo'),
|
|
|
23
|
+ amount: parseFloat(li.attr('data-currNoFeeAmt')),
|
|
|
24
|
+ fee: parseFloat(li.attr('data-currfee')) + 0
|
|
|
25
|
+ };
|
56
|
|
26
|
|
57
|
- if (total === 0) {
|
|
|
58
|
- $currAmt.html((currAmt - amt).toFixed(2));
|
|
|
59
|
- $currFee.html((currFee - fee).toFixed(2));
|
|
|
60
|
- } else {
|
|
|
61
|
- tip.show('请按时间顺序取消选择,不可以跨期');
|
|
|
62
|
- return false;
|
|
|
63
|
- }
|
|
|
64
|
- } else {
|
|
|
65
|
- total = totalChecked(index);
|
|
|
66
|
-
|
|
|
67
|
- if (total === index) {
|
|
|
68
|
- $currAmt.html((amt + currAmt).toFixed(2));
|
|
|
69
|
- $currFee.html((fee + currFee).toFixed(2));
|
|
|
70
|
- } else {
|
|
|
71
|
- tip.show('请按时间顺序添加还款,不可以跨期');
|
|
|
72
|
- return false;
|
|
|
73
|
- }
|
|
|
74
|
- }
|
27
|
+ ret.push(data);
|
|
|
28
|
+ });
|
75
|
|
29
|
|
76
|
- if (parseFloat($currFee.html()) > 0) {
|
|
|
77
|
- $servePrice.show();
|
|
|
78
|
- } else {
|
|
|
79
|
- $servePrice.hide();
|
30
|
+ return ret;
|
|
|
31
|
+ },
|
|
|
32
|
+ onDeselectAll: function() {
|
|
|
33
|
+ $(`${CHECKBOX_SELECTOR}:checked`).prop('checked', false);
|
|
|
34
|
+ return [];
|
|
|
35
|
+ },
|
|
|
36
|
+ onSelectAll: function() {
|
|
|
37
|
+ $(`${CHECKBOX_SELECTOR}:not(:checked)`).prop('checked', true);
|
|
|
38
|
+ return this.getSelection();
|
80
|
}
|
39
|
}
|
81
|
-
|
|
|
82
|
- setTimeout(function() {
|
|
|
83
|
- count = $('.repay-list input:checked').length;
|
|
|
84
|
- $('#repayment-total').prop('checked', count === $('.repay-list li').length);
|
|
|
85
|
- }, 0);
|
|
|
86
|
});
|
40
|
});
|
87
|
|
41
|
|
88
|
-// 全选||全不选
|
|
|
89
|
-$('.repayment-bottom label').on('click', function() {
|
|
|
90
|
- var totalAmt = 0;
|
|
|
91
|
- var totalFee = 0;
|
|
|
92
|
-
|
|
|
93
|
- if ($(this).prev().is(':checked')) {
|
|
|
94
|
- $('.repay-list input').prop('checked', false);
|
|
|
95
|
- $currAmt.html('0.00');
|
|
|
96
|
- $currFee.html('0.00');
|
|
|
97
|
- $servePrice.hide();
|
|
|
98
|
- } else {
|
|
|
99
|
- $('.repay-list input').prop('checked', true);
|
|
|
100
|
- $('.repay-list li').each(function() {
|
|
|
101
|
- totalAmt += (+$(this).attr('data-curramt'));
|
|
|
102
|
- totalFee += (+$(this).attr('data-currfee'));
|
|
|
103
|
- });
|
42
|
+require('./overdue-notice');
|
104
|
|
43
|
|
105
|
- $currAmt.html(totalAmt.toFixed(2));
|
|
|
106
|
- $currFee.html(totalFee.toFixed(2));
|
44
|
+$(CHECKBOX_SELECTOR + ':checkbox').click(function() {
|
|
|
45
|
+ var selection = repayment.getSelection();
|
|
|
46
|
+ var isSkipped = false;
|
|
|
47
|
+ var lastIndex = 0;
|
|
|
48
|
+ var self = this;
|
107
|
|
49
|
|
108
|
- if (parseFloat($currFee.html()) > 0) {
|
|
|
109
|
- $servePrice.show();
|
50
|
+ selection.forEach(function(sel) {
|
|
|
51
|
+ if ((sel.index + 1) - lastIndex > 1) {
|
|
|
52
|
+ isSkipped = true;
|
110
|
} else {
|
53
|
} else {
|
111
|
- $servePrice.hide();
|
|
|
112
|
- }
|
|
|
113
|
- }
|
|
|
114
|
-});
|
|
|
115
|
-
|
|
|
116
|
-$('.repayment-btn').on('click', function() {
|
|
|
117
|
- var path = location.pathname;
|
|
|
118
|
- var list = [];
|
|
|
119
|
-
|
|
|
120
|
- $('.repay-list li').each(function(key, item) {
|
|
|
121
|
- if ($(item).find('input').is(':checked')) {
|
|
|
122
|
- list.push({
|
|
|
123
|
- index: key, // 分期列表序号
|
|
|
124
|
- orderCode: $(item).attr('data-billno'), // 订单号
|
|
|
125
|
- termNo: $(item).attr('data-termNo') // 第几期还款
|
|
|
126
|
- });
|
54
|
+ lastIndex = sel.index + 1;
|
127
|
}
|
55
|
}
|
128
|
});
|
56
|
});
|
129
|
|
57
|
|
130
|
- $(this).attr('href',
|
|
|
131
|
- path + '?openby:yohobuy={"action":"go.instalmentRepayment","params":{"list":' +
|
|
|
132
|
- encodeURIComponent(JSON.stringify(list)) + ',"amount":' + (+$currAmt.html()) + '}}');
|
|
|
133
|
-});
|
|
|
134
|
-
|
|
|
135
|
-// const repayment = new Repayment({
|
|
|
136
|
-// onGetSelection: function() {
|
|
|
137
|
-// const ret = [];
|
|
|
138
|
-
|
|
|
139
|
-// $(`${CHECKBOX_SELECTOR}:checked`).each(function(key, item) {
|
|
|
140
|
-// const li = $(item).parents('li');
|
|
|
141
|
-
|
|
|
142
|
-// const data = {
|
|
|
143
|
-// index: key,
|
|
|
144
|
-// orderCode: li.attr('data-billno'),
|
|
|
145
|
-// termNo: li.attr('data-termNo'),
|
|
|
146
|
-// amount: parseFloat(li.attr('data-currNoFeeAmt')),
|
|
|
147
|
-// fee: parseFloat(li.attr('data-currfee')) + 0
|
|
|
148
|
-// };
|
|
|
149
|
-
|
|
|
150
|
-// ret.push(data);
|
|
|
151
|
-// });
|
58
|
+ if (isSkipped) {
|
|
|
59
|
+ setTimeout(function() {
|
|
|
60
|
+ tip.show($(self).is(':checked') ? '请按时间顺序取消选择,不可以跨期' : '请按时间顺序添加还款,不可以跨期');
|
|
|
61
|
+ }, 0);
|
|
|
62
|
+ return false;
|
|
|
63
|
+ }
|
152
|
|
64
|
|
153
|
-// return ret;
|
|
|
154
|
-// },
|
|
|
155
|
-// onDeselectAll: function() {
|
|
|
156
|
-// $(`${CHECKBOX_SELECTOR}:checked`).prop('checked', false);
|
|
|
157
|
-// return [];
|
|
|
158
|
-// },
|
|
|
159
|
-// onSelectAll: function() {
|
|
|
160
|
-// $(`${CHECKBOX_SELECTOR}:not(:checked)`).prop('checked', true);
|
|
|
161
|
-// return this.getSelection();
|
|
|
162
|
-// }
|
|
|
163
|
-// });
|
65
|
+ repayment.update();
|
|
|
66
|
+});
|
164
|
|
67
|
|
165
|
// 跳转到还款详情
|
68
|
// 跳转到还款详情
|
166
|
window.jumpDetail = function(id) {
|
69
|
window.jumpDetail = function(id) {
|