功能:完善订单流程和加固
This commit is contained in:
@@ -47,6 +47,45 @@ function switchTab(path) {
|
||||
})
|
||||
}
|
||||
|
||||
function normalizeActionPath(value) {
|
||||
const rawPath = String(value || '').trim()
|
||||
if (!rawPath || !rawPath.startsWith('/') || rawPath.startsWith('//')) {
|
||||
return ''
|
||||
}
|
||||
|
||||
if (rawPath.startsWith('/orders')) {
|
||||
const queryIndex = rawPath.indexOf('?')
|
||||
const query = queryIndex >= 0 ? rawPath.slice(queryIndex) : ''
|
||||
return `/pages/orders/index${query}`
|
||||
}
|
||||
|
||||
if (rawPath.startsWith('/pages/')) {
|
||||
return rawPath
|
||||
}
|
||||
|
||||
return ''
|
||||
}
|
||||
|
||||
function openActionPath(value) {
|
||||
const target = normalizeActionPath(value)
|
||||
if (!target) {
|
||||
return Promise.resolve(false)
|
||||
}
|
||||
|
||||
const purePath = target.split('?')[0]
|
||||
const openPromise = isTabPage(purePath) ? switchTab(purePath) : navigate(target)
|
||||
return openPromise
|
||||
.then(() => true)
|
||||
.catch(error => {
|
||||
console.error('Open message action path failed', error)
|
||||
wx.showToast({
|
||||
title: '无法打开消息链接',
|
||||
icon: 'none'
|
||||
})
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
function goBack(fallbackPath) {
|
||||
const pages = getCurrentPages()
|
||||
if (pages.length > 1) {
|
||||
@@ -186,6 +225,8 @@ module.exports = {
|
||||
isTabPage,
|
||||
navigate,
|
||||
switchTab,
|
||||
normalizeActionPath,
|
||||
openActionPath,
|
||||
goBack,
|
||||
redirectAfterLogin,
|
||||
openAuth,
|
||||
|
||||
Reference in New Issue
Block a user