repayment-list.page.js 1.21 KB
/**
 * 分期还款
 * @author: wsl<shuiling.wang@yoho.cn>
 * @date: 2016/08/04
 */

var $ = require('yoho-jquery');

var $notice = $('.installment-overdue-notice');

$('.repay-list .notice').on('click', function() {
    $notice.show();

    return false;
});

$('.think-ok, .mask-bg').on('click', function() {
    $notice.hide();
});

$('.repay-list .cont').on('click', function() {
    var $currAmt = $('.repayment-bottom').find('.curr-amt');
    var $currFee = $('.repayment-bottom').find('.curr-fee');
    var $input = $(this).parent().prev();
    var currAmt = +$currAmt.html();
    var currFee = +$currFee.html();
    var amt = +$(this).parents('li').attr('data-curramt');
    var fee = +$(this).parents('li').attr('data-currfee');
    var count = 1;

    if ($input.is(':checked')) {
        $currAmt.html(currAmt - amt);
        $currFee.html(currFee - fee);
    } else {
        $currAmt.html(amt + currAmt);
        $currFee.html(fee + currFee);
    }

    $('.repay-list input').each(function() {
        if ($(this).is(':checked')) {
            count++;
        }
    });

    if (count === $('.repay-list li').length) {
        $('#repayment-total').click();
    } else {
        $('#repayment-total').click();
    }
});