|
@@ -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="closePayPopup">
|
|
|
+ <view class="icon" @tap="handleClose">
|
|
|
<uni-icons
|
|
|
type="closeempty"
|
|
|
color="#999"
|
|
@@ -59,6 +59,10 @@ const props = defineProps({
|
|
|
type: String,
|
|
|
default: '支付'
|
|
|
},
|
|
|
+ tabBar: { // 页面底部导航菜单栏控制
|
|
|
+ type: Boolean,
|
|
|
+ default: true
|
|
|
+ },
|
|
|
})
|
|
|
|
|
|
const payType = [
|
|
@@ -100,22 +104,6 @@ const channelValue = ref('')
|
|
|
const radioChange = (e) => {
|
|
|
channelValue.value = e?.detail?.value || ''
|
|
|
}
|
|
|
-
|
|
|
-const tabBarShow = (show = false) => { // 显示/隐藏 TabBar
|
|
|
- console.log('tabBarShow:', show ? '展示' : '隐藏')
|
|
|
- const currentPage = getCurrentPages()
|
|
|
- if (!currentPage) return
|
|
|
- const currentTabBar = currentPage[0]?.getTabBar?.()
|
|
|
- currentTabBar?.setData({ show })
|
|
|
-}
|
|
|
-
|
|
|
-const popup = ref()
|
|
|
-const closePayPopup = () => {
|
|
|
- tabBarShow(true)
|
|
|
- popup.value.close()
|
|
|
- emit('close')
|
|
|
-}
|
|
|
-
|
|
|
const query = ref(null)
|
|
|
const amount = ref('') // 支付金额
|
|
|
const handleOpen = async (val) => {
|
|
@@ -123,7 +111,6 @@ const handleOpen = async (val) => {
|
|
|
await getPayMethodsList()
|
|
|
query.value = val
|
|
|
amount.value = Number(val?.price) ? Number(val?.price)/100 : 0
|
|
|
- tabBarShow(false)
|
|
|
popup.value.open('bottom')
|
|
|
}
|
|
|
|
|
@@ -223,12 +210,12 @@ const checkPayStatus = async (id) => {
|
|
|
payLoading = true
|
|
|
const res = await getOrderPayStatus({ id })
|
|
|
if (res?.data?.status === 10) {
|
|
|
- console.log('轮询支付状态:支付成功', res.data.status)
|
|
|
+ console.log('支付成功', res.data.status)
|
|
|
if (interTimer) clearInterval(interTimer); interTimer = null
|
|
|
- uni.showToast({ title: '支付成功', icon: 'none'})
|
|
|
+ // uni.showToast({ title: '支付成功', icon: 'none'})
|
|
|
+ popup.value.close()
|
|
|
setTimeout(async () => {
|
|
|
emit('paySuccess')
|
|
|
- closePayPopup()
|
|
|
}, 1500)
|
|
|
}
|
|
|
} catch (error) {
|
|
@@ -275,8 +262,6 @@ const weChatMiniProgramPay = async () => {
|
|
|
// 用户支付成功
|
|
|
console.log('用户支付成功')
|
|
|
initIntervalFun()
|
|
|
- popup.value.close()
|
|
|
- tabBarShow(true)
|
|
|
},
|
|
|
fail: (err) => {
|
|
|
if (err.errMsg === 'requestPayment:fail cancel') {
|
|
@@ -329,30 +314,46 @@ const setOrderCreated = async () => {
|
|
|
handlePay(true) // 避免死循环
|
|
|
}
|
|
|
|
|
|
-const pageHide = ref(false)
|
|
|
-onShow(() => {
|
|
|
- console.log('onShow')
|
|
|
- pageHide.value = false
|
|
|
-})
|
|
|
-onHide(() => {
|
|
|
- console.log('onHide')
|
|
|
- pageHide.value = true
|
|
|
- closePayPopup() // 关闭支付弹窗
|
|
|
-})
|
|
|
+const popup = ref()
|
|
|
+const handleClose = () => { // 手动关闭emit
|
|
|
+ console.log('手动关闭')
|
|
|
+ popup.value.close()
|
|
|
+ emit('close')
|
|
|
+}
|
|
|
+
|
|
|
+const tabBarShow = (show = false) => { // 显示/隐藏 TabBar
|
|
|
+ console.log(' 显示/隐藏 TabBar:', show ? '展示' : '隐藏')
|
|
|
+ const currentPage = getCurrentPages()
|
|
|
+ if (!currentPage) return
|
|
|
+ const currentTabBar = currentPage[0]?.getTabBar?.()
|
|
|
+ currentTabBar?.setData({ show })
|
|
|
+}
|
|
|
|
|
|
+// 显示/隐藏 TabBar
|
|
|
const popupChange = (e) => {
|
|
|
- console.log('popupChange:', )
|
|
|
+ console.log('popupChange支付弹窗状态', e)
|
|
|
if (!e || e.show === undefined) return
|
|
|
+ if (!props.tabBar) return // 页面没有底部导航菜单栏
|
|
|
if (e.show) {
|
|
|
// 支付弹窗打开
|
|
|
tabBarShow(false)
|
|
|
} else {
|
|
|
// 支付弹窗关闭
|
|
|
tabBarShow(true)
|
|
|
- if (interTimer) clearInterval(interTimer)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+const pageHide = ref(false)
|
|
|
+onShow(() => {
|
|
|
+ console.log('onShow')
|
|
|
+ pageHide.value = false
|
|
|
+})
|
|
|
+onHide(() => {
|
|
|
+ console.log('onHide')
|
|
|
+ pageHide.value = true // 支付的时候会AppHide,不能清空轮询
|
|
|
+ popup.value.close()
|
|
|
+})
|
|
|
+
|
|
|
defineExpose({
|
|
|
handleOpen
|
|
|
})
|