Authored by Aiden Xu

分期订单

... ... @@ -360,6 +360,14 @@ const agreement = (req, res) => {
});
};
// 计算金额
const totalAmount = (req, res, next) => {
installmentModel.totalAmount(req.query.prices).then((result) => {
res.json(result);
}).catch(next);
};
module.exports = {
index,
review,
... ... @@ -380,5 +388,6 @@ module.exports = {
repayDetail,
help,
serviceProvision,
agreement
agreement,
totalAmount
};
... ...
... ... @@ -406,6 +406,25 @@ const getInstallmentOrderDetail = (params) => {
});
};
/**
* 计算总金额
*
* @param params 金额
*
* @returns {*|Promise.<TResult>}
*/
const totalAmount = (params) => {
const method = 'app.order.calPrice';
return api.get('', {
method: method,
prices: params,
debug: 'XYZ'
}).then((result)=> {
return Promise.resolve(camelCase(result));
});
};
module.exports = {
getStauts,
getQueryCreditInfo,
... ... @@ -419,5 +438,6 @@ module.exports = {
getBankCards,
getBankInfo,
getInstallmentOrders,
getInstallmentOrderDetail
getInstallmentOrderDetail,
totalAmount
};
... ...
... ... @@ -31,6 +31,7 @@ router.post('/installment/activate-service', installment.activateService);
router.get('/installment/order', installment.orderIndex);
router.get('/installment/order.html', installment.orderList);
router.get('/installment/order/:id', installment.orderDetail);
router.get('/installment/total-amount.json', installment.totalAmount);
router.get('/installment/help', installment.help);// 帮助静态页面
router.get('/installment/service-provision', installment.serviceProvision);// 服务条款静态页面
... ...
... ... @@ -125,6 +125,17 @@ Repayment.prototype.getSelection = function() {
return this.settings.onGetSelection();
};
Repayment.prototype._updateUI = function() {
this.setTotal(this.total);
this.setFee(this.fee);
if (this.fee > 0) {
$('.serve-price').show();
} else {
$('.serve-price').hide();
}
};
/**
* 更新组件并计算金额
*/
... ... @@ -132,6 +143,7 @@ Repayment.prototype.update = function() {
var values = this.getSelection();
var $repaymentBottom = $('.repayment-bottom');
var self = this;
var total = [], fee = [];
// 是否选择全部
var totalCheck = this.settings.onGetSelectableCount() === values.length;
... ... @@ -140,10 +152,29 @@ Repayment.prototype.update = function() {
this.fee = 0;
if (values && values.length) {
values.forEach(function(value) {
// 计算还款总额和费用
self.total += value.amount + value.fee;
self.fee += value.fee;
// self.total += value.amount + value.fee;
// self.fee += value.fee;
total.push(value.amount);
total.push(value.fee);
fee.push(value.fee);
});
$.get('/home/installment/total-amount.json?prices=' + total.join(',')).then(function(result) {
if (result.code === 200) {
self.total = result.data;
self._updateUI();
}
});
$.get('/home/installment/total-amount.json?prices=' + fee.join(',')).then(function(result) {
if (result.code === 200) {
self.fee = result.data;
self._updateUI();
}
});
}
... ... @@ -155,14 +186,7 @@ Repayment.prototype.update = function() {
$('#repayment-total').prop('checked', totalCheck).data('checked', totalCheck);
this.setTotal(this.total);
this.setFee(this.fee);
if (this.fee > 0) {
$('.serve-price').show();
} else {
$('.serve-price').hide();
}
this._updateUI();
};
// 跳转到还款详情
... ...