Authored by Aiden Xu

分期订单

... ... @@ -22,6 +22,9 @@ var repayment = new Repayment({
return ret;
},
onGetSelectableCount: function() {
return $(CHECKBOX_SELECTOR).length;
},
onDeselectAll: function() {
$(CHECKBOX_SELECTOR + ':checked').prop('checked', false);
return [];
... ... @@ -76,3 +79,7 @@ $(CHECKBOX_SELECTOR + ':checkbox').click(function() {
repayment.update();
});
// 默认选择第一个
$(CHECKBOX_SELECTOR + ':checkbox:first').click();
... ...
... ... @@ -8,6 +8,15 @@ var Repayment = function(options) {
onDeselectAll: $.noop,
/**
* 返回可选择数目
*
* @returns {number}
*/
onGetSelectableCount: function() {
return 0;
},
/**
* 获取选择
*
* @returns {Array}
... ... @@ -116,11 +125,17 @@ Repayment.prototype.getSelection = function() {
return this.settings.onGetSelection();
};
/**
* 更新组件并计算金额
*/
Repayment.prototype.update = function() {
var values = this.getSelection();
var $repaymentBottom = $('.repayment-bottom');
var self = this;
// 是否选择全部
var totalCheck = this.settings.onGetSelectableCount() === values.length;
this.total = 0;
this.fee = 0;
... ... @@ -138,6 +153,8 @@ Repayment.prototype.update = function() {
$repaymentBottom.slideDown();
}
$('#repayment-total').prop('checked', totalCheck).data('checked', totalCheck);
this.setTotal(this.total);
this.setFee(this.fee);
... ...