This commit is contained in:
唐明明
2023-05-22 11:13:29 +08:00
parent c77b741c61
commit 0fe6fd4aaf
47 changed files with 6090 additions and 39 deletions

View File

@@ -4,11 +4,15 @@
<view class="header">
<view class="header-title">实付金额</view>
<view class="header-price"><text></text>{{total}}</view>
<block v-if="rate != 1">
<view class="header-fire">火力值{{totalFire}}</view>
<view class="header-no">当前火力值比例1:{{rate}}</view>
</block>
<view class="header-no">订单号:{{orderNo}}</view>
</view>
<!-- 选择支付方式 -->
<view class="choose">
<radio-group @change="payMethod = $event.detail.value" >
<radio-group @change="changeRadio" >
<label class="choose-item" v-if="payType != 'free'">
<view class="choose-text nowrap">
<image src="@/static/icons/pay_alipay.png" mode="aspectFill"></image>
@@ -104,7 +108,22 @@
<script>
import { info } from '@/apis/interfaces/order.js'
import { coinPay, diffCoinPay, umsPay, umsState, diffUmsPay, umsFree, umsFreeInfo, dgPay, diffDgPay, dgFree } from '@/apis/interfaces/pay.js'
import { oderinfo } from '@/apis/interfaces/synthesisOrder.js'
import {
coinPay,
diffCoinPay,
umsPay,
umsState,
diffUmsPay,
umsFree,
umsFreeInfo,
dgPay,
diffDgPay,
dgFree,
umsSynthesize,
dgSynthesize,
coinSynthesize,
} from '@/apis/interfaces/pay.js'
import mixin from 'uview-ui/libs/mixin/mixin';
export default {
data() {
@@ -120,6 +139,10 @@
balance : 0,
isDeduction : false,
deductionVal: '',
// 综法支付订单类型
orderType : '',
rate : 1,
totalFire : '',
// 二维码支付
payCodeShow : false,
payQrUrl : '',
@@ -154,6 +177,28 @@
})
return
}
// 综法订单支付
if(this.$Route.query.paytype === 'synthesize'){
let order_type = this.$Route.query.orderType.replace(/\-/g, '\\')
oderinfo( this.$Route.query.orderId, order_type).then(res => {
let { order_no, price, score, order_id, rate, total_fire } = res
this.rate = rate
this.totalFire = total_fire
this.orderType = order_type
this.payType = this.$Route.query.paytype
this.orderId = order_id
this.total = price
this.orderNo = order_no
this.balance = score
uni.hideLoading()
}).catch(err => {
uni.showToast({
title: err.message,
icon : 'none'
})
})
return
}
// 其他支付方式订单信息
info(this.$Route.query.orderId).then(res => {
let { total, order_no, business_order_id, diff_prices, diff, score } = res
@@ -191,9 +236,6 @@
return
}
umsState(this.trade_id).then(res => {
console.log(res)
resNumb++
if(res.state === 'success'){
clearInterval(outTime)
@@ -222,6 +264,16 @@
this.payQrUrl = '',
this.payQrType = ''
},
// 选择支付方式
changeRadio(e){
let { value } = e.detail
this.payMethod = value
// 初始化金额
if(value == 'coin' || value == 'code'){
this.isDeduction = false
this.deductionVal = 0
}
},
// 抵扣金额
onDeductionSwitch(e){
this.deductionVal = ''
@@ -240,21 +292,23 @@
case 'coin':
if(this.payType == 'price') this.onCoinPay()
if(this.payType == 'diff') this.onDiffCoinPay()
if(this.payType == 'synthesize') this.onCoinSynthesizePay()
break;
case 'code':
uni.showActionSheet({
itemList:["微信付款码", "支付宝付款码"],
success : actionRes => {
console.log(actionRes.tapIndex)
if(actionRes.tapIndex === 0){
if(this.payType == 'price') this.onDgPay('app', true)
if(this.payType == 'diff') this.onDgDiffPay('app', true)
if(this.payType == 'free') this.onDgFreePay('app', true)
if(this.payType == 'synthesize') this.onFreeToast('onDgSynthesizePay', 'app', true)
}
if(actionRes.tapIndex === 1){
if(this.payType == 'price') this.onDgPay('app_alipay', true)
if(this.payType == 'diff') this.onDgDiffPay('app_alipay', true)
if(this.payType == 'free') this.onDgFreePay('app_alipay', true)
if(this.payType == 'synthesize') this.onFreeToast('onDgSynthesizePay', 'app_alipay', false)
}
}
})
@@ -263,24 +317,144 @@
if(this.payType == 'price') this.onUmsPay('app')
if(this.payType == 'diff') this.onDiffUmsPay('app')
if(this.payType == 'free') this.onFreePay('app')
if(this.payType == 'synthesize') this.onFreeToast('onUmsSynthesizePay', 'app')
break;
case 'ali':
if(this.payType == 'price') this.onUmsPay('app_alipay')
if(this.payType == 'diff') this.onDiffUmsPay('app_alipay')
if(this.payType == 'free') this.onFreePay('app_alipay')
if(this.payType == 'synthesize') this.onFreeToast('onUmsSynthesizePay', 'app_alipay')
break;
case 'dgwx':
if(this.payType == 'price') this.onDgPay('app', false)
if(this.payType == 'diff') this.onDgDiffPay('app', false)
if(this.payType == 'free') this.onDgFreePay('app', false)
if(this.payType == 'synthesize') this.onFreeToast('onDgSynthesizePay', 'app', false)
break;
case 'dgali':
if(this.payType == 'price') this.onDgPay('app_alipay', false)
if(this.payType == 'diff') this.onDgDiffPay('app_alipay', false)
if(this.payType == 'free') this.onDgFreePay('app_alipay', false)
if(this.payType == 'synthesize') this.onFreeToast('onDgSynthesizePay', 'app_alipay', false)
break
}
},
// 火力值 - 综法
onCoinSynthesizePay(){
coinSynthesize({
order_type : this.orderType,
order_id : this.orderId
}).then(res => {
wx.showModal({
title : '提示',
content : '火力值支付成功',
showCancel : false,
confirmColor: '#446EFE',
success : () => {
this.onRrmoveItem()
}
})
}).catch(err => {
uni.showToast({
title: err.message,
icon : 'none'
})
}).finally(() => {
uni.hideLoading()
})
},
// 火力值使用提示
onFreeToast(funName, type, isCode){
if(this.isDeduction){
let discount = this.deductionVal * this.rate
let surplus = Number(this.total) - (this.deductionVal * this.rate)
uni.showModal({
title : '支付提示',
content : '本次支付使用火力值抵扣现金:' + discount.toFixed(2) + '元,您还需支付现金:' + surplus.toFixed(2) + '元',
cancelText : '取消支付',
confirmText : '继续支付',
success : res => {
if(res.confirm){
this[funName](type, isCode)
}
}
})
return
}
this[funName](type, isCode)
},
// 银联三方 - 综法
onUmsSynthesizePay(type){
uni.showLoading({
title: '加载中...',
mask : true
})
umsSynthesize({
type,
order_type : this.orderType,
order_id : this.orderId,
fire : this.deductionVal || 0,
use_fire : this.isDeduction ? 1 : 0,
app_schema : 'doufire://',
}).then(res => {
this.getState = true
this.trade_id = res.trade_id
switch (type){
case 'app':
this.onMiniWx()
break;
case 'app_alipay':
plus.runtime.openURL(res.alipay)
break;
}
}).catch(err => {
uni.showToast({
title: err.message,
icon : 'none'
})
}).finally(() => {
uni.hideLoading()
})
},
// 斗拱 - 综法
onDgSynthesizePay(type, code){
uni.showLoading({
title: '加载中...',
mask : true
})
dgSynthesize({
type,
order_type : this.orderType,
order_id : this.orderId,
fire : this.deductionVal || 0,
use_fire : this.isDeduction ? 1 : 0,
app_schema : 'doufire://',
}).then(res => {
let { params, trade_id } = res;
// 二维码支付
if(code){
this.onDgPayCode(type, params, trade_id)
return
}
// 转跳付款
this.getState = true
this.trade_id = trade_id
if(type == 'app'){
let jumpUrl = JSON.parse(params.miniapp_data)
plus.runtime.openURL(jumpUrl.scheme_code)
}
if(type == 'app_alipay'){
plus.runtime.openURL(params.jump_url)
}
}).catch(err => {
uni.showToast({
title: err.message,
icon : 'none'
})
}).finally(() => {
uni.hideLoading()
})
},
// 斗拱支付
onDgPay(type, code){
uni.showLoading({
@@ -610,6 +784,11 @@
font-size: 28rpx;
color: gray;
}
.header-fire{
@extend .header-no;
font-size: 30rpx;
color: $text-price;
}
}
// 支付抵扣
.deduction{