75 lines
2.2 KiB
JavaScript
75 lines
2.2 KiB
JavaScript
|
import moneySubFn from './moneySubFn'
|
||
|
import rechargeDeductFn from './rechargeDeductFn'
|
||
|
import creditDeductFn from './creditDeductFn'
|
||
|
module.exports = {
|
||
|
changeEv: function(e, that) {
|
||
|
if(e>that.quota){
|
||
|
uni.showToast({
|
||
|
title:'最大支付金额为'+that.quota+'元!',
|
||
|
icon:'none'
|
||
|
})
|
||
|
}
|
||
|
if(e>999999){
|
||
|
return false;
|
||
|
}
|
||
|
if (typeof e === 'number' && !isNaN(e)) {
|
||
|
return
|
||
|
}
|
||
|
if (typeof(e) == 'undefined' || e == undefined || e == 'undefined' || e < 0) {
|
||
|
return
|
||
|
}
|
||
|
// 如果是收银台付款,金额不能修改
|
||
|
if (that.option.cashierid && that.option.total > 0) {
|
||
|
that.$set(that.list, 'realprice', that.option.total)
|
||
|
} else {
|
||
|
that.$set(that.list, 'realprice', e)
|
||
|
}
|
||
|
// 更改金额后,取消储值卡/金豆抵扣的勾选
|
||
|
that.use_deduct_recharge = false
|
||
|
that.use_deductprice = false
|
||
|
that.use_deductprice_hot = false
|
||
|
|
||
|
that.use_max_credit_money=parseFloat(e*that.merch.credit_pay_proportion).toFixed(2);
|
||
|
|
||
|
//计算
|
||
|
if (that.credit1 > 0) {
|
||
|
//计算客户金豆余额折算现金
|
||
|
let user_credit_to_money=getApp().globalData.util.numberFloor(that.credit1 * that.merch.credit_pay_rate);
|
||
|
//计算金豆最大支付金额比例
|
||
|
let max_credit_money=that.merch.credit_pay_proportion*e;
|
||
|
//客户金豆金额>最大抵扣金豆金额
|
||
|
if(user_credit_to_money>max_credit_money){
|
||
|
//金豆抵扣金额
|
||
|
that.use_max_credit_money=max_credit_money;
|
||
|
}
|
||
|
else{ //金豆不足最大金豆支付比例
|
||
|
that.use_max_credit_money=user_credit_to_money;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
// 送金豆的钱
|
||
|
let money4CreditAdd = that.list.realprice
|
||
|
if (that.deduct_recharge >= 0.01) {
|
||
|
money4CreditAdd = money4CreditAdd - that.deduct_recharge
|
||
|
}
|
||
|
// 赠送金豆个数
|
||
|
let creditaddNumber = money4CreditAdd * that.merch.credit_give / that.merch.credit_give_rate
|
||
|
if (creditaddNumber >= 0.01) {
|
||
|
that.$set(that.list, 'credit', getApp().globalData.util.numberFloor(creditaddNumber))
|
||
|
}
|
||
|
else{
|
||
|
that.$set(that.list, 'credit', 0.00)
|
||
|
}
|
||
|
that.hideCreditDeduct = false
|
||
|
that.hideRechargeDeduct = false
|
||
|
if (parseFloat(that.list.realprice) > 0 && e<that.quota) {
|
||
|
moneySubFn.modifyMoneySub(that)
|
||
|
creditDeductFn.modifyCreditDeduct(that)
|
||
|
rechargeDeductFn.modifyRechargeDeduct(that)
|
||
|
}
|
||
|
|
||
|
that.$forceUpdate()
|
||
|
},
|
||
|
}
|