同步
This commit is contained in:
@@ -8,15 +8,15 @@
|
||||
</view>
|
||||
<!-- 选择支付方式 -->
|
||||
<view class="choose">
|
||||
<radio-group @change="payMethod = $event.detail.value">
|
||||
<label class="choose-item">
|
||||
<radio-group @change="payMethod = $event.detail.value" >
|
||||
<label class="choose-item" v-if="payType != 'free'">
|
||||
<view class="choose-text nowrap">
|
||||
<image src="@/static/icons/pay_alipay.png" mode="aspectFill"></image>
|
||||
火力值支付
|
||||
</view>
|
||||
<radio class="choose-radio" value="coin" checked></radio>
|
||||
<radio class="choose-radio" value="coin" :checked="payMethod == 'coin'"></radio>
|
||||
</label>
|
||||
<label class="choose-item nowrap">
|
||||
<!-- <label class="choose-item nowrap">
|
||||
<view class="choose-text">
|
||||
<image src="@/static/icons/pay_code.png" mode="aspectFill"></image>
|
||||
付款码支付
|
||||
@@ -29,6 +29,13 @@
|
||||
微信支付
|
||||
</view>
|
||||
<radio class="choose-radio" value="wx"></radio>
|
||||
</label> -->
|
||||
<label class="choose-item nowrap">
|
||||
<view class="choose-text">
|
||||
<image src="@/static/icons/pay_ali.png" mode="aspectFill"></image>
|
||||
支付宝支付
|
||||
</view>
|
||||
<radio class="choose-radio" value="ali" :checked="payMethod == 'ali'"></radio>
|
||||
</label>
|
||||
</radio-group>
|
||||
</view>
|
||||
@@ -41,23 +48,86 @@
|
||||
|
||||
<script>
|
||||
import { info } from '@/apis/interfaces/order.js'
|
||||
import { coinPay, diffCoinPay } from '@/apis/interfaces/pay.js'
|
||||
import { coinPay, diffCoinPay, umsPay, umsState, diffUmsPay, umsFree, umsFreeInfo } from '@/apis/interfaces/pay.js'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
getState : false,
|
||||
trade_id : '',
|
||||
orderId : '',
|
||||
diffId : '',
|
||||
payMethod : 'coin',
|
||||
payType : 'price',
|
||||
total : '0.00',
|
||||
orderNo : ''
|
||||
orderNo : '',
|
||||
};
|
||||
},
|
||||
onShow() {
|
||||
if(this.getState && this.trade_id != ''){
|
||||
// 查询支付状态
|
||||
uni.showLoading({
|
||||
title: '查询支付结果...',
|
||||
mask : true
|
||||
})
|
||||
let outTime;
|
||||
let resNumb = 0;
|
||||
outTime = setInterval(() => {
|
||||
if(resNumb >= 3){
|
||||
clearInterval(outTime)
|
||||
uni.showToast({
|
||||
title: '查询失败',
|
||||
icon : 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
umsState(this.trade_id).then(res => {
|
||||
resNumb++
|
||||
if(res.state === 'success'){
|
||||
clearInterval(outTime)
|
||||
wx.showModal({
|
||||
title : '提示',
|
||||
content : '支付成功',
|
||||
showCancel : false,
|
||||
confirmColor: '#446EFE',
|
||||
success : () => {
|
||||
this.onRrmoveItem()
|
||||
}
|
||||
})
|
||||
}
|
||||
}).catch(err => {
|
||||
console.log(err)
|
||||
clearInterval(outTime)
|
||||
uni.showToast({
|
||||
title: err.message,
|
||||
icon : 'none'
|
||||
})
|
||||
})
|
||||
}, 2000)
|
||||
}
|
||||
},
|
||||
created() {
|
||||
uni.showLoading({
|
||||
title: '获取订单信息...',
|
||||
mask : true
|
||||
})
|
||||
if(this.$Route.query.paytype === 'free'){
|
||||
this.payMethod = "ali"
|
||||
umsFreeInfo(this.$Route.query.serviceId).then(res => {
|
||||
let { order_id, price, order_no } = res;
|
||||
this.orderId = order_id
|
||||
this.total = price
|
||||
this.orderNo = order_no
|
||||
this.payType = this.$Route.query.paytype
|
||||
uni.hideLoading()
|
||||
}).catch(err => {
|
||||
console.log(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 } = res
|
||||
this.orderId = business_order_id
|
||||
@@ -93,8 +163,53 @@
|
||||
icon : 'none'
|
||||
})
|
||||
break;
|
||||
case 'ali':
|
||||
if(this.payType == 'price') this.onUmsPay('mp_alipay')
|
||||
if(this.payType == 'diff') this.onDiffUmsPay('mp_alipay')
|
||||
if(this.payType == 'free') this.onFreePay('mp_alipay')
|
||||
break;
|
||||
}
|
||||
},
|
||||
// 银联三方支付
|
||||
onUmsPay(type){
|
||||
uni.showLoading({
|
||||
title: '加载中...',
|
||||
mask : true
|
||||
})
|
||||
umsPay(this.orderId, { type }).then(res => {
|
||||
uni.hideLoading()
|
||||
this.getState = true
|
||||
this.trade_id = res.trade_id
|
||||
if(res.alipay){
|
||||
plus.runtime.openURL(res.alipay)
|
||||
}
|
||||
}).catch(err => {
|
||||
uni.showToast({
|
||||
title: err.message,
|
||||
icon : 'none'
|
||||
})
|
||||
})
|
||||
},
|
||||
// 银联三方补差价支付
|
||||
onDiffUmsPay(type){
|
||||
uni.showLoading({
|
||||
title: '加载中...',
|
||||
mask : true
|
||||
})
|
||||
diffUmsPay(this.diffId, {type}).then(res => {
|
||||
uni.hideLoading()
|
||||
this.getState = true
|
||||
this.trade_id = res.trade_id
|
||||
if(res.alipay){
|
||||
plus.runtime.openURL(res.alipay)
|
||||
}
|
||||
}).catch(err => {
|
||||
uni.showToast({
|
||||
title: err.message,
|
||||
icon : 'none'
|
||||
})
|
||||
})
|
||||
},
|
||||
// 火力值支付
|
||||
onCoinPay(){
|
||||
wx.showLoading({
|
||||
@@ -118,7 +233,7 @@
|
||||
})
|
||||
})
|
||||
},
|
||||
// 活力值补差价支付
|
||||
// 火力值补差价支付
|
||||
onDiffCoinPay(){
|
||||
diffCoinPay(this.diffId).then(res => {
|
||||
wx.showModal({
|
||||
@@ -137,6 +252,26 @@
|
||||
})
|
||||
})
|
||||
},
|
||||
// 银联三方自由服务包支付
|
||||
onFreePay(type){
|
||||
wx.showLoading({
|
||||
title: '加载中...',
|
||||
mask : true
|
||||
})
|
||||
umsFree(this.orderId, type).then(res => {
|
||||
uni.hideLoading()
|
||||
this.getState = true
|
||||
this.trade_id = res.trade_id
|
||||
if(res.alipay){
|
||||
plus.runtime.openURL(res.alipay)
|
||||
}
|
||||
}).catch(err => {
|
||||
uni.showToast({
|
||||
title: err.message,
|
||||
icon : 'none'
|
||||
})
|
||||
})
|
||||
},
|
||||
// 更新订单列表
|
||||
onRrmoveItem(){
|
||||
this.$store.commit('setOrderId', this.orderId)
|
||||
|
||||
Reference in New Issue
Block a user