const core = getApp().globalData.requirejs("core") module.exports = { /** * 处理金豆抵扣方法 * @param {*} e */ modifyCreditDeduct: function(that) { let use_huodong_money=0 //平台赠送活动金额 let list = that.list list.is_use_credit_deduct = this.use_deductprice ? 'yes' : 'no' // 剩余要付款金额 let allBa2Need = parseFloat(list.realprice - that.list.money_sub - list.deduct_recharge) allBa2Need = getApp().globalData.util.numberFloor(allBa2Need) // 储值和金豆抵扣满足一个即可 if (that.use_deductprice) { let credit1 = that.credit1 if (credit1 <= 0) { //金豆为0 list.deductprice = 0; list.needpay = list.realprice; } else { //计算客户金豆余额折算现金 let user_credit_to_money=getApp().globalData.util.numberFloor(credit1 * that.merch.credit_pay_rate); //计算金豆最大支付金额比例 let max_credit_money=that.merch.credit_pay_proportion*list.realprice; //客户金豆金额>最大抵扣金豆金额 if(user_credit_to_money>max_credit_money){ //金豆抵扣金额 list.deductprice=max_credit_money; //金豆抵扣个数=赠送金豆个数+个人抵扣 list.deductcredit=max_credit_money/that.merch.credit_pay_rate; //真实付款 list.needpay = list.realprice - list.deductprice; } else{ //金豆不足最大金豆支付比例 list.needpay = list.realprice - user_credit_to_money; list.deductprice=user_credit_to_money; } //更新金豆最大抵扣金额 that.use_max_credit_money=list.deductprice; } } else { that.hideRechargeDeduct = false list.deductcredit = 0 list.deductprice = 0 list.needpay = list.realprice } //赠送金豆活动 if(that.credit1_hot_set>0){ if(that.use_deductprice_hot){ //使用活动金额 use_huodong_money=that.credit1_hot_rang * that.merch.credit_pay_rate list.deductprice_zs = that.credit1_hot_rang* that.merch.credit_pay_rate list.deductcredit_zs = that.credit1_hot_rang } else{ //不使用活动金额 use_huodong_money=0 list.deductprice_zs = 0 list.deductcredit_zs = 0 } } //真实付款-随机立减-储值卡 list.needpay = parseFloat(list.needpay) - parseFloat(that.list.money_sub) - parseFloat(that.list .deduct_recharge)-use_huodong_money list.needpay = parseFloat(list.needpay).toFixed(2) list.needpay = list.needpay > 0 ? list.needpay : 0 that.list = list that.submit = false that.$forceUpdate() }, }