|
@@ -9,11 +9,15 @@
|
|
|
<!-- 发票信息 -->
|
|
|
<invoice-tent ref="invoice"
|
|
|
v-if="isRequest"
|
|
|
- :invoiceData="invoiceData"
|
|
|
+ :invoiceDatas="invoiceData"
|
|
|
@handleChoiceaInvoice="handleChoiceaInvoiceData">
|
|
|
</invoice-tent>
|
|
|
<!-- 运费 -->
|
|
|
- <freight ref="freight" v-if="isRequest" :freightData="freightData" @showFreightAlert="handFreightAlertShow"></freight>
|
|
|
+ <freight ref="freight"
|
|
|
+ v-if="isFreight"
|
|
|
+ :freightData="freightData"
|
|
|
+ @showFreightAlert="handFreightAlertShow">
|
|
|
+ </freight>
|
|
|
<freight-alert v-if="isfreightTip" ref="csPhone"></freight-alert>
|
|
|
<!-- 余额抵扣 -->
|
|
|
<view class="invoice-balance">
|
|
@@ -64,7 +68,7 @@
|
|
|
import freightAlert from '@/components/module/modelAlert/freightAlert'
|
|
|
import modalLayer from "@/components/modal-layer"
|
|
|
import { queryAddressList } from "@/api/cart.js"
|
|
|
- import { createOrderInfo,createOrderSubmit,getOrderPostage } from "@/api/order.js"
|
|
|
+ import { createOrderInfo,createOrderSubmit,getOrderPostage,getFindInvoice,updateInvoice } from "@/api/order.js"
|
|
|
|
|
|
export default {
|
|
|
components:{
|
|
@@ -95,6 +99,7 @@
|
|
|
addressID:'', //地址ID
|
|
|
townID:'', //区ID
|
|
|
isRequest:false, //是否加载完成渲染子组件
|
|
|
+ isFreight:false, //是否加载完成渲染子组件
|
|
|
isAddress:false, //是否加载完成地址
|
|
|
isfreightTip:false, //控制邮费弹窗
|
|
|
ischecked:false, //是否勾选余额
|
|
@@ -109,72 +114,64 @@
|
|
|
},
|
|
|
onLoad(option){//商品数据
|
|
|
let data = JSON.parse(option.data);
|
|
|
- console.log(data)
|
|
|
+ // console.log(data)
|
|
|
this.allPrice = data.data.allPrice;
|
|
|
this.allCount = data.data.allCount;
|
|
|
this.payAllPrice = this.allPrice;
|
|
|
- // console.log(data)
|
|
|
if(option.type =='prodcut'){
|
|
|
this.cartType = 2
|
|
|
this.productCount = data.data.productCount
|
|
|
this.productIds = data.data.productID
|
|
|
- // this.classifyIDS = data.data.classifyID
|
|
|
}else{
|
|
|
this.cartType = 1
|
|
|
this.productCount = data.data.productCount
|
|
|
this.productIds = data.data.productID
|
|
|
- // this.classifyIDS = data.data.classifyID
|
|
|
}
|
|
|
- this.getInitCrearOrder(option);
|
|
|
- // this.getAddressData()
|
|
|
+ this.$api.getStorage().then((resolve) =>{
|
|
|
+ this.userID = resolve.userID
|
|
|
+ this.getInitCrearOrder(option);
|
|
|
+ })
|
|
|
},
|
|
|
methods: {
|
|
|
getInitCrearOrder(option){//获取订单商品信息
|
|
|
- this.$api.getStorage().then((resolve) =>{
|
|
|
- this.userID = resolve.userID
|
|
|
- let params ={userId:this.userID,count:this.productCount,productIds:this.productIds}
|
|
|
- createOrderInfo(params).then(response =>{
|
|
|
- let resData = response.data
|
|
|
- this.isRequest = true
|
|
|
- this.goodsData = resData.shopList
|
|
|
- this.userMoney = resData.userMoney
|
|
|
- this.getUseFindInvoice()
|
|
|
- }).catch(response =>{
|
|
|
- this.$util.msg(response.msg,2000)
|
|
|
- })
|
|
|
+ let params ={userId:this.userID,count:this.productCount,productIds:this.productIds}
|
|
|
+ createOrderInfo(params).then(response =>{
|
|
|
+ let resData = response.data
|
|
|
+ this.isRequest = true
|
|
|
+ this.goodsData = resData.shopList
|
|
|
+ this.userMoney = resData.userMoney
|
|
|
+ this.getUseFindInvoice()
|
|
|
+ }).catch(response =>{
|
|
|
+ this.$util.msg(response.msg,2000)
|
|
|
})
|
|
|
},
|
|
|
getFreightData(){//获取邮费信息
|
|
|
- this.$api.getComStorage('orderUserInfo').then((resolve) =>{
|
|
|
- let params ={
|
|
|
- userId:resolve.userID,
|
|
|
- productIds:this.productIds,
|
|
|
- totalPrice:this.allPrice,
|
|
|
- townId:this.addressData.townID
|
|
|
- }
|
|
|
- getOrderPostage(params).then(response =>{
|
|
|
- console.log(response)
|
|
|
- this.isFreight = true
|
|
|
- this.freightData = response.data
|
|
|
- if(response.data.freePostFlag== 1){
|
|
|
- this.payAllPrice = this.payAllPrice+response.data.freight
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
+ let params ={
|
|
|
+ userId:this.userID,
|
|
|
+ productIds:this.productIds,
|
|
|
+ totalPrice:this.allPrice,
|
|
|
+ townId:this.addressData.townID
|
|
|
+ }
|
|
|
+ getOrderPostage(params).then(response =>{
|
|
|
+ console.log(response)
|
|
|
+ this.isFreight = true
|
|
|
+ this.freightData = response.data
|
|
|
+ if(response.data.freePostFlag== 1){
|
|
|
+ this.payAllPrice = this.payAllPrice+response.data.freight
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
getUseFindInvoice(){//获取发票信息
|
|
|
- this.$api.getComStorage('orderUserInfo').then((resolve) =>{
|
|
|
- getFindInvoice({userID:resolve.userID}).then(response =>{
|
|
|
- if(response.data == null){
|
|
|
- this.invoiceData = Object.assign(this.invoiceData,'',{type:0})
|
|
|
- }else{
|
|
|
- this.invoiceData = response.data
|
|
|
- }
|
|
|
- })
|
|
|
+ getFindInvoice({userID:this.userID}).then(response =>{
|
|
|
+ if(response.data == null){
|
|
|
+ this.invoiceData = Object.assign(this.invoiceData,'',{type:0})
|
|
|
+ }else{
|
|
|
+ this.invoiceData = response.data
|
|
|
+ }
|
|
|
})
|
|
|
},
|
|
|
getAddressData(){//获取地址信息
|
|
|
- this.$api.getStorage().then((resolve) =>{
|
|
|
+ this.$api.getStorage().then((resolve) => {
|
|
|
queryAddressList({pageNum:1,pageSize:1,userID:resolve.userID}).then(response =>{
|
|
|
this.isAddress = true
|
|
|
this.addressData = {}
|
|
@@ -196,35 +193,59 @@
|
|
|
handleChoiceaInvoiceData(data){//获取发票信息
|
|
|
console.log(data)
|
|
|
this.invoiceData = data
|
|
|
- this.$api.getComStorage('orderUserInfo').then((resolve) =>{
|
|
|
- let params =Object.assign(data,'',{userID:resolve.userID})
|
|
|
- updateInvoice(params).then(response =>{
|
|
|
- console.log(response)
|
|
|
- })
|
|
|
+ let params =Object.assign(data,'',{userID:this.userID})
|
|
|
+ updateInvoice(params).then(response =>{
|
|
|
+ console.log('<=====保存发票信息成功====>')
|
|
|
})
|
|
|
},
|
|
|
checkedBalabce(){//勾选使用余额
|
|
|
- if(this.userMoney == 0){
|
|
|
- return
|
|
|
- }else{
|
|
|
+ if(this.userMoney > 0){
|
|
|
this.ischecked = !this.ischecked
|
|
|
if(this.ischecked){
|
|
|
this.balanceDeductionFlag =1
|
|
|
- if(this.userMoney>this.payAllPrice){
|
|
|
- this.payAllPrice =0.00
|
|
|
- this.deductMoney = this.allPrice //勾选后使用抵余额
|
|
|
- this.surplusMoney = this.userMoney - this.deductMoney //勾选后的剩余抵扣
|
|
|
+ this.attributePallPrice()
|
|
|
+ }else{
|
|
|
+ if(this.freightData.freePostFlag == 1 || this.freightData.freePostFlag == '1'){
|
|
|
+ this.payAllPrice = this.allPrice+parseInt(this.freightData.freight)
|
|
|
}else{
|
|
|
- this.payAllPrice = this.allPrice - this.userMoney //勾选后的总价
|
|
|
- this.deductMoney = this.userMoney //勾选后使用抵余额
|
|
|
- this.surplusMoney = this.userMoney - this.deductMoney //勾选后的剩余抵扣
|
|
|
+ this.payAllPrice = this.allPrice
|
|
|
}
|
|
|
- }else{
|
|
|
- this.payAllPrice = this.allPrice
|
|
|
this.balanceDeductionFlag = 2
|
|
|
}
|
|
|
+ }else{
|
|
|
+ return
|
|
|
}
|
|
|
},
|
|
|
+ attributePallPrice(){//计算价格
|
|
|
+ if(this.freightData.freePostFlag == 1 || this.freightData.freePostFlag == '1'){
|
|
|
+ this.attributeHashfreight(this.freightData.freight)
|
|
|
+ }else{
|
|
|
+ this.attributeNofreight()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ attributeNofreight(){//计算没有邮费的支付价格
|
|
|
+ if(this.userMoney>this.payAllPrice){
|
|
|
+ this.payAllPrice = 0.00
|
|
|
+ this.deductMoney = this.allPrice //勾选后使用抵余额
|
|
|
+ this.surplusMoney = this.userMoney - this.deductMoney //勾选后的剩余抵扣
|
|
|
+ }else{
|
|
|
+ this.payAllPrice = this.allPrice - this.userMoney //勾选后的总价
|
|
|
+ this.deductMoney = this.userMoney //勾选后使用抵余额
|
|
|
+ this.surplusMoney = this.userMoney - this.deductMoney //勾选后的剩余抵扣
|
|
|
+ }
|
|
|
+ },
|
|
|
+ attributeHashfreight(freight){//计算需要邮费的支付价格
|
|
|
+ this.payAllPrice = this.allPrice+parseInt(freight)//计算不包邮的价格 总价等于商品价格+邮费
|
|
|
+ if(this.userMoney>this.payAllPrice){ //余额大于支付金额
|
|
|
+ this.payAllPrice =0.00
|
|
|
+ this.deductMoney = this.allPrice+parseInt(freight) //勾选后使用抵余额
|
|
|
+ this.surplusMoney = this.userMoney - this.deductMoney //勾选后的剩余抵扣
|
|
|
+ }else{
|
|
|
+ this.payAllPrice = this.allPrice+parseInt(freight) - this.userMoney //勾选后的总价
|
|
|
+ this.deductMoney = this.userMoney //勾选后使用抵余额
|
|
|
+ this.surplusMoney = this.userMoney - this.deductMoney //勾选后的剩余抵扣
|
|
|
+ }
|
|
|
+ },
|
|
|
orderSubmitMit(){//提交订单
|
|
|
if(this.addressID == ''){
|
|
|
this.$util.msg('请先添加收货地址~',2000)
|
|
@@ -239,23 +260,18 @@
|
|
|
presentNum:0
|
|
|
})
|
|
|
})
|
|
|
- if(el.note == null){
|
|
|
- el.note = ''
|
|
|
- }else{
|
|
|
- el.note = el.note
|
|
|
- }
|
|
|
- return {shopId:el.shopID,note:el.note,productInfo:productInfo}
|
|
|
+ return {shopId:el.shopID,note:el.note?el.note:'',productInfo:productInfo}
|
|
|
})
|
|
|
//订单信息
|
|
|
this.payInfo = {
|
|
|
clauseId:0,//条款(暂时保留)
|
|
|
- orderShouldPayFee:this.payAllPrice,//提交的总价
|
|
|
+ orderShouldPayFee:this.payAllPrice.toFixed(2),//提交的总价
|
|
|
balancePayFlag:this.balanceDeductionFlag,//余额抵扣的状态
|
|
|
- freight:this.freightData.freight,//邮费
|
|
|
- freePostFlag:this.freightData.freePostFlag//运费形式
|
|
|
+ freight:this.freightData.freight>0 ? this.freightData.freight : this.freightData.freight.toFixed(2),//邮费
|
|
|
+ freePostFlag:parseInt(this.freightData.freePostFlag)//运费形式
|
|
|
}
|
|
|
let param = {
|
|
|
- orderSource:1,
|
|
|
+ orderSource:6,
|
|
|
clubUserId:this.userID,
|
|
|
cartType:this.cartType,
|
|
|
addressId:this.addressID,
|