Commit cc0b44ae by Jony.L

新支付功能-api模块支付重构

parent 5a8990ae
......@@ -48,6 +48,7 @@ export function createOrderSubmitWpgj(query){
})
}
export function createPay(query){
return request({
url: '/pay/order/submit',
......
......@@ -54,6 +54,7 @@ export function createApiOrderSubmit(query){
})
}
// === 老的微信支付接口(保留以便回退) ===
export function createPay(query){
return request({
url: '/pay/order/submit',
......@@ -61,3 +62,24 @@ export function createPay(query){
data: query
})
}
// === 新的WPGJ支付接口 ===
// 创建API订单(旺铺聚合支付)
export function createApiOrderSubmitWpgj(query){
return request({
url: '/apihub/api-order/create-wpgj',
method: 'post',
data: query
})
}
// WPGJ旺铺聚合支付订单查询(与算力资源模块共用)
export function getWpgjOrder(id) {
return request({
url: '/pay/order/wpgj-get',
method: 'get',
params: {
id
}
})
}
......@@ -95,7 +95,7 @@
</template>
<script name="ConfirmOrder" setup>
import { confirmOrderInfo, orderSubmit } from '@/api/computingResource.js'
// import { confirmOrderInfo, orderSubmit } from '@/api/computingResource.js'
import { useRoute, useRouter } from 'vue-router'
import { ref } from 'vue'
......@@ -104,19 +104,19 @@ const router = useRouter()
const tableData = ref([])
const totalPrice = ref(0)
const params = ref([])
confirmOrderInfo({id: route.query.id}).then(res => {
totalPrice.value = res.data.publicTotalPrice
params.value = JSON.parse(res.data.param)
tableData.value = [res.data]
})
function submit () {
orderSubmit({id: route.query.id}).then(res => {
if (res.data === 1) {
router.replace('/computingResource/orderResult')
}
})
}
// confirmOrderInfo({id: route.query.id}).then(res => {
// totalPrice.value = res.data.publicTotalPrice
// params.value = JSON.parse(res.data.param)
// tableData.value = [res.data]
// })
// function submit () {
// orderSubmit({id: route.query.id}).then(res => {
// if (res.data === 1) {
// router.replace('/computingResource/orderResult')
// }
// })
// }
</script>
......
......@@ -435,7 +435,7 @@ function create() {
// WPGJ聚合支付处理 - 后端现在直接返回AppPayOrderSubmitRespVO
if (res.data.displayContent) {
// 使用displayContent字段生成二维码,使用WPGJ订单ID进行轮询
getCode(res.data.displayContent, res.data.wpgjOrderId);
getCode(res.data.displayContent, res.data.id);
} else {
ElMessage.error('获取支付信息失败');
}
......
<template>
<div class="app-container shopping-cart">
<div class="page-title">
<div>购物车 (总共{{ tableData.length }})</div>
</div>
<div class="page-main">
<div class="detail-info">
<el-table :data="tableData" v-if="tableData.length !== 0" row-key="id" @selection-change="tableSelectionChange" align="center">
<el-table-column type="selection" reserve-selection/>
<el-table-column label="资源型号" prop="model"/>
<el-table-column label="配置详情" width="210px">
<template #default="{row}">
<p>CPU:{{ row.cpu }}</p>
<p>GPU:{{ row.gpu }}</p>
<p>内存:{{ row.memory }}</p>
<p>存储:{{ row.storage }}</p>
</template>
</el-table-column>
<!-- <el-table-column v-for="(item,index) in params[0]" :key="item.id" :label="item.name"-->
<!-- :width="item?.name?.length >= 8 ? '150px':''">-->
<!-- <template #default="scope">-->
<!-- {{ param[scope.$index][index]['valueName'] }}-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column v-for="(i, index) in headers" :key="index" :label="i.name" :prop="i.name"-->
<!-- :width="i?.name?.length >= 8 ? '150px':''">-->
<!-- <template v-slot="scope">-->
<!-- {{ getCellValue(scope.row.param, i.name) || '-' }}-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column label="配置参数" width="300px">
<template v-slot="scope">
<div v-for="(item, index) in JSON.parse(scope.row.param)" :key="index">
{{ item.name }}{{ item.valueName }}
</div>
</template>
</el-table-column>
<el-table-column label="申请数量" prop="useNum">
<template #default="{row}">
<el-input-number
v-model="row.useNum"
:min="1"
controls-position="right"
@change="editNum(row)"
style="width: 80px"/>
</template>
</el-table-column>
<el-table-column label="配置费用" prop="publicTotalPrice"/>
<el-table-column align="center" label="操作">
<template #default="{row}">
<el-popconfirm title="确认删除当前订单吗" width="180px" @confirm="confirmDel(row)">
<template #reference>
<el-button link>删除</el-button>
</template>
</el-popconfirm>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
v-model:page="pageNum"
v-model:limit="pageSize"
@pagination="getList"/>
<div v-if="tableData.length === 0" class="empty-box">
<el-empty description="暂无数据"/>
</div>
</div>
</div>
<div class="footer-bar">
<div class="content flex-space-between flex-align-center">
<div class="flex-align-center" style="font-size: 16px">
<span>已选 ({{ ids.length }})</span>
<el-popconfirm title="确认删除当前订单吗" width="180px" @confirm="confirmDel()">
<template #reference>
<div>
<el-button
:disabled="!ids.length"
link
style="margin-left: 40px;margin-top:2px;font-size: 16px">
删除
</el-button>
</div>
</template>
</el-popconfirm>
</div>
<div class="flex-align-center right">
<div class="mr20">
<div class="price">¥{{ totalPrice }}</div>
</div>
<el-button :disabled="!ids.length" type="primary" @click="submit">提交</el-button>
</div>
</div>
</div>
</div>
<!-- <div class="app-container shopping-cart">-->
<!-- <div class="page-title">-->
<!-- <div>购物车 (总共{{ tableData.length }})</div>-->
<!-- </div>-->
<!-- <div class="page-main">-->
<!-- <div class="detail-info">-->
<!-- <el-table :data="tableData" v-if="tableData.length !== 0" row-key="id" @selection-change="tableSelectionChange" align="center">-->
<!-- <el-table-column type="selection" reserve-selection/>-->
<!-- <el-table-column label="资源型号" prop="model"/>-->
<!-- <el-table-column label="配置详情" width="210px">-->
<!-- <template #default="{row}">-->
<!-- <p>CPU:{{ row.cpu }}</p>-->
<!-- <p>GPU:{{ row.gpu }}</p>-->
<!-- <p>内存:{{ row.memory }}</p>-->
<!-- <p>存储:{{ row.storage }}</p>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- &lt;!&ndash; <el-table-column v-for="(item,index) in params[0]" :key="item.id" :label="item.name"&ndash;&gt;-->
<!-- &lt;!&ndash; :width="item?.name?.length >= 8 ? '150px':''">&ndash;&gt;-->
<!-- &lt;!&ndash; <template #default="scope">&ndash;&gt;-->
<!-- &lt;!&ndash; {{ param[scope.$index][index]['valueName'] }}&ndash;&gt;-->
<!-- &lt;!&ndash; </template>&ndash;&gt;-->
<!-- &lt;!&ndash; </el-table-column>&ndash;&gt;-->
<!-- &lt;!&ndash; <el-table-column v-for="(i, index) in headers" :key="index" :label="i.name" :prop="i.name"&ndash;&gt;-->
<!-- &lt;!&ndash; :width="i?.name?.length >= 8 ? '150px':''">&ndash;&gt;-->
<!-- &lt;!&ndash; <template v-slot="scope">&ndash;&gt;-->
<!-- &lt;!&ndash; {{ getCellValue(scope.row.param, i.name) || '-' }}&ndash;&gt;-->
<!-- &lt;!&ndash; </template>&ndash;&gt;-->
<!-- &lt;!&ndash; </el-table-column>&ndash;&gt;-->
<!-- <el-table-column label="配置参数" width="300px">-->
<!-- <template v-slot="scope">-->
<!-- <div v-for="(item, index) in JSON.parse(scope.row.param)" :key="index">-->
<!-- {{ item.name }}:{{ item.valueName }}-->
<!-- </div>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column label="申请数量" prop="useNum">-->
<!-- <template #default="{row}">-->
<!-- <el-input-number-->
<!-- v-model="row.useNum"-->
<!-- :min="1"-->
<!-- controls-position="right"-->
<!-- @change="editNum(row)"-->
<!-- style="width: 80px"/>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column label="配置费用" prop="publicTotalPrice"/>-->
<!-- <el-table-column align="center" label="操作">-->
<!-- <template #default="{row}">-->
<!-- <el-popconfirm title="确认删除当前订单吗" width="180px" @confirm="confirmDel(row)">-->
<!-- <template #reference>-->
<!-- <el-button link>删除</el-button>-->
<!-- </template>-->
<!-- </el-popconfirm>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- </el-table>-->
<!-- <pagination-->
<!-- v-show="total > 0"-->
<!-- :total="total"-->
<!-- v-model:page="pageNum"-->
<!-- v-model:limit="pageSize"-->
<!-- @pagination="getList"/>-->
<!-- <div v-if="tableData.length === 0" class="empty-box">-->
<!-- <el-empty description="暂无数据"/>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="footer-bar">-->
<!-- <div class="content flex-space-between flex-align-center">-->
<!-- <div class="flex-align-center" style="font-size: 16px">-->
<!-- <span>已选 ({{ ids.length }})</span>-->
<!-- <el-popconfirm title="确认删除当前订单吗" width="180px" @confirm="confirmDel()">-->
<!-- <template #reference>-->
<!-- <div>-->
<!-- <el-button-->
<!-- :disabled="!ids.length"-->
<!-- link-->
<!-- style="margin-left: 40px;margin-top:2px;font-size: 16px">-->
<!-- 删除-->
<!-- </el-button>-->
<!-- </div>-->
<!-- </template>-->
<!-- </el-popconfirm>-->
<!-- </div>-->
<!-- <div class="flex-align-center right">-->
<!-- <div class="mr20">-->
<!-- <div class="price">¥{{ totalPrice }}</div>-->
<!-- </div>-->
<!-- <el-button :disabled="!ids.length" type="primary" @click="submit">提交</el-button>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
</template>
<script name="ConfirmOrder" setup>
import {
shoppingList,
shoppingEdit,
shoppingDelete,
shoppingSubmit,
shoppingComputerVo
} from '@/api/computingResource.js'
import {ref, computed} from 'vue'
import {ElMessageBox} from 'element-plus'
import {useRouter} from 'vue-router'
const router = useRouter()
const total = ref(0)
const pageNum = ref(1)
const pageSize = ref(10)
const tableData = ref([])
const params = ref([])
function getList() {
shoppingList({pageNum: pageNum.value, pageSize: pageSize.value}).then(res => {
tableData.value = res.rows
total.value = res.total
})
}
const handler = {
get(target, propKey) {
return target[propKey];
}
};
getList()
const ids = ref([])
function tableSelectionChange(value) {
ids.value = value.map(row => row.id)
shoppingComputer()
}
const headers = computed(() => {
if (tableData.value.length > 0 && tableData.value[0].param) {
const param = JSON.parse(tableData.value[0].param)
return param.map(item => ({
name: item.name
}));
}
return [];
});
const getCellValue = (params, headerName) => {
const paramsCopy = JSON.parse(params)
const param = paramsCopy.find(item => item.name === headerName);
return param ? param.valueName : '';
};
// const totalPrice = computed(() => {
// const list = tableData.value.filter(item => {
// return ids.value.includes(item.id)
// })
// let price = 0
// list.forEach(i => price += parseFloat(i.publicTotalPrice))
// return price
// })
function editNum(row) {
shoppingEdit({id: row.id, useNum: row.useNum}).then(res => {
shoppingComputer()
getList()
})
}
const totalPrice = ref(0)
function shoppingComputer() {
if (!ids.value.length) {
totalPrice.value = 0
return
}
shoppingComputerVo(ids.value).then(res => {
totalPrice.value = res.data.totalPulicPrice
})
}
function confirmDel(row) {
const idsValue = row?.id ? row.id : ids.value
shoppingDelete(idsValue).then(res => {
getList()
})
}
function submit() {
ElMessageBox.confirm(
'确认提交订单吗',
'提示',
{
confirmButtonText: '确认提交',
cancelButtonText: '关闭',
icon: 'QuestionFilled'
}
).then(() => {
shoppingSubmit(ids.value).then(res => {
router.push('/computingResource/orderResult')
})
}).catch(() => {
})
}
</script>
<style scoped lang="scss">
.app-container {
background-color: #F7F8F9;
padding: 0 0 90px;
min-height: 100%;
}
.page-title {
font-weight: bold;
font-size: 22px;
color: #303233;
padding: 12px 80px;
background-color: #FFFFFF;
> div {
width: 1280px;
margin: 0 auto;
}
}
.page-main {
padding: 30px 80px;
}
.detail-info {
width: 1280px;
margin: 0 auto;
padding: 0 24px 24px 24px;
background-color: #FFFFFF;
.el-table {
:deep(.el-table__header-wrapper ) th {
background-color: #FFFFFF !important;
font-size: 14px;
}
:deep(td.el-table__cell) {
background-color: #F7F8F9 !important;
}
}
//table {
// border-collapse: collapse;
//}
//
//tbody tr:not(:last-child) td {
// border-bottom: 1px solid #d7d7d7;
//}
//
//th {
// font-weight: 500;
// font-size: 14px;
// color: #303233;
// text-align: left;
// padding: 16px 20px;
//}
//
//td {
// font-weight: 400;
// font-size: 14px;
// color: #303233;
// text-align: left;
// padding: 16px 20px;
// background-color: #F7F8F9;
//}
}
.empty-box {
display: flex;
justify-content: center;
align-items: center;
min-height: 650px;
}
.footer-bar {
padding: 18px;
background-color: #FFFFFF;
position: fixed;
z-index: 99;
bottom: 0;
width: 100%;
-webkit-box-shadow: 2px 0 6px rgba(0, 21, 41, 0.25);
.content {
margin: 0 auto;
width: 1280px;
}
.price {
font-weight: bold;
font-size: 24px;
color: #FF9811;
& + div {
font-weight: 400;
font-size: 14px;
color: #949899;
text-align: right;
}
}
.right .el-button {
width: 180px;
height: 46px;
font-size: 20px;
border-radius: 2px 2px 2px 2px;
}
}
</style>
<!--<script name="ConfirmOrder" setup>-->
<!--import {-->
<!-- shoppingList,-->
<!-- shoppingEdit,-->
<!-- shoppingDelete,-->
<!-- shoppingSubmit,-->
<!-- shoppingComputerVo-->
<!--} from '@/api/computingResource.js'-->
<!--import {ref, computed} from 'vue'-->
<!--import {ElMessageBox} from 'element-plus'-->
<!--import {useRouter} from 'vue-router'-->
<!--const router = useRouter()-->
<!--const total = ref(0)-->
<!--const pageNum = ref(1)-->
<!--const pageSize = ref(10)-->
<!--const tableData = ref([])-->
<!--const params = ref([])-->
<!--function getList() {-->
<!-- shoppingList({pageNum: pageNum.value, pageSize: pageSize.value}).then(res => {-->
<!-- tableData.value = res.rows-->
<!-- total.value = res.total-->
<!-- })-->
<!--}-->
<!--const handler = {-->
<!-- get(target, propKey) {-->
<!-- return target[propKey];-->
<!-- }-->
<!--};-->
<!--getList()-->
<!--const ids = ref([])-->
<!--function tableSelectionChange(value) {-->
<!-- ids.value = value.map(row => row.id)-->
<!-- shoppingComputer()-->
<!--}-->
<!--const headers = computed(() => {-->
<!-- if (tableData.value.length > 0 && tableData.value[0].param) {-->
<!-- const param = JSON.parse(tableData.value[0].param)-->
<!-- return param.map(item => ({-->
<!-- name: item.name-->
<!-- }));-->
<!-- }-->
<!-- return [];-->
<!--});-->
<!--const getCellValue = (params, headerName) => {-->
<!-- const paramsCopy = JSON.parse(params)-->
<!-- const param = paramsCopy.find(item => item.name === headerName);-->
<!-- return param ? param.valueName : '';-->
<!--};-->
<!--// const totalPrice = computed(() => {-->
<!--// const list = tableData.value.filter(item => {-->
<!--// return ids.value.includes(item.id)-->
<!--// })-->
<!--// let price = 0-->
<!--// list.forEach(i => price += parseFloat(i.publicTotalPrice))-->
<!--// return price-->
<!--// })-->
<!--function editNum(row) {-->
<!-- shoppingEdit({id: row.id, useNum: row.useNum}).then(res => {-->
<!-- shoppingComputer()-->
<!-- getList()-->
<!-- })-->
<!--}-->
<!--const totalPrice = ref(0)-->
<!--function shoppingComputer() {-->
<!-- if (!ids.value.length) {-->
<!-- totalPrice.value = 0-->
<!-- return-->
<!-- }-->
<!-- shoppingComputerVo(ids.value).then(res => {-->
<!-- totalPrice.value = res.data.totalPulicPrice-->
<!-- })-->
<!--}-->
<!--function confirmDel(row) {-->
<!-- const idsValue = row?.id ? row.id : ids.value-->
<!-- shoppingDelete(idsValue).then(res => {-->
<!-- getList()-->
<!-- })-->
<!--}-->
<!--function submit() {-->
<!-- ElMessageBox.confirm(-->
<!-- '确认提交订单吗',-->
<!-- '提示',-->
<!-- {-->
<!-- confirmButtonText: '确认提交',-->
<!-- cancelButtonText: '关闭',-->
<!-- icon: 'QuestionFilled'-->
<!-- }-->
<!-- ).then(() => {-->
<!-- shoppingSubmit(ids.value).then(res => {-->
<!-- router.push('/computingResource/orderResult')-->
<!-- })-->
<!-- }).catch(() => {-->
<!-- })-->
<!--}-->
<!--</script>-->
<!--<style scoped lang="scss">-->
<!--.app-container {-->
<!-- background-color: #F7F8F9;-->
<!-- padding: 0 0 90px;-->
<!-- min-height: 100%;-->
<!--}-->
<!--.page-title {-->
<!-- font-weight: bold;-->
<!-- font-size: 22px;-->
<!-- color: #303233;-->
<!-- padding: 12px 80px;-->
<!-- background-color: #FFFFFF;-->
<!-- > div {-->
<!-- width: 1280px;-->
<!-- margin: 0 auto;-->
<!-- }-->
<!--}-->
<!--.page-main {-->
<!-- padding: 30px 80px;-->
<!--}-->
<!--.detail-info {-->
<!-- width: 1280px;-->
<!-- margin: 0 auto;-->
<!-- padding: 0 24px 24px 24px;-->
<!-- background-color: #FFFFFF;-->
<!-- .el-table {-->
<!-- :deep(.el-table__header-wrapper ) th {-->
<!-- background-color: #FFFFFF !important;-->
<!-- font-size: 14px;-->
<!-- }-->
<!-- :deep(td.el-table__cell) {-->
<!-- background-color: #F7F8F9 !important;-->
<!-- }-->
<!-- }-->
<!-- //table {-->
<!-- // border-collapse: collapse;-->
<!-- //}-->
<!-- //-->
<!-- //tbody tr:not(:last-child) td {-->
<!-- // border-bottom: 1px solid #d7d7d7;-->
<!-- //}-->
<!-- //-->
<!-- //th {-->
<!-- // font-weight: 500;-->
<!-- // font-size: 14px;-->
<!-- // color: #303233;-->
<!-- // text-align: left;-->
<!-- // padding: 16px 20px;-->
<!-- //}-->
<!-- //-->
<!-- //td {-->
<!-- // font-weight: 400;-->
<!-- // font-size: 14px;-->
<!-- // color: #303233;-->
<!-- // text-align: left;-->
<!-- // padding: 16px 20px;-->
<!-- // background-color: #F7F8F9;-->
<!-- //}-->
<!--}-->
<!--.empty-box {-->
<!-- display: flex;-->
<!-- justify-content: center;-->
<!-- align-items: center;-->
<!-- min-height: 650px;-->
<!--}-->
<!--.footer-bar {-->
<!-- padding: 18px;-->
<!-- background-color: #FFFFFF;-->
<!-- position: fixed;-->
<!-- z-index: 99;-->
<!-- bottom: 0;-->
<!-- width: 100%;-->
<!-- -webkit-box-shadow: 2px 0 6px rgba(0, 21, 41, 0.25);-->
<!-- .content {-->
<!-- margin: 0 auto;-->
<!-- width: 1280px;-->
<!-- }-->
<!-- .price {-->
<!-- font-weight: bold;-->
<!-- font-size: 24px;-->
<!-- color: #FF9811;-->
<!-- & + div {-->
<!-- font-weight: 400;-->
<!-- font-size: 14px;-->
<!-- color: #949899;-->
<!-- text-align: right;-->
<!-- }-->
<!-- }-->
<!-- .right .el-button {-->
<!-- width: 180px;-->
<!-- height: 46px;-->
<!-- font-size: 20px;-->
<!-- border-radius: 2px 2px 2px 2px;-->
<!-- }-->
<!--}-->
<!--</style>-->
......@@ -259,7 +259,7 @@ import {
//getMerchantInfo,
getAppRecommendList,
//getAppCategoryList,
getAppInfoDetail, createApiOrderSubmit,createPay
getAppInfoDetail, createApiOrderSubmit,createPay, createApiOrderSubmitWpgj, getWpgjOrder
} from "../../api/marketplace";
import {ElMessage, ElMessageBox} from "element-plus";
import { OfficeBuilding, Phone } from '@element-plus/icons-vue'
......@@ -537,8 +537,56 @@ function getCreateData(){
}
function create() {
// 用户点击“确认”时执行
// 用户点击"确认"时执行
const createData = getCreateData();
// === 新的WPGJ支付流程 ===
// 创建API订单(旺铺聚合支付)
createApiOrderSubmitWpgj({
apiId: productData.value.id,
packageId: currentPackageId.value,
}).then(res => {
console.log('API WPGJ支付响应数据:', res.data);
// 弹出确认对话框
ElMessageBox.confirm(
'确定购买吗?', // 对话框提示文字
'购买确认', // 对话框标题
{
confirmButtonText: '确认', // 确认按钮文字
cancelButtonText: '取消', // 取消按钮文字
type: 'warning' // 对话框类型(警告样式)
}
)
.then(() => {
// WPGJ聚合支付处理 - 后端现在直接返回支付信息
if (res.data.displayContent) {
// 使用displayContent字段生成二维码,使用WPGJ订单ID进行轮询
getCodeWpgj(res.data.displayContent, res.data.id);
} else {
ElMessage.error('获取支付信息失败');
}
showDrawer.value = false;
})
.catch(() => {
ElMessageBox.confirm(
'订单已创建,请前往控制台-api订单查看',
'提示',
{
confirmButtonText: '确认',
showCancelButton: false,
type: 'success'
}
).then(() => {
showDrawer.value = false;
})
});
}).catch(err => {
console.error('创建API订单失败:', err);
ElMessage.error('创建订单失败,请重试');
});
// === 老的支付流程代码(注释掉以便回退) ===
/*
//创建订单
createApiOrderSubmit(
{
......@@ -581,25 +629,77 @@ function create() {
}).catch(err => {
// 接口调用失败的处理(如提示错误)
});
*/
}
// === 新的WPGJ支付函数 ===
function getCodeWpgj(value, wpgjOrderId) {
QRCode.toDataURL(value, {errorCorrectionLevel: 'L', margin: 2, width: 350}, (err, url) => {
if (err) throw err
qrCode.value = {
url: url,
title: '请使用微信或支付宝扫码支付',
visible: true
}
}
)
createQueryIntervalWpgj(wpgjOrderId)
}
// === 老的支付函数(注释掉以便回退) ===
/*
function getCode(value, payOrderId) {
QRCode.toDataURL(value, {errorCorrectionLevel: 'L', margin: 2, width: 350}, (err, url) => {
if (err) throw err
qrCode.value = {
url: url,
title: '请使用微信“扫一扫”扫码支付',
title: '请使用微信"扫一扫"扫码支付',
visible: true
}
}
)
createQueryInterval(payOrderId)
}
*/
// === 新的WPGJ轮询查询任务 ===
const createQueryIntervalWpgj = (id) => {
if (interval.value) {
return
}
interval.value = setInterval(async () => {
try {
const res = await getWpgjOrder(id)
console.log(res, 'API WPGJ轮询结果')
// 已支付
if (res.data.orderStatus === '1') {
clearQueryInterval()
ElMessageBox.confirm(
'支付成功',
'请前往控制台-api订单查看',
{
confirmButtonText: '确认',
showCancelButton: false,
type: 'success'
}
).then(() => {})
}
// 已取消或失败
if (res.data.orderStatus === '2') {
clearQueryInterval()
ElMessage.error('支付已关闭!')
}
} catch (e) {
// 静默捕获轮询异常
}
}, 1000 * 2)
}
/** 轮询查询任务 */
// === 老的轮询查询任务(注释掉以便回退) ===
/*
const createQueryInterval = (id) => {
if (interval.value) {
return
......@@ -631,7 +731,10 @@ const createQueryInterval = (id) => {
}
}, 1000 * 2)
}
*/
// === 老的支付订单查询(注释掉以便回退) ===
/*
// 查询详情支付订单
const getOrder = async (id, sync) => {
return await request({
......@@ -643,6 +746,7 @@ const getOrder = async (id, sync) => {
}
})
}
*/
/** 清空查询任务 */
const clearQueryInterval = () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment