|
@@ -85,7 +85,7 @@ const payType = [
|
|
|
const payTypeList = ref([])
|
|
|
// 获取支付方式
|
|
|
const getPayMethodsList = async () => {
|
|
|
- console.log('获取支付方式:', )
|
|
|
+ console.log('获取支付方式列表')
|
|
|
payTypeList.value = []
|
|
|
try {
|
|
|
const res = await getEnableCodeList({appId: 10})
|
|
@@ -107,7 +107,7 @@ const radioChange = (e) => {
|
|
|
const query = ref(null)
|
|
|
const amount = ref('') // 支付金额
|
|
|
const handleOpen = async (val) => {
|
|
|
- console.log('handleOpen打开支付:', )
|
|
|
+ console.log('打开支付popup')
|
|
|
await getPayMethodsList()
|
|
|
query.value = val
|
|
|
amount.value = Number(val?.price) ? Number(val?.price)/100 : 0
|
|
@@ -159,7 +159,7 @@ const socialType = 34; // 社交类型 - 微信小程序
|
|
|
|
|
|
// 预支付
|
|
|
const prepay = async (channel, orderData) => {
|
|
|
- console.log('预支付prepay:', )
|
|
|
+ console.log('微信预支付')
|
|
|
return new Promise(async (resolve, reject) => {
|
|
|
let data = {
|
|
|
id: orderData?.payOrder?.id,
|
|
@@ -198,7 +198,7 @@ const prepay = async (channel, orderData) => {
|
|
|
let interTimer = null
|
|
|
let payLoading = false
|
|
|
const checkPayStatus = async (id) => {
|
|
|
- console.log('轮询支付状态:调用')
|
|
|
+ console.log('进入轮询订单状态')
|
|
|
if (pageHide.value) {
|
|
|
console.log('轮询支付状态:页面隐藏:return')
|
|
|
return
|
|
@@ -210,7 +210,7 @@ const checkPayStatus = async (id) => {
|
|
|
payLoading = true
|
|
|
const res = await getOrderPayStatus({ id })
|
|
|
if (res?.data?.status === 10) {
|
|
|
- console.log('支付成功', res.data.status)
|
|
|
+ console.log('轮询订单状态:支付成功')
|
|
|
if (interTimer) clearInterval(interTimer); interTimer = null
|
|
|
// uni.showToast({ title: '支付成功', icon: 'none'})
|
|
|
popup.value.close()
|
|
@@ -219,7 +219,7 @@ const checkPayStatus = async (id) => {
|
|
|
}, 1500)
|
|
|
}
|
|
|
} catch (error) {
|
|
|
- console.log('轮询支付状态:error', error)
|
|
|
+ console.log('轮询订单状态报错:error', error)
|
|
|
if (interTimer) clearInterval(interTimer)
|
|
|
} finally {
|
|
|
payLoading = false
|
|
@@ -227,9 +227,9 @@ const checkPayStatus = async (id) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// 计时器
|
|
|
+// 轮询订单状态
|
|
|
const initIntervalFun = () => {
|
|
|
- console.log('计时器initIntervalFun:', )
|
|
|
+ console.log('开启轮询订单状态')
|
|
|
if (interTimer) clearInterval(interTimer)
|
|
|
|
|
|
// 查询是否已经支付
|
|
@@ -243,12 +243,12 @@ const initIntervalFun = () => {
|
|
|
|
|
|
const orderInfo = ref({})
|
|
|
const weChatMiniProgramPay = async () => {
|
|
|
- console.log('weChatMiniProgramPay调用微信小程序支付')
|
|
|
let res = await prepay(channelValue.value, orderInfo.value); // 预支付
|
|
|
if (res?.code !== 0) {
|
|
|
return;
|
|
|
}
|
|
|
// 调用微信小程序支付
|
|
|
+ console.log('调用微信小程序支付打印')
|
|
|
const payConfig = res?.data?.displayContent ? JSON.parse(res.data.displayContent) : null
|
|
|
if (!payConfig) return uni.showToast({ title: '购买失败', icon: 'none'})
|
|
|
uni.requestPayment({
|
|
@@ -260,8 +260,8 @@ const weChatMiniProgramPay = async () => {
|
|
|
paySign: payConfig.paySign,
|
|
|
success: (res) => {
|
|
|
// 用户支付成功
|
|
|
- console.log('用户支付成功')
|
|
|
- initIntervalFun()
|
|
|
+ console.log('用户支付成功success打印')
|
|
|
+ initIntervalFun() // 轮询订单状态
|
|
|
},
|
|
|
fail: (err) => {
|
|
|
if (err.errMsg === 'requestPayment:fail cancel') {
|
|
@@ -273,9 +273,9 @@ const weChatMiniProgramPay = async () => {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-// 确认支付
|
|
|
+// 确认支付按钮
|
|
|
const handlePay = async (retry = false) => {
|
|
|
- console.log('确认支付handlePay:', )
|
|
|
+ console.log('点击确认支付按钮')
|
|
|
if (!channelValue.value) {
|
|
|
uni.showToast({ title: '请选择支付方式', icon: 'none'})
|
|
|
return
|
|
@@ -302,7 +302,6 @@ const handlePay = async (retry = false) => {
|
|
|
|
|
|
// 创建订单
|
|
|
const setOrderCreated = async () => {
|
|
|
- console.log('setOrderCreated-createTradeOrder:', )
|
|
|
const params = {
|
|
|
spuId: query.value?.spuId, // 商品编号
|
|
|
type: query.value?.type, // 订单类型 0平台订单|1发布职位|2发布众聘职位|3会员套餐|4企业会员套餐|5招聘会门票
|
|
@@ -322,7 +321,7 @@ const handleClose = () => { // 手动关闭emit
|
|
|
}
|
|
|
|
|
|
const tabBarShow = (show = false) => { // 显示/隐藏 TabBar
|
|
|
- console.log(' 显示/隐藏 TabBar:', show ? '展示' : '隐藏')
|
|
|
+ console.log('TabBar:', show ? '展示' : '隐藏')
|
|
|
const currentPage = getCurrentPages()
|
|
|
if (!currentPage) return
|
|
|
const currentTabBar = currentPage[0]?.getTabBar?.()
|
|
@@ -345,11 +344,9 @@ const popupChange = (e) => {
|
|
|
|
|
|
const pageHide = ref(false)
|
|
|
onShow(() => {
|
|
|
- console.log('onShow')
|
|
|
pageHide.value = false
|
|
|
})
|
|
|
onHide(() => {
|
|
|
- console.log('onHide')
|
|
|
pageHide.value = true // 支付的时候会AppHide,不能清空轮询
|
|
|
popup.value.close()
|
|
|
})
|