|
|
|
@ -28,7 +28,8 @@ |
|
|
|
|
<text>(可用¥{{ personal.balance }}元)</text> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="item-right col-m" v-if="curPaymentItem && curPaymentItem.method == item.method"> |
|
|
|
|
<!-- <view class="item-right col-m" v-if="curPaymentItem && curPaymentItem.method == item.method"> --> |
|
|
|
|
<view class="item-right col-m" v-if="isCheckedHandle(item.method)"> |
|
|
|
|
<text class="iconfont icon-check"></text> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
@ -62,18 +63,21 @@ |
|
|
|
|
import { PayMethodEnum } from '@/common/enum/payment' |
|
|
|
|
import { PayStatusEnum } from '@/common/enum/order' |
|
|
|
|
import * as CashierApi from '@/api/cashier' |
|
|
|
|
|
|
|
|
|
import * as getpayinfo from '@/api/bargain/checkout.js' |
|
|
|
|
|
|
|
|
|
// 支付方式对应的图标 |
|
|
|
|
const PayMethodIconEnum = { |
|
|
|
|
[PayMethodEnum.WECHAT.value]: 'icon-wechat-pay', |
|
|
|
|
[PayMethodEnum.ALIPAY.value]: 'icon-alipay', |
|
|
|
|
[PayMethodEnum.BALANCE.value]: 'icon-balance-pay' |
|
|
|
|
[PayMethodEnum.BALANCE.value]: 'icon-balance-pay', |
|
|
|
|
[PayMethodEnum.POINT.value]: 'icon-balance-pay', |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 支付方式的终端名称 |
|
|
|
|
const PayMethodClientNameEnum = { |
|
|
|
|
[PayMethodEnum.WECHAT.value]: '微信', |
|
|
|
|
[PayMethodEnum.ALIPAY.value]: '支付宝' |
|
|
|
|
[PayMethodEnum.ALIPAY.value]: '支付宝', |
|
|
|
|
[PayMethodEnum.POINT.value]: '积分', |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
@ -91,7 +95,7 @@ |
|
|
|
|
PayMethodIconEnum, |
|
|
|
|
PayMethodClientNameEnum, |
|
|
|
|
// 当前选中的支付方式 |
|
|
|
|
curPaymentItem: null, |
|
|
|
|
curPaymentItem: [], |
|
|
|
|
// 当前订单ID |
|
|
|
|
orderId: null, |
|
|
|
|
// 当前结算订单信息 |
|
|
|
@ -159,9 +163,56 @@ |
|
|
|
|
|
|
|
|
|
// 选择支付方式 |
|
|
|
|
handleSelectPayType(index) { |
|
|
|
|
this.curPaymentItem = this.methods[index] |
|
|
|
|
console.log(index,this.methods,this.curPaymentItem) |
|
|
|
|
let arr = this.curPaymentItem.filter(item=>{ |
|
|
|
|
return item.method==this.methods[index].method |
|
|
|
|
}) |
|
|
|
|
if(arr.length>0){ |
|
|
|
|
// 需要删除 |
|
|
|
|
this.curPaymentItem.forEach((item,i)=>{ |
|
|
|
|
if(item.method==this.methods[index].method){ |
|
|
|
|
// 需要删除 |
|
|
|
|
this.curPaymentItem.splice(i,1) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}else{ |
|
|
|
|
// 需要增加 |
|
|
|
|
this.curPaymentItem.push(this.methods[index]) |
|
|
|
|
} |
|
|
|
|
if(this.methods[index].method=='point'){ |
|
|
|
|
// 调用积分支付的接口 |
|
|
|
|
let res =this.curPaymentItem.filter(item=>{ |
|
|
|
|
return item.method=='point' |
|
|
|
|
}) |
|
|
|
|
let app = this; |
|
|
|
|
CashierApi.getpayinfo({ orderID:this.orderId,isUsePoints:res.length>0?1:0 }).then(result => { |
|
|
|
|
console.log(result) |
|
|
|
|
app.order = result.data.order |
|
|
|
|
app.personal = result.data.personal |
|
|
|
|
app.methods = result.data.paymentMethods |
|
|
|
|
app.isLoading = false |
|
|
|
|
// app.setDefaultPayType() |
|
|
|
|
app.checkOrderPayStatus() |
|
|
|
|
// #ifdef H5 |
|
|
|
|
// 判断当前页面来源于浏览器返回 |
|
|
|
|
this.performance() |
|
|
|
|
// #endif |
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
// this.curPaymentItem = this.methods[index] |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
isCheckedHandle(item){ |
|
|
|
|
|
|
|
|
|
let arr = this.curPaymentItem.filter(i=>{ |
|
|
|
|
return i.method==item |
|
|
|
|
}) |
|
|
|
|
if(arr.length>0){ |
|
|
|
|
return true |
|
|
|
|
}else{ |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 判断当前页面来源于浏览器返回 |
|
|
|
|
// #ifdef H5 |
|
|
|
|
performance() { |
|
|
|
@ -196,7 +247,7 @@ |
|
|
|
|
handleSubmit() { |
|
|
|
|
const app = this |
|
|
|
|
// 判断是否选择了支付方式 |
|
|
|
|
if (!app.curPaymentItem) { |
|
|
|
|
if (app.curPaymentItem.length==0) { |
|
|
|
|
app.$toast('您还没有选择支付方式') |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
@ -204,8 +255,21 @@ |
|
|
|
|
if (app.disabled) return |
|
|
|
|
app.disabled = true |
|
|
|
|
// 提交到后端API |
|
|
|
|
let method=null; |
|
|
|
|
let isWX = app.curPaymentItem.filter(item=>{ |
|
|
|
|
return item.method=="wechat" |
|
|
|
|
}) |
|
|
|
|
let isPoint = app.curPaymentItem.filter(item=>{ |
|
|
|
|
return item.method=="point" |
|
|
|
|
}) |
|
|
|
|
if(app.curPaymentItem.length>0&&isWX.length>0){ |
|
|
|
|
method = 'wechat' |
|
|
|
|
} |
|
|
|
|
if(app.curPaymentItem.length>0&&isWX.length==0&&isPoint.length>0){ |
|
|
|
|
method = 'point' |
|
|
|
|
} |
|
|
|
|
CashierApi.orderPay(app.orderId, { |
|
|
|
|
method: app.curPaymentItem.method, |
|
|
|
|
method: method, |
|
|
|
|
client: app.platform, |
|
|
|
|
extra: app.getExtraAsUnify(app.curPaymentItem.method) |
|
|
|
|
}) |
|
|
|
@ -227,7 +291,15 @@ |
|
|
|
|
// 订单提交成功后回调 |
|
|
|
|
onSubmitCallback(result) { |
|
|
|
|
const app = this |
|
|
|
|
const method = app.curPaymentItem.method |
|
|
|
|
// const method = app.curPaymentItem.method |
|
|
|
|
let method; |
|
|
|
|
let isWX = app.curPaymentItem.filter(item=>{ |
|
|
|
|
return item.method=="wechat" |
|
|
|
|
}) |
|
|
|
|
if(isWX.length>0){ |
|
|
|
|
method = "wechat" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const paymentData = result.data.payment |
|
|
|
|
// 余额支付 |
|
|
|
|
if (method === PayMethodEnum.BALANCE.value) { |
|
|
|
|