|
@@ -1,3 +1,37 @@
|
|
|
+const defaultProductParam = {
|
|
|
+ productCount:0, // 商品数量
|
|
|
+ productId:0, // 商品Id
|
|
|
+ source:1, // 来源:1WWW 2小程序
|
|
|
+ userId:0 // 用户Id
|
|
|
+};
|
|
|
+const defaultCartParam = {
|
|
|
+ productIds:0, // 商品Id(逗号隔开)
|
|
|
+ source:1, // 来源:1WWW 2小程序
|
|
|
+ userId:0 // 用户Id
|
|
|
+};
|
|
|
+const defaultPostageParam = {
|
|
|
+ productIds:0, // 商品Id(逗号隔开)
|
|
|
+ userId:0, // 用户Id
|
|
|
+ townId:0 // 地区Id
|
|
|
+};
|
|
|
+const defaultConfirmParam = {
|
|
|
+ cartType:1, // 购买类型:(1自主下单, 3协销下单)
|
|
|
+ orderSource:1, // 订单来源 1WWW 6小程序[采美,星范]
|
|
|
+ addressId:0, // 收货地址Id
|
|
|
+ clubCouponId:0, // 关联优惠券Id
|
|
|
+ clubId:0, // 机构Id
|
|
|
+ orderInfo:[], // 订单商品数据 // 订单发票信息
|
|
|
+ orderInvoice:{ type: 0 }, // 订单发票信息
|
|
|
+ payInfo:{ // 订单金额数据
|
|
|
+ orderShouldPayFee: 0, // 订单最终支付金额
|
|
|
+ balancePayFlag: 0, // 勾选余额的状态(1使用,0不使用)
|
|
|
+ clauseId:0, // 条款Id
|
|
|
+ postage: 0, // 运费金额
|
|
|
+ postageFlag: 0, // 运费类型
|
|
|
+ userBeans: 0, // 抵扣采美豆数量
|
|
|
+ rebateFlag:0 // 是否返佣订单
|
|
|
+ }
|
|
|
+};
|
|
|
var shoppingConfirm = new Vue({
|
|
|
el: "#shoppingConfirm",
|
|
|
data: {
|
|
@@ -13,6 +47,10 @@ var shoppingConfirm = new Vue({
|
|
|
reducedPrice: 0, // 满减金额
|
|
|
couponAmount:0, // 优惠券金额
|
|
|
totalDiscountAmount:0, // 共减金额
|
|
|
+ cartParam: Object.assign({}, defaultCartParam), // 购物车立即结算确认订单参数
|
|
|
+ productParam: Object.assign({}, defaultProductParam), // 商品立即购买确认订单参数
|
|
|
+ postageParam: Object.assign({}, defaultPostageParam), // 邮费计算参数
|
|
|
+ confirmParam: Object.assign({}, defaultConfirmParam), // 提交订单参数
|
|
|
address: {
|
|
|
id: '',
|
|
|
townId: '',
|
|
@@ -27,6 +65,17 @@ var shoppingConfirm = new Vue({
|
|
|
default: '',
|
|
|
selectedId: ''
|
|
|
},
|
|
|
+ orderInvoice:{ // 订单发票信息
|
|
|
+ id:0,
|
|
|
+ type: 0,
|
|
|
+ invoiceTitleType: 0, // 发票抬头类型 1企业 0个人
|
|
|
+ invoiceTitle: '', // 单位名称
|
|
|
+ corporationTaxNum:'', // 纳税人识别号
|
|
|
+ registeredAddress: '',// 单位地址
|
|
|
+ registeredPhone:'', // 注册电话
|
|
|
+ openBank:'', // 开户银行
|
|
|
+ bankAccountNo: '', // 银行账号
|
|
|
+ },
|
|
|
addressList: [],
|
|
|
isShowAddressList: false,
|
|
|
isShowAddressForm: false,
|
|
@@ -56,31 +105,14 @@ var shoppingConfirm = new Vue({
|
|
|
deductMoney: 0, //显示已使用的余额
|
|
|
surplusMoney: 0 //显示勾选后的剩余抵扣
|
|
|
},
|
|
|
- payInfo: {
|
|
|
- clauseId: 0, //条款(暂时保留)
|
|
|
- orderShouldPayFee: 0.00,//提交的总价
|
|
|
- balancePayFlag: 0, //余额抵扣的状态 0不使用,1使用
|
|
|
- freight: 0.00, //邮费
|
|
|
- freePostFlag:-1 // 0包邮 -1到付 1 有运费
|
|
|
- },
|
|
|
- clubCouponId:0, // 用户关联优惠Id
|
|
|
- invoice: {
|
|
|
- id:'',
|
|
|
- type: 0,
|
|
|
- invoiceTitleType: 0, //发票抬头类型 1企业 0个人
|
|
|
- invoiceTitle: '', //单位名称
|
|
|
- corporationTaxNum:'',//纳税人识别号
|
|
|
- registeredAddress: '',//单位地址
|
|
|
- registeredPhone:'', //注册电话
|
|
|
- openBank:'', //开户银行
|
|
|
- bankAccountNo: '', //银行账号
|
|
|
- },
|
|
|
isBeansShow:false,
|
|
|
userBeans:0,
|
|
|
+ hanldPostage:0,
|
|
|
+ hanldPostageFlag:0,
|
|
|
+ hanldShouldPayFee:0,
|
|
|
freightBeansMoney:0,
|
|
|
freightMoney:0,
|
|
|
deductionBeans:0,
|
|
|
- hanldUserBeans:0,
|
|
|
submitLoading: false,
|
|
|
checkedIndex:null,
|
|
|
couponList:[], // 可用优惠券列表
|
|
@@ -123,14 +155,45 @@ var shoppingConfirm = new Vue({
|
|
|
var el = event.currentTarget;
|
|
|
verifyHandle(el);
|
|
|
},
|
|
|
- getConfirmList: function (productCount) {// 初始化确认订单信息
|
|
|
+ getProductCreateOrderInfo:function(){// 商品立即购买确认订单初始化
|
|
|
+ var _self = this;
|
|
|
+ if(_self.userId ===0){return;}
|
|
|
+ OrderApi.ProductCreateOrderInfo(_self.productParam,function(response){
|
|
|
+ if (response.code === 0 ) {
|
|
|
+ var data = response.data;
|
|
|
+ _self.listData = data.list;
|
|
|
+ _self.totalPrice = data.totalPrice;
|
|
|
+ _self.reducedPrice = data.reducedPrice;
|
|
|
+ _self.totalCount = data.totalCount;
|
|
|
+ _self.kindCount = data.kindCount;
|
|
|
+ _self.balance.userMoney = data.userMoney;
|
|
|
+ _self.balance.originUserMoney = data.userMoney;
|
|
|
+ _self.hanldShouldPayFee = data.totalPrice;
|
|
|
+ _self.getAddressList(_self.userId,20);
|
|
|
+ if( data.couponList && data.couponList.length>0){
|
|
|
+ _self.isCouponShow = true;
|
|
|
+ _self.couponAmount = data.couponList[0].couponAmount;
|
|
|
+ _self.confirmParam.clubCouponId = data.couponList[0].clubCouponId;
|
|
|
+ data.couponList.forEach((el) => {
|
|
|
+ _self.couponList.push(Object.assign(el,{ischecked:false}))
|
|
|
+ })
|
|
|
+ _self.couponList[0].ischecked = true;
|
|
|
+ _self.hanldShouldPayFee = data.totalPrice - _self.couponAmount;
|
|
|
+ }
|
|
|
+ _self.totalDiscountAmount = _self.reducedPrice + _self.couponAmount;
|
|
|
+ if(data.invoice){
|
|
|
+ data.invoice.type = 0;
|
|
|
+ _self.orderInvoice = data.invoice;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ CAIMEI.Alert(r.msg, '确定', false);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getCartCreateOrderInfo: function () {// 购物车去结算确认订单初始化
|
|
|
var _self = this;
|
|
|
- if(this.userId ===0){return;}
|
|
|
- OrderApi.GetOrderConfirmInfo({
|
|
|
- userId: _self.userId,
|
|
|
- count: productCount,
|
|
|
- productIds: this.productIds
|
|
|
- },function(response){
|
|
|
+ if(_self.userId ===0){return;}
|
|
|
+ OrderApi.GetOrderConfirmInfo(_self.cartParam,function(response){
|
|
|
if (response.code === 0 ) {
|
|
|
var data = response.data;
|
|
|
_self.listData = data.list;
|
|
@@ -140,46 +203,41 @@ var shoppingConfirm = new Vue({
|
|
|
_self.kindCount = data.kindCount;
|
|
|
_self.balance.userMoney = data.userMoney;
|
|
|
_self.balance.originUserMoney = data.userMoney;
|
|
|
- _self.payInfo.orderShouldPayFee = data.totalPrice;
|
|
|
+ _self.hanldShouldPayFee = data.totalPrice;
|
|
|
_self.getAddressList(_self.userId,20);
|
|
|
if( data.couponList && data.couponList.length>0){
|
|
|
_self.isCouponShow = true;
|
|
|
_self.couponAmount = data.couponList[0].couponAmount;
|
|
|
- _self.clubCouponId = data.couponList[0].clubCouponId;
|
|
|
+ _self.confirmParam.clubCouponId = data.couponList[0].clubCouponId;
|
|
|
data.couponList.forEach((el) => {
|
|
|
_self.couponList.push(Object.assign(el,{ischecked:false}))
|
|
|
})
|
|
|
_self.couponList[0].ischecked = true;
|
|
|
- _self.payInfo.orderShouldPayFee = data.totalPrice - _self.couponAmount;
|
|
|
+ _self.hanldShouldPayFee = data.totalPrice - _self.couponAmount;
|
|
|
}
|
|
|
_self.totalDiscountAmount = _self.reducedPrice + _self.couponAmount;
|
|
|
if(data.invoice){
|
|
|
data.invoice.type = 0;
|
|
|
- _self.invoice = data.invoice;
|
|
|
+ _self.orderInvoice = data.invoice;
|
|
|
}
|
|
|
}else{
|
|
|
CAIMEI.Alert(r.msg, '确定', false);
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- getFreight: function(townId){// 获取邮费
|
|
|
+ getFreight: function(){// 获取邮费
|
|
|
var _self = this;
|
|
|
- OrderApi.GetOrderPostage({
|
|
|
- userId: this.userId,
|
|
|
- productIds: this.productIds,
|
|
|
- totalPrice: this.totalPrice,
|
|
|
- townId: townId
|
|
|
- },function (r) {
|
|
|
+ OrderApi.GetOrderPostage(_self.postageParam,function (r) {
|
|
|
if(r.code === 0 && r.data){
|
|
|
- _self.payInfo.freePostFlag = r.data.freePostFlag;
|
|
|
+ _self.confirmParam.payInfo.postageFlag = _self.hanldPostageFlag = r.data.postageFlag;
|
|
|
_self.userBeans = r.data.userBeans;
|
|
|
- _self.payInfo.freight = (r.data.freePostFlag===1 ? r.data.freight : 0);
|
|
|
- _self.payInfo.orderShouldPayFee = _self.totalPrice + _self.payInfo.freight - _self.couponAmount;
|
|
|
- switch (_self.payInfo.freePostFlag) {
|
|
|
+ _self.confirmParam.payInfo.postage = _self.hanldPostage = (r.data.postageFlag=== 1 ? r.data.postage : 0);
|
|
|
+ _self.hanldShouldPayFee = _self.totalPrice + _self.confirmParam.payInfo.postage - _self.couponAmount;
|
|
|
+ switch ( _self.confirmParam.payInfo.postageFlag) {
|
|
|
case 1:
|
|
|
if( _self.userBeans > 0 ){
|
|
|
- _self.freightBeansMoney = r.data.freight;
|
|
|
- _self.freightMoney = r.data.freight;
|
|
|
+ _self.freightBeansMoney = r.data.postage;
|
|
|
+ _self.freightMoney = r.data.postage;
|
|
|
_self.isBeansShow = true;
|
|
|
}else{
|
|
|
_self.freightBeansMoney = 0;
|
|
@@ -220,74 +278,76 @@ var shoppingConfirm = new Vue({
|
|
|
getAddressList: function(userId,pageSize){ // 获取收货地址
|
|
|
var _self = this;
|
|
|
OrderApi.GetAddressList({
|
|
|
- userID:userId,
|
|
|
+ userId:userId,
|
|
|
pageNum:1,
|
|
|
pageSize:pageSize
|
|
|
- },function (r) {
|
|
|
- if(r.code === 0 && r.data){
|
|
|
- if(r.data.results){
|
|
|
- _self.addressList = r.data.results;
|
|
|
- _self.address.id = r.data.results[0].addressID;
|
|
|
- _self.address.townId = r.data.results[0].townID;
|
|
|
- _self.address.cityId = r.data.results[0].cityID;
|
|
|
- _self.address.provinceId = r.data.results[0].provinceID;
|
|
|
- _self.address.name = r.data.results[0].shouHuoRen;
|
|
|
- _self.address.mobile = r.data.results[0].mobile;
|
|
|
- _self.address.desc = r.data.results[0].address;
|
|
|
- _self.address.town = r.data.results[0].town;
|
|
|
- _self.address.city = r.data.results[0].city;
|
|
|
- _self.address.province = r.data.results[0].province;
|
|
|
+ },function (res) {
|
|
|
+ if(res.code === 0 && res.data){
|
|
|
+ if(res.data.list){
|
|
|
+ _self.addressList = res.data.list;
|
|
|
+ _self.address.id = res.data.list[0].addressId;
|
|
|
+ _self.confirmParam.addressId = res.data.list[0].addressId;
|
|
|
+ _self.address.townId = res.data.list[0].townId;
|
|
|
+ _self.postageParam.townId = res.data.list[0].townId;
|
|
|
+ _self.address.cityId = res.data.list[0].cityId;
|
|
|
+ _self.address.provinceId = res.data.list[0].provinceId;
|
|
|
+ _self.address.name = res.data.list[0].receiver;
|
|
|
+ _self.address.mobile = res.data.list[0].mobile;
|
|
|
+ _self.address.desc = res.data.list[0].address;
|
|
|
+ _self.address.town = res.data.list[0].town;
|
|
|
+ _self.address.city = res.data.list[0].city;
|
|
|
+ _self.address.province = res.data.list[0].province;
|
|
|
_self.address.default = true;
|
|
|
- _self.address.selectedId = r.data.results[0].addressID;
|
|
|
+ _self.address.selectedId = res.data.list[0].addressId;
|
|
|
_self.getFreight(_self.address.townId);
|
|
|
}else{
|
|
|
_self.createAddress();
|
|
|
}
|
|
|
_self.getProvinceOptions();
|
|
|
}else {
|
|
|
- CAIMEI.Alert(r.msg, '确定', false);
|
|
|
+ CAIMEI.Alert(res.msg, '确定', false);
|
|
|
_self.createAddress();
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
getProvinceOptions: function(){ // 获取全部省份
|
|
|
var _self = this;
|
|
|
- PublicApi.GetProvince({},function(r){
|
|
|
- if(r.code === 0 && r.data){
|
|
|
- _self.provinceOptions =r.data;
|
|
|
+ OrderApi.GetAddressSelect({},function(res){
|
|
|
+ if(res.code === 0 && res.data){
|
|
|
+ _self.provinceOptions =res.data;
|
|
|
}else{
|
|
|
- CAIMEI.Alert(r.msg,'确定',false);
|
|
|
+ CAIMEI.Alert(res.msg,'确定',false);
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- getCityOptions: function(provinceId,callback){// 获取地区
|
|
|
+ getCityOptions: function(parentId,callback){// 获取地区
|
|
|
var _self = this;
|
|
|
- if(provinceId && provinceId>0){
|
|
|
+ if(parentId && parentId>0){
|
|
|
_self.cityOptions = [];
|
|
|
_self.townOptions = [];
|
|
|
_self.addressForm.cityId = '';
|
|
|
_self.addressForm.townId = '';
|
|
|
- PublicApi.GetCity({ provinceId: provinceId },function(r){
|
|
|
- if(r.code === 0 && r.data){
|
|
|
- _self.cityOptions = r.data;
|
|
|
+ OrderApi.GetAddressSelect({ parentId: parentId,type:1 },function(res){
|
|
|
+ if(res.code === 0 && res.data){
|
|
|
+ _self.cityOptions = res.data;
|
|
|
if(callback){callback();}
|
|
|
}else{
|
|
|
- CAIMEI.Alert(r.msg,'确定',false);
|
|
|
+ CAIMEI.Alert(res.msg,'确定',false);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
- getTownOptions: function(cityId, callback){
|
|
|
+ getTownOptions: function(parentId, callback){
|
|
|
var _self = this;
|
|
|
- if(cityId && cityId>0){
|
|
|
+ if(parentId && parentId>0){
|
|
|
_self.townOptions = [];
|
|
|
_self.addressForm.townId = '';
|
|
|
- PublicApi.GetTown({cityId: cityId},function(r){
|
|
|
- if(r.code === 0 && r.data){
|
|
|
- _self.townOptions = r.data;
|
|
|
+ OrderApi.GetAddressSelect({parentId: parentId,type:2},function(res){
|
|
|
+ if(res.code === 0 && res.data){
|
|
|
+ _self.townOptions = res.data;
|
|
|
if(callback){callback();}
|
|
|
}else{
|
|
|
- CAIMEI.Alert(r.msg,'确定',false);
|
|
|
+ CAIMEI.Alert(res.msg,'确定',false);
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -317,15 +377,15 @@ var shoppingConfirm = new Vue({
|
|
|
if(!isPC){fixedBody();}
|
|
|
},
|
|
|
updateAddress: function(){// 更新选择地址
|
|
|
- this.isShowAddressForm = true;
|
|
|
- this.addressForm.id = this.address.id;
|
|
|
- this.addressForm.name = this.address.name;
|
|
|
- this.addressForm.mobile = this.address.mobile;
|
|
|
- this.addressForm.default = this.address.default;
|
|
|
- this.addressForm.desc = this.address.desc;
|
|
|
- this.addressForm.provinceId = this.address.provinceId;
|
|
|
var _self = this;
|
|
|
- this.getCityOptions(this.address.provinceId, function(){
|
|
|
+ _self.isShowAddressForm = true;
|
|
|
+ _self.addressForm.id = _self.address.id;
|
|
|
+ _self.addressForm.name = _self.address.name;
|
|
|
+ _self.addressForm.mobile = _self.address.mobile;
|
|
|
+ _self.addressForm.default = _self.address.default;
|
|
|
+ _self.addressForm.desc = _self.address.desc;
|
|
|
+ _self.addressForm.provinceId = _self.address.provinceId;
|
|
|
+ _self.getCityOptions(_self.address.provinceId, function(){
|
|
|
_self.addressForm.cityId = _self.address.cityId;
|
|
|
_self.getTownOptions(_self.address.cityId,function(){
|
|
|
_self.addressForm.townId = _self.address.townId;
|
|
@@ -345,16 +405,15 @@ var shoppingConfirm = new Vue({
|
|
|
};
|
|
|
_self.saveLoading = true;
|
|
|
var params = {
|
|
|
- userID:_self.userId, //用户id ,只在新增收货地址时传
|
|
|
- shouHuoRen:_self.addressForm.name, //收货人
|
|
|
- mobile:_self.addressForm.mobile, //手机
|
|
|
- townID:_self.addressForm.townId, //区ID
|
|
|
- address:_self.addressForm.desc, //地址
|
|
|
- defaultFlag:_self.addressForm.default?1:0 //是否默认收货地址(0 不是默认,1 默认)
|
|
|
+ userId:_self.userId, // 用户id ,只在新增收货地址时传
|
|
|
+ receiver:_self.addressForm.name, // 收货人
|
|
|
+ mobile:_self.addressForm.mobile, // 手机
|
|
|
+ townId:_self.addressForm.townId, // 区ID
|
|
|
+ address:_self.addressForm.desc, // 地址
|
|
|
+ defaultFlag:_self.addressForm.default ? 1 : 0 //是否默认收货地址(0 不是默认,1 默认)
|
|
|
};
|
|
|
- if(_self.addressForm.id){
|
|
|
- // 编辑
|
|
|
- params.addressID = _self.addressForm.id;//编辑保存地址ID
|
|
|
+ if(_self.addressForm.id){// 编辑
|
|
|
+ params.addressId = _self.addressForm.id;//编辑保存地址ID
|
|
|
}
|
|
|
_self.saveAddress(params);
|
|
|
});
|
|
@@ -387,7 +446,7 @@ var shoppingConfirm = new Vue({
|
|
|
deleteAddress: function(addressId){// 列表删除单个地址
|
|
|
var _self = this;
|
|
|
CAIMEI.Modal('确定要删除该地址?','取消','确定',function () {
|
|
|
- OrderApi.DeleteAddress({addressID:addressId,userID:_self.userId},function (r) {
|
|
|
+ OrderApi.DeleteAddress({addressId:addressId,userId:_self.userId},function (r) {
|
|
|
if(r.code === 0 ){
|
|
|
CAIMEI.dialog('删除成功');
|
|
|
// 重新获取地址列表
|
|
@@ -403,20 +462,22 @@ var shoppingConfirm = new Vue({
|
|
|
},
|
|
|
confirmAddress: function(){// 确认地址并查询邮费
|
|
|
var _self = this;
|
|
|
- this.addressList.forEach(function(item){
|
|
|
- if (_self.address.selectedId==item.addressID){
|
|
|
- _self.address.id = item.addressID;
|
|
|
- _self.address.townId = item.townID;
|
|
|
- _self.address.cityId = item.cityID;
|
|
|
- _self.address.provinceId = item.provinceID;
|
|
|
- _self.address.name = item.shouHuoRen;
|
|
|
+ _self.addressList.forEach(function(item){
|
|
|
+ if (_self.address.selectedId==item.addressId){
|
|
|
+ _self.address.id = item.addressId;
|
|
|
+ _self.confirmParam.addressId = item.addressId;
|
|
|
+ _self.address.townId = item.townId;
|
|
|
+ _self.postageParam.townId = item.townId;
|
|
|
+ _self.address.cityId = item.cityId;
|
|
|
+ _self.address.provinceId = item.provinceId;
|
|
|
+ _self.address.name = item.receiver;
|
|
|
_self.address.mobile = item.mobile;
|
|
|
_self.address.desc = item.address;
|
|
|
_self.address.town = item.town;
|
|
|
_self.address.city = item.city;
|
|
|
_self.address.province = item.province;
|
|
|
_self.address.default = (item.defaultFlag > 0);
|
|
|
- _self.getFreight(_self.address.townId);
|
|
|
+ _self.getFreight();
|
|
|
}
|
|
|
});
|
|
|
this.closeAddressBox();
|
|
@@ -438,7 +499,7 @@ var shoppingConfirm = new Vue({
|
|
|
})
|
|
|
_self.couponAmount = coupon.couponAmount;
|
|
|
_self.totalDiscountAmount = _self.reducedPrice + _self.couponAmount;
|
|
|
- _self.clubCouponId = coupon.clubCouponId;
|
|
|
+ _self.confirmParam.clubCouponId = coupon.clubCouponId;
|
|
|
_self.changeDeductibleFreight();
|
|
|
_self.useUserMoney();
|
|
|
},
|
|
@@ -461,11 +522,11 @@ var shoppingConfirm = new Vue({
|
|
|
var _self = this;
|
|
|
if(this.balance.userMoney>0){
|
|
|
this.$nextTick(function() {
|
|
|
- var total = _self.totalPrice + _self.payInfo.freight - _self.couponAmount; // 订单总金额 + 邮费金额
|
|
|
+ var total = _self.totalPrice +_self.confirmParam.payInfo.postage - _self.couponAmount; // 订单总金额 + 邮费金额
|
|
|
if(_self.balance.flag){
|
|
|
- _self.payInfo.balancePayFlag = 1;
|
|
|
+ _self.confirmParam.payInfo.balancePayFlag = 1;
|
|
|
if(_self.balance.userMoney >= total){ // 全部抵扣
|
|
|
- _self.payInfo.orderShouldPayFee = 0;
|
|
|
+ _self.hanldShouldPayFee = 0;
|
|
|
if(_self.balance.isFreight){// 勾选了采美豆丢运费
|
|
|
_self.balance.deductMoney = _self.totalPrice - _self.couponAmount; // 抵扣使用金额 = 订单总金额
|
|
|
_self.balance.surplusMoney = _self.repiceNumSub(_self.balance.userMoney,_self.totalPrice); // 抵扣后剩余余额 = 余额总额 - (订单总金额+邮费金额)
|
|
@@ -477,99 +538,99 @@ var shoppingConfirm = new Vue({
|
|
|
}
|
|
|
}else{ // 部分抵扣
|
|
|
if(_self.balance.isFreight){// 勾选了采美豆丢运费
|
|
|
- _self.payInfo.orderShouldPayFee = _self.repiceNumSub(_self.totalPrice,_self.balance.userMoney) - _self.couponAmount; // 最终订单总价 = 订单总金额 - 余额总额
|
|
|
+ _self.hanldShouldPayFee = _self.repiceNumSub(_self.totalPrice,_self.balance.userMoney) - _self.couponAmount; // 最终订单总价 = 订单总金额 - 余额总额
|
|
|
_self.balance.deductMoney = _self.balance.userMoney; // 抵扣使用金额 = 余额总额
|
|
|
_self.balance.surplusMoney = 0; // 抵扣后剩余余额 = 0
|
|
|
- console.log('部分抵扣勾选了采美豆运费',_self.payInfo.orderShouldPayFee)
|
|
|
+ console.log('部分抵扣勾选了采美豆运费',_self.hanldShouldPayFee)
|
|
|
}else{
|
|
|
- _self.payInfo.orderShouldPayFee = _self.repiceNumSub(total,_self.balance.userMoney); // 最终订单总价 = 订单总金额 - 余额总额
|
|
|
+ _self.hanldShouldPayFee = _self.repiceNumSub(total,_self.balance.userMoney); // 最终订单总价 = 订单总金额 - 余额总额
|
|
|
_self.balance.deductMoney = _self.balance.userMoney; // 抵扣使用金额 = 余额总额
|
|
|
_self.balance.surplusMoney = 0; // 抵扣后剩余余额 = 0
|
|
|
- console.log('部分抵扣没有勾选了采美豆运费',_self.payInfo.orderShouldPayFee)
|
|
|
+ console.log('部分抵扣没有勾选了采美豆运费',_self.hanldShouldPayFee)
|
|
|
}
|
|
|
}
|
|
|
}else{// 取消抵扣
|
|
|
- _self.payInfo.balancePayFlag = 0;
|
|
|
+ _self.confirmParam.payInfo.balancePayFlag = 0;
|
|
|
_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 - _self.couponAmount; // 最终订单总价 = 订单总金额
|
|
|
+ _self.hanldShouldPayFee = _self.totalPrice - _self.couponAmount; // 最终订单总价 = 订单总金额
|
|
|
}else{
|
|
|
- _self.payInfo.orderShouldPayFee = total; // 最终订单总价 = 订单总金额 + 邮费金额
|
|
|
+ _self.hanldShouldPayFee = total; // 最终订单总价 = 订单总金额 + 邮费金额
|
|
|
}
|
|
|
- console.log('取消余额抵扣',_self.payInfo.orderShouldPayFee)
|
|
|
+ console.log('取消余额抵扣',_self.hanldShouldPayFee)
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
changeDeductibleFreight: function(){//选择采美豆抵扣邮费
|
|
|
var _self = this;
|
|
|
- var total = _self.totalPrice + _self.payInfo.freight - _self.couponAmount;
|
|
|
+ var total = _self.totalPrice +_self.confirmParam.payInfo.postage - _self.couponAmount;
|
|
|
if(_self.balance.isFreight){//判断是否勾选运费
|
|
|
- if(_self.payInfo.freePostFlag == 1){//有邮费
|
|
|
- _self.hanldUserBeans = _self.freightBeansMoney*100;
|
|
|
+ if(_self.confirmParam.payInfo.postageFlag == 1){//有邮费
|
|
|
+ _self.confirmParam.payInfo.userBeans = _self.freightBeansMoney*100;
|
|
|
if( _self.userBeans > 0 ){// 判断采美豆大于0
|
|
|
if(_self.balance.flag) {// 勾选了余额抵扣
|
|
|
console.log('订单总额',total)
|
|
|
if(_self.balance.userMoney>=total){ // 全部抵扣
|
|
|
- _self.payInfo.orderShouldPayFee = 0;
|
|
|
+ _self.hanldShouldPayFee = 0;
|
|
|
_self.balance.deductMoney = _self.totalPrice - _self.couponAmount; // 抵扣使用金额 = 订单总金额
|
|
|
_self.balance.surplusMoney = _self.repiceNumSub(_self.balance.userMoney,_self.balance.deductMoney); // 抵扣后剩余余额 = 余额总额 - 抵扣使用金额
|
|
|
- console.log('有勾选余额抵扣全抵',_self.payInfo.orderShouldPayFee)
|
|
|
+ console.log('有勾选余额抵扣全抵',_self.hanldShouldPayFee)
|
|
|
}else{ // 部分抵扣
|
|
|
- _self.payInfo.orderShouldPayFee = _self.repiceNumSub(_self.totalPrice,_self.balance.userMoney) - _self.couponAmount;
|
|
|
+ _self.hanldShouldPayFee = _self.repiceNumSub(_self.totalPrice,_self.balance.userMoney) - _self.couponAmount;
|
|
|
_self.balance.deductMoney = _self.balance.userMoney; // 抵扣使用金额 = 余额总额
|
|
|
_self.balance.surplusMoney = _self.repiceNumSub(_self.balance.userMoney,_self.balance.deductMoney); // 抵扣后剩余余额 = 余额总额 - 抵扣使用金额
|
|
|
- console.log('有勾选余额抵扣部分抵',_self.payInfo.orderShouldPayFee)
|
|
|
+ console.log('有勾选余额抵扣部分抵',_self.hanldShouldPayFee)
|
|
|
}
|
|
|
}else{
|
|
|
- _self.payInfo.orderShouldPayFee = ((_self.totalPrice*100 + _self.payInfo.freight*100 - _self.freightBeansMoney*100)/100) - _self.couponAmount;
|
|
|
- console.log('无余额抵扣',_self.payInfo.orderShouldPayFee)
|
|
|
+ _self.hanldShouldPayFee = ((_self.totalPrice*100 +_self.confirmParam.payInfo.postage*100 - _self.freightBeansMoney*100)/100) - _self.couponAmount;
|
|
|
+ console.log('无余额抵扣',_self.hanldShouldPayFee)
|
|
|
}
|
|
|
}
|
|
|
- }else if(_self.payInfo.freePostFlag == -1){// 到付
|
|
|
- _self.hanldUserBeans = _self.freightBeansMoney*100;
|
|
|
+ }else if(_self.confirmParam.payInfo.postageFlag == -1){// 到付
|
|
|
+ _self.confirmParam.payInfo.userBeans = _self.freightBeansMoney*100;
|
|
|
if(_self.balance.flag) {// 勾选了余额抵扣
|
|
|
if(_self.balance.userMoney >= total){ // 全部抵扣
|
|
|
- _self.payInfo.orderShouldPayFee = 0;
|
|
|
+ _self.hanldShouldPayFee = 0;
|
|
|
_self.balance.deductMoney = _self.totalPrice - _self.couponAmount; // 抵扣使用金额 = 订单总金额
|
|
|
_self.balance.surplusMoney = _self.repiceNumSub(_self.balance.userMoney,_self.balance.deductMoney); // 抵扣后剩余余额 = 余额总额 - 抵扣使用金额
|
|
|
- console.log('到付有勾选余额抵扣全抵',_self.payInfo.orderShouldPayFee)
|
|
|
+ console.log('到付有勾选余额抵扣全抵',_self.hanldShouldPayFee)
|
|
|
}else{ // 部分抵扣
|
|
|
- _self.payInfo.orderShouldPayFee = _self.repiceNumSub(_self.totalPrice,_self.balance.userMoney) - _self.couponAmount;
|
|
|
+ _self.hanldShouldPayFee =_self.hanldShouldPayFee = _self.repiceNumSub(_self.totalPrice,_self.balance.userMoney) - _self.couponAmount;
|
|
|
_self.balance.deductMoney = _self.balance.userMoney; // 抵扣使用金额 = 余额总额
|
|
|
_self.balance.surplusMoney = _self.repiceNumSub(_self.balance.userMoney,_self.balance.deductMoney); // 抵扣后剩余余额 = 余额总额 - 抵扣使用金额
|
|
|
- console.log('到付有勾选余额抵扣部分抵',_self.payInfo.orderShouldPayFee)
|
|
|
+ console.log('到付有勾选余额抵扣部分抵',_self.hanldShouldPayFee)
|
|
|
}
|
|
|
}else{
|
|
|
- _self.payInfo.orderShouldPayFee = _self.totalPrice - _self.couponAmount ;
|
|
|
- console.log('到付未勾选余额抵扣',_self.payInfo.orderShouldPayFee)
|
|
|
+ _self.hanldShouldPayFee = _self.totalPrice - _self.couponAmount ;
|
|
|
+ console.log('到付未勾选余额抵扣',_self.hanldShouldPayFee)
|
|
|
}
|
|
|
}else{
|
|
|
- _self.hanldUserBeans = 0;
|
|
|
- _self.payInfo.orderShouldPayFee = _self.totalPrice - _self.couponAmount ;
|
|
|
- console.log('其他',_self.payInfo.orderShouldPayFee)
|
|
|
+ _self.confirmParam.payInfo.userBeans = 0;
|
|
|
+ _self.hanldShouldPayFee = _self.totalPrice - _self.couponAmount ;
|
|
|
+ console.log('其他',_self.hanldShouldPayFee)
|
|
|
}
|
|
|
}else{
|
|
|
console.log('未勾选采美豆抵扣')
|
|
|
- _self.hanldUserBeans = 0;
|
|
|
+ _self.confirmParam.payInfo.userBeans = 0;
|
|
|
if(_self.balance.flag) {//如果勾选了余额抵扣
|
|
|
if(_self.balance.userMoney>=total) { // 全部抵扣
|
|
|
console.log('勾选采美豆抵扣=========》',total)
|
|
|
- _self.payInfo.orderShouldPayFee = 0 ;
|
|
|
+ _self.hanldShouldPayFee = 0 ;
|
|
|
_self.balance.deductMoney = total; // 抵扣使用金额 = (订单总金额+邮费金额-优惠券价格)
|
|
|
_self.balance.surplusMoney = _self.repiceNumSub(_self.balance.userMoney,_self.balance.deductMoney); // 抵扣后剩余余额 = 余额总额 - 抵扣使用金额
|
|
|
- console.log('余额全抵抵未勾选采美豆抵扣',_self.payInfo.orderShouldPayFee)
|
|
|
+ console.log('余额全抵抵未勾选采美豆抵扣',_self.hanldShouldPayFee)
|
|
|
}else{
|
|
|
console.log('未勾选采美豆抵扣=========》',total)
|
|
|
- _self.payInfo.orderShouldPayFee = _self.repiceNumSub(total,_self.balance.userMoney);
|
|
|
+ _self.hanldShouldPayFee = _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)
|
|
|
+ console.log('余额部分抵未勾选采美豆抵扣',_self.hanldShouldPayFee)
|
|
|
}
|
|
|
}else{
|
|
|
- _self.payInfo.orderShouldPayFee = (_self.totalPrice + _self.payInfo.freight) - _self.couponAmount;
|
|
|
+ _self.hanldShouldPayFee = (_self.totalPrice +_self.confirmParam.payInfo.postage) - _self.couponAmount;
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -593,107 +654,94 @@ var shoppingConfirm = new Vue({
|
|
|
},
|
|
|
submitOrder: function(){
|
|
|
var _self = this;
|
|
|
- if(this.submitLoading){return false;}
|
|
|
- if(!this.address.id){
|
|
|
+ if(_self.submitLoading){return false;}
|
|
|
+ if(!_self.confirmParam.addressId){
|
|
|
CAIMEI.dialog('请先添加收货地址~');
|
|
|
return false;
|
|
|
}
|
|
|
- if(this.invoice.type*1 === 1){
|
|
|
+ if(_self.orderInvoice.type*1 === 1){
|
|
|
// 普通发票
|
|
|
- if(!this.invoice.invoiceTitle){
|
|
|
+ if(!_self.orderInvoice.invoiceTitle){
|
|
|
CAIMEI.dialog('请输入个人抬头');return false;
|
|
|
}
|
|
|
- if(this.invoice.invoiceTitleType===1 && !this.invoice.corporationTaxNum){
|
|
|
+ if(_self.orderInvoice.invoiceTitleType===1 && !_self.orderInvoice.corporationTaxNum){
|
|
|
CAIMEI.dialog('请输入纳税人识别号');return false;
|
|
|
}
|
|
|
- }else if(this.invoice.type*1 === 2){
|
|
|
+ }else if(_self.orderInvoice.type*1 === 2){
|
|
|
// 增值税发票
|
|
|
- if(!this.invoice.invoiceTitle){
|
|
|
+ if(!_self.orderInvoice.invoiceTitle){
|
|
|
CAIMEI.dialog('请输入个人抬头');return false;
|
|
|
}
|
|
|
- if(!this.invoice.corporationTaxNum){
|
|
|
+ if(!_self.orderInvoice.corporationTaxNum){
|
|
|
CAIMEI.dialog('请输入纳税人识别号');return false;
|
|
|
}
|
|
|
- if(!this.invoice.registeredAddress){
|
|
|
+ if(!_self.orderInvoice.registeredAddress){
|
|
|
CAIMEI.dialog('请输入单位地址');return false;
|
|
|
}
|
|
|
- if(!this.invoice.registeredPhone){
|
|
|
+ if(!_self.orderInvoice.registeredPhone){
|
|
|
CAIMEI.dialog('请输入注册电话');return false;
|
|
|
}
|
|
|
- if(!this.invoice.openBank){
|
|
|
+ if(!_self.orderInvoice.openBank){
|
|
|
CAIMEI.dialog('请输入开户银行');return false;
|
|
|
}
|
|
|
- if(!this.invoice.bankAccountNo){
|
|
|
+ if(!_self.orderInvoice.bankAccountNo){
|
|
|
CAIMEI.dialog('请输入银行账号');return false;
|
|
|
}
|
|
|
}
|
|
|
// 禁用按钮
|
|
|
- this.submitLoading = true;
|
|
|
+ _self.submitLoading = true;
|
|
|
// 发票信息
|
|
|
- if(this.invoice.type*1 === 0){
|
|
|
- this.invoice = Object.assign(this.invoice,'',{type:0});
|
|
|
- }else if(this.invoice.type*1 === 1){
|
|
|
- this.invoice = Object.assign(this.invoice,'',{type:1, invoiceContent: '商品明细'});
|
|
|
- }else if(this.invoice.type*1 === 2){
|
|
|
- this.invoice = Object.assign(this.invoice,'',{type:2});
|
|
|
+ if(_self.confirmParam.orderInvoice.type*1 === 0){
|
|
|
+ _self.confirmParam.orderInvoice = Object.assign(_self.confirmParam.orderInvoice,'',{type:0});
|
|
|
+ }else if(_self.confirmParam.orderInvoice.type*1 === 1){
|
|
|
+ _self.confirmParam.orderInvoice = Object.assign(_self.confirmParam.orderInvoice,'',{type:1, invoiceContent: '商品明细'});
|
|
|
+ }else if(_self.confirmParam.orderInvoice.type*1 === 2){
|
|
|
+ _self.confirmParam.orderInvoice = Object.assign(_self.confirmParam.orderInvoice,'',{type:2});
|
|
|
}
|
|
|
//商品信息
|
|
|
- var _orderInfo = this.listData.map(function(supplier){
|
|
|
- var productInfo = [];
|
|
|
- supplier.cartList.forEach(function(item){
|
|
|
- productInfo.push({
|
|
|
- productId:item.productId,
|
|
|
- productNum:item.number,
|
|
|
- presentNum:0,
|
|
|
- productType:item.productType
|
|
|
- })
|
|
|
- });
|
|
|
- return {
|
|
|
- shopId: supplier.id,
|
|
|
- note: supplier.note ? supplier.note : '',
|
|
|
- productInfo: productInfo
|
|
|
- }
|
|
|
- });
|
|
|
- var _payInfo = {
|
|
|
- clauseId: 0,
|
|
|
- orderShouldPayFee: toFloat(this.payInfo.orderShouldPayFee),
|
|
|
- balancePayFlag: this.payInfo.balancePayFlag,
|
|
|
- freight: toFloat(this.payInfo.freight),
|
|
|
- freePostFlag: this.payInfo.freePostFlag,
|
|
|
- userBeans:this.hanldUserBeans
|
|
|
- };
|
|
|
- var params = {
|
|
|
- clubCouponId:this.clubCouponId,
|
|
|
- cartType: this.type,
|
|
|
- orderSource: 1, // 购买类型:(1购物车提交[对应表cm_cart],2直接购买提交, 3协销下单)
|
|
|
- serviceProviderId: '', // 协销ID(小程序忽略)
|
|
|
- clubUserId: this.userId, // 机构用户ID
|
|
|
- addressId: this.address.id,// 地址ID
|
|
|
- orderInfo: _orderInfo, // 商品信息
|
|
|
- payInfo: _payInfo, // 订单信息
|
|
|
- orderInvoice: this.invoice // 发票信息
|
|
|
- };
|
|
|
- OrderApi.ConfirmOrder({'params':JSON.stringify(params)},function (r) {
|
|
|
- if(r.code === 0){
|
|
|
- var _data = r.data;
|
|
|
- if(Number(_data.code) === 1){//余额抵扣全部订单金额
|
|
|
- var data = { payableAmount: _self.deductMoney };
|
|
|
+ _self.confirmParam.orderInfo = _self.listData.map(el => {
|
|
|
+ var productInfo = [];
|
|
|
+ el.cartList.forEach(item => {
|
|
|
+ productInfo.push({
|
|
|
+ productId:item.productId,
|
|
|
+ productNum:item.number,
|
|
|
+ presentNum:0,
|
|
|
+ productType:item.productType
|
|
|
+ })
|
|
|
+ })
|
|
|
+ return {shopId:el.shopId,note:el.note?el.note:'',productInfo:productInfo}
|
|
|
+ });
|
|
|
+ if(_self.orderInvoice.type!=0){
|
|
|
+ _self.orderInvoice.type = parseInt(_self.orderInvoice.type)
|
|
|
+ _self.confirmParam.orderInvoice = _self.orderInvoice;
|
|
|
+ }
|
|
|
+ _self.confirmParam.payInfo.postage = parseInt(_self.hanldPostage).toFixed(2);
|
|
|
+ _self.confirmParam.payInfo.postageFlag = parseInt(_self.hanldPostageFlag);
|
|
|
+ _self.confirmParam.payInfo.orderShouldPayFee = _self.hanldShouldPayFee.toFixed(2);
|
|
|
+ _self.confirmParam.payInfo = JSON.stringify(_self.confirmParam.payInfo);
|
|
|
+ _self.confirmParam.orderInfo = JSON.stringify(_self.confirmParam.orderInfo);
|
|
|
+ _self.confirmParam.orderInvoice = JSON.stringify(_self.confirmParam.orderInvoice);
|
|
|
+ OrderApi.ConfirmOrder(_self.confirmParam,function (res) {
|
|
|
+ if(res.code === 0){
|
|
|
+ var data = res.data;
|
|
|
+ if(data.code === 1){//余额抵扣全部订单金额
|
|
|
+ var Amount = { payableAmount: _self.deductMoney };
|
|
|
CAIMEI.Storage.removeItem('confirmOrderInfo');
|
|
|
- CAIMEI.Storage.setItem('confirmOrderInfo',JSON.stringify({data:data}));
|
|
|
- window.location.href = '/pay/success.html?pageType=www&type=success&payAmount='+_data.payTotalFee;
|
|
|
+ CAIMEI.Storage.setItem('confirmOrderInfo',JSON.stringify({data:Amount}));
|
|
|
+ window.location.href = '/pay/success.html?pageType=www&type=success&payAmount='+data.payTotalFee;
|
|
|
}else{//余额抵扣部分订单金额或者未支付的
|
|
|
- var data = {
|
|
|
- orderID:_data.orderID,
|
|
|
- orderNo:_data.orderNo,
|
|
|
- orderMark:_data.orderMark,
|
|
|
- payableAmount:_data.payableAmount
|
|
|
+ var order = {
|
|
|
+ orderId:data.orderId,
|
|
|
+ orderNo:data.orderNo,
|
|
|
+ orderMark:data.orderMark,
|
|
|
+ payableAmount:data.payableAmount
|
|
|
};
|
|
|
CAIMEI.Storage.removeItem('confirmOrderInfo');
|
|
|
- CAIMEI.Storage.setItem('confirmOrderInfo',JSON.stringify({data:data}));
|
|
|
- window.location.href = '/pay/caimei-paycash.html?type=confirm&orderID='+_data.orderID;
|
|
|
+ CAIMEI.Storage.setItem('confirmOrderInfo',JSON.stringify({data:order}));
|
|
|
+ window.location.href = '/pay/caimei-paycash.html?type=confirm&orderId='+data.orderId;
|
|
|
}
|
|
|
}else{
|
|
|
- CAIMEI.Alert(r.msg,'确定',true, function(){
|
|
|
+ CAIMEI.Alert(res.msg,'确定',true, function(){
|
|
|
setTimeout(function(){
|
|
|
_self.submitLoading = false;
|
|
|
},500);
|
|
@@ -703,24 +751,23 @@ var shoppingConfirm = new Vue({
|
|
|
}
|
|
|
},
|
|
|
created: function () {
|
|
|
- this.type = getUrlParam("type") ? getUrlParam("type")*1 : "";
|
|
|
+ var _self = this;
|
|
|
+ _self.type = getUrlParam("type") ? getUrlParam("type")*1 : "";
|
|
|
if(globalUserData){
|
|
|
- this.userId = globalUserData.userId;
|
|
|
- this.userIdentity = globalUserData.identity;
|
|
|
- this.userToken = globalUserData.token;
|
|
|
+ _self.userId = _self.productParam.userId = _self.cartParam.userId = _self.postageParam.userId = globalUserData.userId;
|
|
|
+ _self.confirmParam.clubId = globalUserData.clubId
|
|
|
+ _self.userIdentity = globalUserData.identity;
|
|
|
+ _self.userToken = globalUserData.token;
|
|
|
// type:(1购物车提交[对应表cm_cart],2直接购买提交, 3协销下单)
|
|
|
- if(this.type === 1) {
|
|
|
- this.productIds = window.localStorage.getItem("shoppingProductIds");
|
|
|
+ if(_self.type === 1) {
|
|
|
+ _self.cartParam.productIds = _self.postageParam.productIds = _self.productIds = window.localStorage.getItem("shoppingProductIds");
|
|
|
// 获取列表数据
|
|
|
- this.getConfirmList(null);
|
|
|
+ _self.getCartCreateOrderInfo();
|
|
|
}else if(this.type === 2){
|
|
|
- this.productIds = getUrlParam("id");
|
|
|
- var count = getUrlParam("count");
|
|
|
- if(this.productIds && count) {
|
|
|
- // 获取列表数据
|
|
|
- this.getConfirmList(count);
|
|
|
- }else{
|
|
|
- alertInfo("参数错误,请重新提交订单!");
|
|
|
+ _self.productParam.productId = _self.postageParam.productIds = _self.productIds = getUrlParam("productId");
|
|
|
+ _self.productParam.productCount = getUrlParam("count");
|
|
|
+ if(_self.productParam.productId && _self.productParam.productCount) {
|
|
|
+ _self.getProductCreateOrderInfo();
|
|
|
}
|
|
|
}
|
|
|
}
|