|
@@ -76,6 +76,7 @@ var shoppingConfirm = new Vue({
|
|
|
userBeans:0,
|
|
|
freightBeansMoney:0,
|
|
|
freightMoney:0,
|
|
|
+ deductionBeans:0,
|
|
|
hanldUserBeans:0,
|
|
|
submitLoading: false,
|
|
|
},
|
|
@@ -140,7 +141,7 @@ var shoppingConfirm = new Vue({
|
|
|
_self.payInfo.orderShouldPayFee = _self.totalPrice + _self.payInfo.freight;
|
|
|
switch (_self.payInfo.freePostFlag) {
|
|
|
case 1:
|
|
|
- if( _self.userBeans >= r.data.freight*100 ){
|
|
|
+ if( _self.userBeans > 0 ){
|
|
|
_self.freightBeansMoney = r.data.freight;
|
|
|
_self.freightMoney = r.data.freight;
|
|
|
_self.isBeansShow = true;
|
|
@@ -149,11 +150,16 @@ var shoppingConfirm = new Vue({
|
|
|
_self.balance.isFreight = false;
|
|
|
_self.isBeansShow = false;
|
|
|
}
|
|
|
+ if(r.data.userBeans >= _self.freightBeansMoney*100){
|
|
|
+ _self.deductionBeans = _self.freightBeansMoney*100
|
|
|
+ }else{
|
|
|
+ _self.deductionBeans = _self.userBeans
|
|
|
+ }
|
|
|
_self.changeDeductibleFreight();
|
|
|
break;
|
|
|
case -1:
|
|
|
- if( _self.userBeans >= 3000 ){
|
|
|
- _self.freightMoney = 30;
|
|
|
+ if( _self.userBeans > 0 ){
|
|
|
+ _self.freightMoney = '到付';
|
|
|
_self.freightBeansMoney = 30;
|
|
|
_self.isBeansShow = true;
|
|
|
}else{
|
|
@@ -161,6 +167,11 @@ var shoppingConfirm = new Vue({
|
|
|
_self.balance.isFreight = false;
|
|
|
_self.isBeansShow = false;
|
|
|
}
|
|
|
+ if(r.data.userBeans >= _self.freightBeansMoney*100){
|
|
|
+ _self.deductionBeans = _self.freightBeansMoney*100
|
|
|
+ }else{
|
|
|
+ _self.deductionBeans = _self.userBeans
|
|
|
+ }
|
|
|
_self.changeDeductibleFreight();
|
|
|
break;
|
|
|
}
|
|
@@ -393,7 +404,7 @@ var shoppingConfirm = new Vue({
|
|
|
$(el).parents('.priceTag').find('.tag').removeClass("on").siblings('.mFixed').hide();
|
|
|
if(!isPC){looseBody();}
|
|
|
},
|
|
|
- useUserMoney: function(){
|
|
|
+ useUserMoney: function(){//勾选余额抵扣
|
|
|
var _self = this;
|
|
|
if(this.balance.userMoney>0){
|
|
|
this.$nextTick(function() {
|
|
@@ -404,15 +415,25 @@ var shoppingConfirm = new Vue({
|
|
|
_self.payInfo.orderShouldPayFee = 0;
|
|
|
if(_self.balance.isFreight){// 勾选了采美豆丢运费
|
|
|
_self.balance.deductMoney = _self.totalPrice; // 抵扣使用金额 = 订单总金额
|
|
|
- _self.balance.surplusMoney = (_self.balance.userMoney*10 - _self.totalPrice*10)/10; // 抵扣后剩余余额 = 余额总额 - (订单总金额+邮费金额)
|
|
|
+ _self.balance.surplusMoney = _self.repiceNumSub(_self.balance.userMoney,_self.totalPrice); // 抵扣后剩余余额 = 余额总额 - (订单总金额+邮费金额)
|
|
|
+ console.log('余额全部抵扣勾选了采美豆运费',_self.balance.surplusMoney)
|
|
|
}else{
|
|
|
_self.balance.deductMoney = total; // 抵扣使用金额 = 订单总金额 + 邮费金额
|
|
|
- _self.balance.surplusMoney = (_self.balance.userMoney*10 - _self.balance.deductMoney*10)/10; // 抵扣后剩余余额 = 余额总额 - 抵扣使用金额
|
|
|
+ _self.balance.surplusMoney = _self.repiceNumSub(_self.balance.userMoney,_self.balance.deductMoney); // 抵扣后剩余余额 = 余额总额 - 抵扣使用金额
|
|
|
+ console.log('余额全部抵扣未勾选了采美豆运费',_self.balance.surplusMoney)
|
|
|
}
|
|
|
}else{ // 部分抵扣
|
|
|
- _self.payInfo.orderShouldPayFee = total - _self.balance.userMoney; // 最终订单总价 = 订单总金额 - 余额总额
|
|
|
- _self.balance.deductMoney = _self.balance.userMoney; // 抵扣使用金额 = 余额总额
|
|
|
- _self.balance.surplusMoney = 0; // 抵扣后剩余余额 = 0
|
|
|
+ if(_self.balance.isFreight){// 勾选了采美豆丢运费
|
|
|
+ _self.payInfo.orderShouldPayFee = _self.repiceNumSub(_self.totalPrice,_self.balance.userMoney); // 最终订单总价 = 订单总金额 - 余额总额
|
|
|
+ _self.balance.deductMoney = _self.balance.userMoney; // 抵扣使用金额 = 余额总额
|
|
|
+ _self.balance.surplusMoney = 0; // 抵扣后剩余余额 = 0
|
|
|
+ console.log('部分抵扣勾选了采美豆运费',_self.payInfo.orderShouldPayFee)
|
|
|
+ }else{
|
|
|
+ _self.payInfo.orderShouldPayFee = _self.repiceNumSub(total,_self.balance.userMoney); // 最终订单总价 = 订单总金额 - 余额总额
|
|
|
+ _self.balance.deductMoney = _self.balance.userMoney; // 抵扣使用金额 = 余额总额
|
|
|
+ _self.balance.surplusMoney = 0; // 抵扣后剩余余额 = 0
|
|
|
+ console.log('部分抵扣没有勾选了采美豆运费',_self.payInfo.orderShouldPayFee)
|
|
|
+ }
|
|
|
}
|
|
|
}else{// 取消抵扣
|
|
|
_self.payInfo.balancePayFlag = 0;
|
|
@@ -424,6 +445,7 @@ var shoppingConfirm = new Vue({
|
|
|
}else{
|
|
|
_self.payInfo.orderShouldPayFee = total; // 最终订单总价 = 订单总金额 + 邮费金额
|
|
|
}
|
|
|
+ console.log('取消余额抵扣',_self.payInfo.orderShouldPayFee)
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -431,41 +453,92 @@ var shoppingConfirm = new Vue({
|
|
|
changeDeductibleFreight: function(){//选择采美豆抵扣邮费
|
|
|
var _self = this;
|
|
|
var total = _self.totalPrice + _self.payInfo.freight;
|
|
|
- if(_self.balance.isFreight){
|
|
|
- _self.hanldUserBeans = _self.freightBeansMoney*100;
|
|
|
- if(_self.payInfo.freePostFlag == 1){
|
|
|
- if( _self.userBeans >= _self.payInfo.freight*100 ){
|
|
|
+ if(_self.balance.isFreight){//判断是否勾选运费
|
|
|
+ if(_self.payInfo.freePostFlag == 1){//有邮费
|
|
|
+ _self.hanldUserBeans = _self.freightBeansMoney*100;
|
|
|
+ if( _self.userBeans > 0 ){// 判断采美豆大于0
|
|
|
if(_self.balance.flag) {// 勾选了余额抵扣
|
|
|
+ console.log('订单总额11111',total)
|
|
|
if(_self.balance.userMoney>=total){ // 全部抵扣
|
|
|
_self.payInfo.orderShouldPayFee = 0;
|
|
|
_self.balance.deductMoney = _self.totalPrice; // 抵扣使用金额 = 订单总金额
|
|
|
- _self.balance.surplusMoney = (_self.balance.userMoney*10 - _self.balance.deductMoney*10)/10; // 抵扣后剩余余额 = 余额总额 - 抵扣使用金额
|
|
|
+ _self.balance.surplusMoney = _self.repiceNumSub(_self.balance.userMoney,_self.balance.deductMoney); // 抵扣后剩余余额 = 余额总额 - 抵扣使用金额
|
|
|
+ console.log('有勾选余额抵扣全抵',_self.payInfo.orderShouldPayFee)
|
|
|
}else{ // 部分抵扣
|
|
|
- _self.payInfo.orderShouldPayFee = total - _self.balance.userMoney;
|
|
|
+ _self.payInfo.orderShouldPayFee = _self.repiceNumSub(_self.totalPrice,_self.balance.userMoney);
|
|
|
_self.balance.deductMoney = _self.balance.userMoney; // 抵扣使用金额 = 余额总额
|
|
|
- _self.balance.surplusMoney = (_self.balance.userMoney*10 - _self.balance.deductMoney*10)/10; // 抵扣后剩余余额 = 余额总额 - 抵扣使用金额
|
|
|
+ _self.balance.surplusMoney = _self.repiceNumSub(_self.balance.userMoney,_self.balance.deductMoney); // 抵扣后剩余余额 = 余额总额 - 抵扣使用金额
|
|
|
+ console.log('有勾选余额抵扣部分抵',_self.payInfo.orderShouldPayFee)
|
|
|
}
|
|
|
}else{
|
|
|
+ console.log('订单总额2222222',total)
|
|
|
_self.payInfo.orderShouldPayFee = (_self.totalPrice*100 + _self.payInfo.freight*100 - _self.freightBeansMoney*100)/100;
|
|
|
+ console.log('无余额抵扣',_self.payInfo.orderShouldPayFee)
|
|
|
}
|
|
|
}
|
|
|
+ }else if(_self.payInfo.freePostFlag == -1){// 到付
|
|
|
+ _self.hanldUserBeans = _self.freightBeansMoney*100;
|
|
|
+ if(_self.balance.flag) {// 勾选了余额抵扣
|
|
|
+ if(_self.balance.userMoney>=total){ // 全部抵扣
|
|
|
+ _self.payInfo.orderShouldPayFee = 0;
|
|
|
+ _self.balance.deductMoney = _self.totalPrice; // 抵扣使用金额 = 订单总金额
|
|
|
+ _self.balance.surplusMoney = _self.repiceNumSub(_self.balance.userMoney,_self.balance.deductMoney); // 抵扣后剩余余额 = 余额总额 - 抵扣使用金额
|
|
|
+ console.log('到付有勾选余额抵扣全抵',_self.payInfo.orderShouldPayFee)
|
|
|
+ }else{ // 部分抵扣
|
|
|
+ _self.payInfo.orderShouldPayFee = _self.repiceNumSub(_self.totalPrice,_self.balance.userMoney);
|
|
|
+ _self.balance.deductMoney = _self.balance.userMoney; // 抵扣使用金额 = 余额总额
|
|
|
+ _self.balance.surplusMoney = _self.repiceNumSub(_self.balance.userMoney,_self.balance.deductMoney); // 抵扣后剩余余额 = 余额总额 - 抵扣使用金额
|
|
|
+ console.log('到付有勾选余额抵扣部分抵',_self.payInfo.orderShouldPayFee)
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ _self.payInfo.orderShouldPayFee = _self.totalPrice ;
|
|
|
+ console.log('到付未勾选余额抵扣',_self.payInfo.orderShouldPayFee)
|
|
|
+ }
|
|
|
}else{
|
|
|
_self.hanldUserBeans = 0;
|
|
|
_self.payInfo.orderShouldPayFee = _self.totalPrice ;
|
|
|
+ console.log('其他',_self.payInfo.orderShouldPayFee)
|
|
|
}
|
|
|
}else{
|
|
|
+ console.log('未勾选采美豆抵扣')
|
|
|
_self.hanldUserBeans = 0;
|
|
|
- if(_self.balance.flag) {//
|
|
|
+ if(_self.balance.flag) {//如果勾选了余额抵扣
|
|
|
if(_self.balance.userMoney>=total) { // 全部抵扣
|
|
|
+ console.log('勾选采美豆抵扣=========》',total)
|
|
|
_self.payInfo.orderShouldPayFee = 0 ;
|
|
|
_self.balance.deductMoney = total; // 抵扣使用金额 = (订单总金额+邮费金额)
|
|
|
- _self.balance.surplusMoney = (_self.balance.userMoney*10 - _self.balance.deductMoney*10)/10; // 抵扣后剩余余额 = 余额总额 - 抵扣使用金额
|
|
|
+ _self.balance.surplusMoney = _self.repiceNumSub(_self.balance.userMoney,_self.balance.deductMoney); // 抵扣后剩余余额 = 余额总额 - 抵扣使用金额
|
|
|
+ console.log('余额全抵抵未勾选采美豆抵扣',_self.payInfo.orderShouldPayFee)
|
|
|
+ }else{
|
|
|
+ console.log('未勾选采美豆抵扣=========》',total)
|
|
|
+ _self.payInfo.orderShouldPayFee = _self.repiceNumSub(total,_self.balance.userMoney) ;
|
|
|
+ _self.balance.deductMoney = _self.balance.userMoney; // 抵扣使用金额 = (订单总金额+邮费金额)
|
|
|
+ _self.balance.surplusMoney = _self.repiceNumSub(_self.balance.userMoney,_self.balance.deductMoney); // 抵扣后剩余余额 = 余额总额 - 抵扣使用金额
|
|
|
+ console.log('余额部分抵未勾选采美豆抵扣',_self.payInfo.orderShouldPayFee)
|
|
|
}
|
|
|
}else{
|
|
|
_self.payInfo.orderShouldPayFee = _self.totalPrice + _self.payInfo.freight;
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+ repiceNumSub: function(arg1, arg2) {//减法精确,arg2:被减数,arg1:减数
|
|
|
+ var r1,r2,m,n;
|
|
|
+ try{
|
|
|
+ r1=arg1.toString().split(".")[1].length
|
|
|
+ }catch(e){
|
|
|
+ r1=0
|
|
|
+ }
|
|
|
+ try{
|
|
|
+ r2=arg2.toString().split(".")[1].length
|
|
|
+ }catch(e){
|
|
|
+ r2=0
|
|
|
+ }
|
|
|
+ m=Math.pow(10,Math.max(r1,r2));
|
|
|
+ // last modify by deeka
|
|
|
+ // 动态控制精度长度
|
|
|
+ n=(r1>=r2)?r1:r2;
|
|
|
+ return ((arg1*m-arg2*m)/m).toFixed(n);
|
|
|
+ },
|
|
|
submitOrder: function(){
|
|
|
var _self = this;
|
|
|
if(this.submitLoading){return false;}
|
|
@@ -550,6 +623,7 @@ var shoppingConfirm = new Vue({
|
|
|
OrderApi.ConfirmOrder({'params':JSON.stringify(params)},function (r) {
|
|
|
if(r.code === 0){
|
|
|
var _data = r.data;
|
|
|
+ debugger
|
|
|
if(Number(_data.code) === 1){//余额抵扣全部订单金额
|
|
|
var data = { payableAmount: _self.deductMoney };
|
|
|
CAIMEI.Storage.removeItem('confirmOrderInfo');
|