确认订单页面及收银台页面调整
This commit is contained in:
@@ -1,106 +1,123 @@
|
||||
<template>
|
||||
<view>
|
||||
<oct-pay
|
||||
:price="price"
|
||||
:payNo="payNo"
|
||||
color="#34CE98"
|
||||
price-color="#e6576b"
|
||||
:payPlatform="platform"
|
||||
@onPay="pay"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { wxPAY, alPAY } from '@/apis/interfaces/pay'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
payNo : "",
|
||||
price : "",
|
||||
platform: ['wxpay', 'alipay']
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.payNo = this.$Route.query.orderNo
|
||||
this.price = Number(this.$Route.query.price).toFixed(2)
|
||||
},
|
||||
methods: {
|
||||
pay(e){
|
||||
uni.getProvider({
|
||||
service: 'payment',
|
||||
success: res => {
|
||||
if(res.provider.findIndex(val => val === e.platform) < 0){
|
||||
switch (e.platform){
|
||||
case 'wxpay':
|
||||
uni.showToast({
|
||||
title: '支付失败,您暂未安装微信',
|
||||
icon : 'none'
|
||||
})
|
||||
break;
|
||||
case 'alipay':
|
||||
uni.showToast({
|
||||
title: '支付失败,您暂未安装支付宝',
|
||||
icon : 'none'
|
||||
})
|
||||
break;
|
||||
}
|
||||
return
|
||||
}
|
||||
if(e.platform === 'wxpay') this.getWXPAY(e.platform)
|
||||
if(e.platform === 'alipay') this.getALPAY(e.platform)
|
||||
}
|
||||
})
|
||||
},
|
||||
getALPAY(payType){
|
||||
alPAY(this.payNo).then(res => {
|
||||
this.callPay(res, payType)
|
||||
})
|
||||
},
|
||||
getWXPAY(payType){
|
||||
wxPAY(this.payNo).then(res => {
|
||||
let config = JSON.parse(res)
|
||||
this.callPay(config, payType)
|
||||
})
|
||||
},
|
||||
callPay(orderInfo, payType){
|
||||
uni.requestPayment({
|
||||
provider: payType,
|
||||
orderInfo,
|
||||
success: payRes => {
|
||||
uni.showModal({
|
||||
title: '支付成功',
|
||||
content: '订单已支付,我们将尽快为您安排发货,可在订单管理查询订单动态',
|
||||
showCancel:false,
|
||||
success:onRes => {
|
||||
if(onRes.confirm){
|
||||
if(this.$Route.query.oepnType === 'order'){
|
||||
this.$store.commit('setRefresh', 1)
|
||||
}
|
||||
this.$Router.back()
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
fail: payErr => {
|
||||
if(payErr.errCode == '-100'){
|
||||
uni.showToast({
|
||||
title: '支付被取消',
|
||||
icon : 'none'
|
||||
})
|
||||
}else{
|
||||
uni.showToast({
|
||||
title: payErr.errMsg,
|
||||
icon : 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
<template>
|
||||
<view>
|
||||
<oct-pay :price="price" :payNo="payNo" color="#34CE98" price-color="#e6576b" :payPlatform="platform"
|
||||
@onPay="pay" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
wxPAY,
|
||||
alPAY
|
||||
} from '@/apis/interfaces/pay'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
payNo: "",
|
||||
price: "",
|
||||
platform: ['dtpay']
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.payNo = this.$Route.query.orderNo
|
||||
this.price = Number(this.$Route.query.price).toFixed(2)
|
||||
},
|
||||
methods: {
|
||||
pay(e) {
|
||||
if (e.platform === 'dtpay') return this.getDTPAY(e.platform);
|
||||
uni.getProvider({
|
||||
service: 'payment',
|
||||
success: res => {
|
||||
if (res.provider.findIndex(val => val === e.platform) < 0) {
|
||||
switch (e.platform) {
|
||||
case 'wxpay':
|
||||
uni.showToast({
|
||||
title: '支付失败,您暂未安装微信',
|
||||
icon: 'none'
|
||||
})
|
||||
break;
|
||||
case 'alipay':
|
||||
uni.showToast({
|
||||
title: '支付失败,您暂未安装支付宝',
|
||||
icon: 'none'
|
||||
})
|
||||
break;
|
||||
}
|
||||
return
|
||||
}
|
||||
if (e.platform === 'wxpay') this.getWXPAY(e.platform)
|
||||
if (e.platform === 'alipay') this.getALPAY(e.platform)
|
||||
|
||||
}
|
||||
})
|
||||
},
|
||||
getDTPAY(){
|
||||
console.log('dt 支付。。。')
|
||||
uni.showModal({
|
||||
title:'当前DT积分不足',
|
||||
content:'不能支付该订单,是否放弃当前支付',
|
||||
confirmText:'立即充值',
|
||||
confirmColor:"#34CE98",
|
||||
cancelText:'放弃支付',
|
||||
cancelColor:"#666666",
|
||||
success: (res) => {
|
||||
if(res.confirm){
|
||||
|
||||
}else{
|
||||
uni.navigateBack();
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
getALPAY(payType) {
|
||||
alPAY(this.payNo).then(res => {
|
||||
this.callPay(res, payType)
|
||||
})
|
||||
},
|
||||
getWXPAY(payType) {
|
||||
wxPAY(this.payNo).then(res => {
|
||||
let config = JSON.parse(res)
|
||||
this.callPay(config, payType)
|
||||
})
|
||||
},
|
||||
callPay(orderInfo, payType) {
|
||||
uni.requestPayment({
|
||||
provider: payType,
|
||||
orderInfo,
|
||||
success: payRes => {
|
||||
uni.showModal({
|
||||
title: '支付成功',
|
||||
content: '订单已支付,我们将尽快为您安排发货,可在订单管理查询订单动态',
|
||||
showCancel: false,
|
||||
success: onRes => {
|
||||
if (onRes.confirm) {
|
||||
if (this.$Route.query.oepnType === 'order') {
|
||||
this.$store.commit('setRefresh', 1)
|
||||
}
|
||||
this.$Router.back()
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
fail: payErr => {
|
||||
if (payErr.errCode == '-100') {
|
||||
uni.showToast({
|
||||
title: '支付被取消',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: payErr.errMsg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user