登录对接
This commit is contained in:
@@ -51,20 +51,27 @@
|
||||
@refresh="init"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<OrderStatusDialog ref="orderStatusDialogRef" @close="handleStatusClose" @refresh="init" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue'
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import MobileLayout from './MobileLayout/index.vue'
|
||||
import DesktopLayout from './DesktopLayout/index.vue'
|
||||
import OrderStatusDialog from '@/components/user-center/OrderStatusDialog.vue'
|
||||
import Logo from '@/pages/Home/logo.svg?component'
|
||||
import MobileLogo from '@/pages/Home/mobile-logo.svg?component'
|
||||
import request from '@/utils/request'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
// --- State ---
|
||||
const selectedPlanId = ref('p2')
|
||||
const selectedPayment = ref('alipay') // This variable is no longer directly used for payment selection in the UI, but kept for potential future use or if other parts of the app rely on it.
|
||||
const orderStatusDialogRef = ref<InstanceType<typeof OrderStatusDialog> | null>(null)
|
||||
const selectedPayment = ref('alipay')
|
||||
|
||||
const devices = ref<any[]>([])
|
||||
const plans = ref<any[]>([])
|
||||
@@ -130,7 +137,7 @@ const handlePay = (methodId: number | string) => {
|
||||
|
||||
const already = alreadySubscribed.value.find((s: any) => s.subscribe_id === plan.planId)
|
||||
const isRenewal = !!already
|
||||
const api = isRenewal ? '/api/v1//public/order/renewal' : '/api/v1/public/order/purchase'
|
||||
const api = isRenewal ? '/api/v1/public/order/renewal' : '/api/v1/public/order/purchase'
|
||||
const params: any = {
|
||||
subscribe_id: plan.planId,
|
||||
quantity: plan.quantity,
|
||||
@@ -145,11 +152,15 @@ const handlePay = (methodId: number | string) => {
|
||||
request
|
||||
.post('/api/v1/public/portal/order/checkout', {
|
||||
orderNo: res.order_no,
|
||||
returnUrl: window.location.origin,
|
||||
returnUrl: `${window.location.origin}/user-center?order_no=${res.order_no}`,
|
||||
})
|
||||
.then((checkoutRes: any) => {
|
||||
if (checkoutRes.type === 'url' && checkoutRes.checkout_url) {
|
||||
window.location.href = checkoutRes.checkout_url
|
||||
localStorage.setItem('pending_order_no', res.order_no)
|
||||
console.log('pending_order_no', res.order_no)
|
||||
setTimeout(() => {
|
||||
window.location.href = checkoutRes.checkout_url
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -184,7 +195,20 @@ function init() {
|
||||
payments.value = res.list?.filter((p: any) => p.platform !== 'apple_iap') || []
|
||||
})
|
||||
}
|
||||
init()
|
||||
|
||||
onMounted(() => {
|
||||
init()
|
||||
const orderNo = (route.query.order_no as string) || localStorage.getItem('pending_order_no')
|
||||
if (orderNo) {
|
||||
orderStatusDialogRef.value?.show(orderNo)
|
||||
}
|
||||
})
|
||||
|
||||
function handleStatusClose() {
|
||||
localStorage.removeItem('pending_order_no')
|
||||
// 清除 URL 中的 order_no,防止刷新再次弹出
|
||||
router.replace({ query: { ...route.query, order_no: undefined } })
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user