Просмотр исходного кода

付款成功返回指定路由或者关闭

lifanagju_citu 9 месяцев назад
Родитель
Сommit
8c51464e21

+ 6 - 1
src/components/pay/confirmPaymentDialog.vue

@@ -8,6 +8,7 @@
       title="确认支付"
       :footer="false"
       submitText="确认"
+      @paySuccess="paySuccess"
       @close="handleClose"
     >
       <pay
@@ -24,7 +25,7 @@ defineOptions({name: 'pay-confirmPaymentDialog'})
 import pay from './index.vue'
 import { ref } from 'vue'
 
-const emit = defineEmits(['close'])
+const emit = defineEmits(['close', 'paySuccess'])
 
 const payDialog = ref(false)
 setTimeout(() => {
@@ -35,6 +36,10 @@ const handleClose = () => {
   payDialog.value = false
   emit('close')
 }
+const paySuccess = () => {
+  payDialog.value = false
+  emit('paySuccess')
+}
 </script>
 <style lang="scss" scoped>
 </style>

+ 9 - 4
src/components/pay/index.vue

@@ -62,7 +62,7 @@ import { definePayTypeList, qrCodePay, walletPay } from './until/payType'
 import { getEnableCodeList, getUnpaidOrder, payOrderSubmit, getOrderPayStatus } from '@/api/common'
 import { createTradeOrder } from '@/api/position'
 import { useSharedState } from '@/store/sharedState'
-const emit = defineEmits(['payTypeChange', ])
+const emit = defineEmits(['payTypeChange', 'paySuccess'])
 const props = defineProps({
   params: {
     type: Object,
@@ -80,11 +80,16 @@ const props = defineProps({
     type: String,
     default: ''
   },
+  returnUrl: {
+    type: String,
+    default: ''
+  },
   type: {
     type: Number,
     default: 2 // 订单类型 0平台订单| 1发布职位订单| 2发布众聘职位订单,示例值(1)
   },
 })
+
 const loading = ref(true)
 
 const balance = JSON.parse(localStorage.getItem('enterpriseUserAccount'))?.balance || 0
@@ -197,7 +202,7 @@ const initPayQrCode = async () => {
         id: payOrder.value.id, // 支付单编号
         channelCode: payType.value, // 支付渠道
         displayMode: payOrder.value.notifyUrl, // 展示模式 notifyUrl
-        returnUrl: '',
+        // returnUrl: location.href, // 支付成功后,支付渠道跳转回当前页;再由当前页,跳转回 {@link returnUrl} 对应的地址
       }
       const res = await payOrderSubmit(params)
       payQrCodeTet.value = res?.displayContent || '' // 支付二维码
@@ -217,8 +222,8 @@ const payStatus = async () => {
       // 支付成功
       if (timer.value) clearInterval(timer.value); timer.value = null
       setTimeout(() => {
-        const query = { hire: true }
-        router.push({ path: '/recruit/enterprise/position', query }) // 返回到众聘页面
+        if (props.returnUrl) router.push(props.returnUrl) // 返回指定页面
+        else emit('paySuccess')
         Snackbar.success('付款成功')
       }, 1000);
     }

+ 1 - 0
src/views/recruit/enterprise/positionManagement/components/item.vue

@@ -80,6 +80,7 @@
     :spuId="spuId"
     :spuName="spuName"
     :type="2"
+    returnUrl="/recruit/enterprise/position?hire=true"
     @close="showConfirmPaymentDialog = false"
   ></confirmPaymentDialog>
 </template>