repayment-list.page.js
1.73 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
/**
* 分期还款
* @author: wsl<shuiling.wang@yoho.cn>
* @date: 2016/08/04
*/
var $ = require('yoho-jquery');
var $currAmt = $('.repayment-bottom').find('.curr-amt'),
$currFee = $('.repayment-bottom').find('.curr-fee');
require('./overdue-notice');
$('.repay-list .cont').on('click', function() {
var $input = $(this).parent().prev(),
currAmt = +$currAmt.html(),
currFee = +$currFee.html(),
amt = +$(this).parents('li').attr('data-curramt'),
fee = +$(this).parents('li').attr('data-currfee'),
count = 0;
if ($input.is(':checked')) {
$currAmt.html(currAmt - amt);
$currFee.html(currFee - fee);
} else {
$currAmt.html(amt + currAmt);
$currFee.html(fee + currFee);
}
setTimeout(function() {
count = $('.repay-list input:checked').length;
$('#repayment-total').prop('checked', count === $('.repay-list li').length);
}, 0);
});
// 全选||全不选
$('.repayment-bottom label').on('click', function() {
var totalAmt = 0;
var totalFee = 0;
if ($(this).prev().is(':checked')) {
$('.repay-list input').prop('checked', false);
$currAmt.html('0');
$currFee.html('0');
} else {
$('.repay-list input').prop('checked', true);
$('.repay-list li').each(function() {
totalAmt += (+$(this).attr('data-curramt'));
totalFee += (+$(this).attr('data-currfee'));
});
$currAmt.html(totalAmt);
$currFee.html(totalFee);
}
});
$('.repayment-btn').on('click', function() {
var path = location.pathname;
$(this).attr('href',
path + '?openby:yohobuy={"action":"go.instalmentRepayment","params":{"amount":' + (+$currAmt.html()) + '}}');
});