import Vue from 'vue' const conMixins = { data() { return { handleComType:0,//跳转类型 cartParam: { // 购物车立即结算确认订单参数 townId:'', //地址ID skuIds:'', serviceProviderId: 0, // 协销Id clubId: 0 // 机构Id }, productParam: { // 商品立即购买确认订单参数 townId:'', //地址ID productCount: 0, // 商品数量 productId: 0, // 商品Id serviceProviderId: 0, // 协销Id clubId: 0 // 机构Id }, totalCount: 1, // 订单提交总数量 reducedPrice: 0, // 满减金额 couponAmount: 0, // 优惠券金额 allPrice: 0.0, // 订单总金额 userMoney: 0.0, // 显示可使用余额 deductMoney: 0.0, // 显示已使用的余额 orderShouldPayFee:0 //显示最终订单金额 } }, computed: { // 计算订单最终支付金额 = 供应商下的合计金额之和 orderTotalPrice(){ let totalPrice = 0 this.goodsData.forEach(el =>{ totalPrice += el.totalPrice }) console.log('订单最终金额',totalPrice) return totalPrice - this.couponAmount }, // 显示勾选后的剩余抵扣 = 用户总余额-当前使用金额 surplusMoney(){ console.log('剩余抵扣', (this.userMoney - this.deductMoney)) return this.userMoney - this.deductMoney }, // 共减 = 减金额 + 优惠券金额 totalDiscountAmount(){ console.log('共减金额', (this.reducedPrice + this.couponAmount)) return this.reducedPrice + this.couponAmount } }, methods: { //勾选使用余额 checkedBalabce() { if (this.userMoney > 0) { this.ischecked = !this.ischecked if (this.ischecked) { this.confirmParam.payInfo.balancePayFlag = 1 this.attributePallPrice() } else { this.confirmParam.payInfo.balancePayFlag = 0 this.attributePallPrice() } console.log('勾选使用余额最终订单支付金额', this.orderShouldPayFee) } }, // 是否勾选冷链费计算 handleChangeChina(supplier){ this.attributePallPrice() }, // 修改供应商运费类型 handleChangePostage(supplier){ this.attributePallPrice() }, // 计算最终订单支付金额 attributePallPrice() { if (this.ischecked) {// 是否勾选余额抵扣 if (this.userMoney >= this.orderTotalPrice) { this.orderShouldPayFee =0.0 this.deductMoney = this.orderTotalPrice// 当前使用金额等于订单金额 } else { this.orderShouldPayFee = this.orderTotalPrice - this.userMoney // 订单最终支付金额等于订单金额-账户余额 this.deductMoney = this.userMoney // 当前使用金额等于总余额 } console.log('余额抵扣最终订单支付金额', this.orderShouldPayFee) } else { this.orderShouldPayFee = this.orderTotalPrice this.deductMoney = 0 // 当前使用 console.log('未余额抵扣最终订单支付金额', this.orderShouldPayFee) } } } } export default conMixins