|
@@ -3,7 +3,7 @@
|
|
|
<uni-popup ref="popup" :is-mask-click="false" borderRadius="10px 10px 0 0" background-color="#eee" @change="popupChange">
|
|
|
<view class="popup-content">
|
|
|
<view class="popup-content-close">
|
|
|
- <view class="icon" @tap="handleClose">
|
|
|
+ <view class="icon" @tap="closePayPopup">
|
|
|
<uni-icons
|
|
|
type="closeempty"
|
|
|
color="#999"
|
|
@@ -101,8 +101,8 @@ const radioChange = (e) => {
|
|
|
channelValue.value = e?.detail?.value || ''
|
|
|
}
|
|
|
|
|
|
-const tabBarShow = (show = false) => { // 显示/隐藏TabBar
|
|
|
- console.log('tabBarShow:', )
|
|
|
+const tabBarShow = (show = false) => { // 显示/隐藏 TabBar
|
|
|
+ console.log('tabBarShow:', show ? '展示' : '隐藏')
|
|
|
const currentPage = getCurrentPages()
|
|
|
if (!currentPage) return
|
|
|
const currentTabBar = currentPage[0]?.getTabBar?.()
|
|
@@ -110,7 +110,7 @@ const tabBarShow = (show = false) => { // 显示/隐藏TabBar
|
|
|
}
|
|
|
|
|
|
const popup = ref()
|
|
|
-const handleClose = () => {
|
|
|
+const closePayPopup = () => {
|
|
|
tabBarShow(true)
|
|
|
popup.value.close()
|
|
|
emit('close')
|
|
@@ -211,31 +211,32 @@ const prepay = async (channel, orderData) => {
|
|
|
let interTimer = null
|
|
|
let payLoading = false
|
|
|
const checkPayStatus = async (id) => {
|
|
|
- console.log('checkPayStatus:', )
|
|
|
+ console.log('轮询支付状态:调用')
|
|
|
+ if (pageHide.value) {
|
|
|
+ console.log('轮询支付状态:页面隐藏:return')
|
|
|
+ return
|
|
|
+ }
|
|
|
if (!id) return
|
|
|
uni.showLoading({ title: '加载中' })
|
|
|
try {
|
|
|
if (payLoading || !interTimer) return
|
|
|
payLoading = true
|
|
|
const res = await getOrderPayStatus({ id })
|
|
|
- console.log('getOrderPayStatusApi:', res)
|
|
|
if (res?.data?.status === 10) {
|
|
|
- console.log('checkPayStatus-支付成功')
|
|
|
- handleClose()
|
|
|
- if (interTimer) clearInterval(interTimer)
|
|
|
- uni.hideLoading()
|
|
|
+ console.log('轮询支付状态:支付成功', res.data.status)
|
|
|
+ if (interTimer) clearInterval(interTimer); interTimer = null
|
|
|
uni.showToast({ title: '支付成功', icon: 'none'})
|
|
|
setTimeout(async () => {
|
|
|
emit('paySuccess')
|
|
|
+ closePayPopup()
|
|
|
}, 1500)
|
|
|
}
|
|
|
} catch (error) {
|
|
|
- console.log(error)
|
|
|
- handleClose()
|
|
|
- uni.hideLoading()
|
|
|
+ console.log('轮询支付状态:error', error)
|
|
|
if (interTimer) clearInterval(interTimer)
|
|
|
} finally {
|
|
|
payLoading = false
|
|
|
+ uni.hideLoading()
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -274,7 +275,7 @@ const weChatMiniProgramPay = async () => {
|
|
|
// 用户支付成功
|
|
|
console.log('用户支付成功')
|
|
|
initIntervalFun()
|
|
|
- // handleClose()
|
|
|
+ // closePayPopup()
|
|
|
},
|
|
|
fail: (err) => {
|
|
|
if (err.errMsg === 'requestPayment:fail cancel') {
|
|
@@ -327,13 +328,15 @@ const setOrderCreated = async () => {
|
|
|
handlePay(true) // 避免死循环
|
|
|
}
|
|
|
|
|
|
+const pageHide = ref(false)
|
|
|
onShow(() => {
|
|
|
console.log('onShow')
|
|
|
+ pageHide.value = false
|
|
|
})
|
|
|
onHide(() => {
|
|
|
console.log('onHide')
|
|
|
- // if (interTimer) clearInterval(interTimer)
|
|
|
- handleClose() // 关闭支付弹窗
|
|
|
+ pageHide.value = true
|
|
|
+ closePayPopup() // 关闭支付弹窗
|
|
|
})
|
|
|
|
|
|
const popupChange = (e) => {
|