|
@@ -47,6 +47,7 @@ var shoppingConfirm = new Vue({
|
|
|
mobile: '^\\d{6,12}$'
|
|
|
},
|
|
|
balance: {
|
|
|
+ isFreight:false, //使用采美豆抵扣运费
|
|
|
flag: false, //使用余额抵扣
|
|
|
originUserMoney: 0, //初始化后不能改变,用于还原余额抵扣
|
|
|
userMoney: 0, //显示可使用余额
|
|
@@ -69,8 +70,13 @@ var shoppingConfirm = new Vue({
|
|
|
registeredAddress: '',//单位地址
|
|
|
registeredPhone:'', //注册电话
|
|
|
openBank:'', //开户银行
|
|
|
- bankAccountNo: '' //银行账号
|
|
|
+ bankAccountNo: '', //银行账号
|
|
|
},
|
|
|
+ isBeansShow:false,
|
|
|
+ userBeans:0,
|
|
|
+ freightBeansMoney:0,
|
|
|
+ freightMoney:0,
|
|
|
+ hanldUserBeans:0,
|
|
|
submitLoading: false,
|
|
|
},
|
|
|
computed: {
|
|
@@ -129,8 +135,36 @@ var shoppingConfirm = new Vue({
|
|
|
},function (r) {
|
|
|
if(r.code === 0 && r.data){
|
|
|
_self.payInfo.freePostFlag = r.data.freePostFlag;
|
|
|
+ _self.userBeans = r.data.userBeans;
|
|
|
_self.payInfo.freight = (r.data.freePostFlag===1 ? r.data.freight : 0);
|
|
|
_self.payInfo.orderShouldPayFee = _self.totalPrice + _self.payInfo.freight;
|
|
|
+ switch (_self.payInfo.freePostFlag) {
|
|
|
+ case 1:
|
|
|
+ if( _self.userBeans >= r.data.freight*100 ){
|
|
|
+ _self.freightBeansMoney = r.data.freight;
|
|
|
+ _self.freightMoney = r.data.freight;
|
|
|
+ _self.isBeansShow = true;
|
|
|
+ }else{
|
|
|
+ _self.freightBeansMoney = 0;
|
|
|
+ _self.balance.isFreight = false;
|
|
|
+ _self.isBeansShow = false;
|
|
|
+ }
|
|
|
+ _self.changeDeductibleFreight();
|
|
|
+ break;
|
|
|
+ case -1:
|
|
|
+ if( _self.userBeans >= 3000 ){
|
|
|
+ _self.freightMoney = 30;
|
|
|
+ _self.freightBeansMoney = 30;
|
|
|
+ _self.isBeansShow = true;
|
|
|
+ }else{
|
|
|
+ _self.freightBeansMoney = 0;
|
|
|
+ _self.balance.isFreight = false;
|
|
|
+ _self.isBeansShow = false;
|
|
|
+ }
|
|
|
+ _self.changeDeductibleFreight();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
}else{
|
|
|
CAIMEI.Alert(r.msg, '确定', false);
|
|
|
}
|
|
@@ -363,31 +397,75 @@ var shoppingConfirm = new Vue({
|
|
|
var _self = this;
|
|
|
if(this.balance.userMoney>0){
|
|
|
this.$nextTick(function() {
|
|
|
- var total = _self.totalPrice + _self.payInfo.freight;
|
|
|
+ var total = _self.totalPrice + _self.payInfo.freight; // 订单总金额 + 邮费金额
|
|
|
if(_self.balance.flag){
|
|
|
_self.payInfo.balancePayFlag = 1;
|
|
|
- if(_self.balance.userMoney>=total){
|
|
|
- // 全部抵扣
|
|
|
+ if(_self.balance.userMoney>=total){ // 全部抵扣
|
|
|
_self.payInfo.orderShouldPayFee = 0;
|
|
|
- _self.balance.deductMoney = total;
|
|
|
- _self.balance.surplusMoney = _self.balance.userMoney-total;
|
|
|
- }else{
|
|
|
- // 部分抵扣
|
|
|
- _self.payInfo.orderShouldPayFee = total - _self.balance.userMoney;
|
|
|
- _self.balance.deductMoney = _self.balance.userMoney;
|
|
|
- _self.balance.surplusMoney = 0;
|
|
|
+ if(_self.balance.isFreight){// 勾选了采美豆丢运费
|
|
|
+ _self.balance.deductMoney = _self.totalPrice; // 抵扣使用金额 = 订单总金额
|
|
|
+ _self.balance.surplusMoney = (_self.balance.userMoney*10 - _self.totalPrice*10)/10; // 抵扣后剩余余额 = 余额总额 - (订单总金额+邮费金额)
|
|
|
+ }else{
|
|
|
+ _self.balance.deductMoney = total; // 抵扣使用金额 = 订单总金额 + 邮费金额
|
|
|
+ _self.balance.surplusMoney = (_self.balance.userMoney*10 - _self.balance.deductMoney*10)/10; // 抵扣后剩余余额 = 余额总额 - 抵扣使用金额
|
|
|
+ }
|
|
|
+ }else{ // 部分抵扣
|
|
|
+ _self.payInfo.orderShouldPayFee = total - _self.balance.userMoney; // 最终订单总价 = 订单总金额 - 余额总额
|
|
|
+ _self.balance.deductMoney = _self.balance.userMoney; // 抵扣使用金额 = 余额总额
|
|
|
+ _self.balance.surplusMoney = 0; // 抵扣后剩余余额 = 0
|
|
|
}
|
|
|
- }else{
|
|
|
- // 取消抵扣
|
|
|
+ }else{// 取消抵扣
|
|
|
_self.payInfo.balancePayFlag = 0;
|
|
|
- _self.payInfo.orderShouldPayFee = total;
|
|
|
_self.balance.userMoney = _self.balance.originUserMoney;
|
|
|
_self.balance.deductMoney = 0;
|
|
|
_self.balance.surplusMoney = _self.balance.originUserMoney;
|
|
|
+ if(_self.balance.isFreight){//判断是否有采美豆抵扣运费
|
|
|
+ _self.payInfo.orderShouldPayFee = _self.totalPrice; // 最终订单总价 = 订单总金额
|
|
|
+ }else{
|
|
|
+ _self.payInfo.orderShouldPayFee = total; // 最终订单总价 = 订单总金额 + 邮费金额
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
+ 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.flag) {// 勾选了余额抵扣
|
|
|
+ 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; // 抵扣后剩余余额 = 余额总额 - 抵扣使用金额
|
|
|
+ }else{ // 部分抵扣
|
|
|
+ _self.payInfo.orderShouldPayFee = total - _self.balance.userMoney;
|
|
|
+ _self.balance.deductMoney = _self.balance.userMoney; // 抵扣使用金额 = 余额总额
|
|
|
+ _self.balance.surplusMoney = (_self.balance.userMoney*10 - _self.balance.deductMoney*10)/10; // 抵扣后剩余余额 = 余额总额 - 抵扣使用金额
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ _self.payInfo.orderShouldPayFee = (_self.totalPrice*100 + _self.payInfo.freight*100 - _self.freightBeansMoney*100)/100;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ _self.hanldUserBeans = 0;
|
|
|
+ _self.payInfo.orderShouldPayFee = _self.totalPrice ;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ _self.hanldUserBeans = 0;
|
|
|
+ if(_self.balance.flag) {//
|
|
|
+ if(_self.balance.userMoney>=total) { // 全部抵扣
|
|
|
+ _self.payInfo.orderShouldPayFee = 0 ;
|
|
|
+ _self.balance.deductMoney = total; // 抵扣使用金额 = (订单总金额+邮费金额)
|
|
|
+ _self.balance.surplusMoney = (_self.balance.userMoney*10 - _self.balance.deductMoney*10)/10; // 抵扣后剩余余额 = 余额总额 - 抵扣使用金额
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ _self.payInfo.orderShouldPayFee = _self.totalPrice + _self.payInfo.freight;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
submitOrder: function(){
|
|
|
var _self = this;
|
|
|
if(this.submitLoading){return false;}
|
|
@@ -456,7 +534,8 @@ var shoppingConfirm = new Vue({
|
|
|
orderShouldPayFee: toFloat(this.payInfo.orderShouldPayFee),
|
|
|
balancePayFlag: this.payInfo.balancePayFlag,
|
|
|
freight: toFloat(this.payInfo.freight),
|
|
|
- freePostFlag: this.payInfo.freePostFlag
|
|
|
+ freePostFlag: this.payInfo.freePostFlag,
|
|
|
+ userBeans:this.hanldUserBeans
|
|
|
};
|
|
|
var params = {
|
|
|
cartType: this.type,
|