Files
QSY-lvjuxcx/utils/booking-entry.js
liangjian 9fee2c3a74 feat: 优化首页服务入口与租住业务流程
补齐首页待办跳转、押金支付引导和多类租住服务页面能力,统一租客端关键业务流程体验。
2026-08-25 13:53:12 +08:00

33 lines
913 B
JavaScript

function normalizeUrl(url = '') {
return String(url || '').trim()
}
export function isBookingEntryUrl(url = '') {
return /^\/pkgBooking\/(book_viewing\/book_viewing|book\/book)(?:\?|$)/.test(normalizeUrl(url))
}
export function resolveExistingBookingNavigationTarget(stayState = {}) {
const source = stayState || {}
const currentBooking = source.currentBooking || null
const hasCheckedIn = source.hasCheckedIn === true
if (currentBooking) {
return '/pages/index/index?pageId=stay-service'
}
if (hasCheckedIn) {
return '/pages/index/index?pageId=stay-service'
}
return ''
}
export function resolveBookingRedirectAfterLogin(targetUrl = '', stayState = {}) {
const normalizedTargetUrl = normalizeUrl(targetUrl)
if (!isBookingEntryUrl(normalizedTargetUrl)) {
return normalizedTargetUrl
}
return resolveExistingBookingNavigationTarget(stayState) || normalizedTargetUrl
}