浏览代码

打印台

lifanagju_citu 1 月之前
父节点
当前提交
8fdc5018c0
共有 1 个文件被更改,包括 13 次插入14 次删除
  1. 13 14
      components/payPopup/index.vue

+ 13 - 14
components/payPopup/index.vue

@@ -254,10 +254,9 @@ const initIntervalFun = () => {
 }
 
 const orderInfo = ref({})
-const weChatMiniProgramPay = async (data) => {
-  console.log('weChatMiniProgramPay:', )
-  orderInfo.value = data
-  let res = await prepay(channelValue.value, data); // 预支付
+const weChatMiniProgramPay = async () => {
+  console.log('weChatMiniProgramPay调用微信小程序支付')
+  let res = await prepay(channelValue.value, orderInfo.value); // 预支付
   if (res?.code !== 0) {
     return;
   }
@@ -301,18 +300,20 @@ const handlePay = async (retry = false) => {
       type: query.value?.type // 订单类型 0平台订单|1发布职位|2发布众聘职位|3会员套餐|4企业会员套餐|5招聘会门票
     }
     if (!params.spuId || params.type === null || params.type === undefined) return
-    const res = await getUnpaidOrder(params) // 查询订单
-    if (res.data) {
-      // 获取支付码
+    const res = await getUnpaidOrder(params) // 1.查询订单
+    if (res?.data) {
+      orderInfo.value = res.data
+      // 微信小程序支付
       weChatMiniProgramPay(res.data)
       return
     }
-    if (!retry) setOrderCreated() // 创建订单
+    if (!retry) setOrderCreated() // 2.创建订单
   } catch (error) {
     console.log(error)
   }
 }
 
+// 创建订单
 const setOrderCreated = async () => {
   console.log('setOrderCreated-createTradeOrder:', )
   const params = {
@@ -327,13 +328,12 @@ const setOrderCreated = async () => {
 }
 
 onShow(() => {
-  const id = orderInfo.value?.payOrder?.id || orderInfo.value?.order?.payOrderId
-  console.log('onShow:', id)
-  if (id) initIntervalFun()
+  console.log('onShow')
 })
 onHide(() => {
-  console.log('onHide:', 789)
-  if (interTimer) clearInterval(interTimer)
+  console.log('onHide')
+  // if (interTimer) clearInterval(interTimer)
+  handleClose() // 关闭支付弹窗
 })
 
 const popupChange = (e) => {
@@ -342,7 +342,6 @@ const popupChange = (e) => {
   if (e.show) {
     // 支付弹窗打开
     tabBarShow(false)
-    if (orderInfo && orderInfo.value?.id) initIntervalFun()
   } else {
     // 支付弹窗关闭
     tabBarShow(true)