This commit is contained in:
Your Name
2026-03-16 15:08:28 +08:00
parent 294fee4d88
commit cda63b5ae2
26 changed files with 1695 additions and 492 deletions
+35
View File
@@ -116,12 +116,47 @@ function apiUrl(promise, Loading = true) {
})
}
/**
* 解析页面参数(支持普通参数和扫码 scene 参数)
* @param {Object} options - 页面 options,如 getCurrentPages()[].options
* @returns {Object} 解析后的参数对象
*/
function parsePageParams(options) {
const params = {}
if (!options) return params
// 如果有 scene 参数(扫码进入),解析 scene
if (options.scene) {
try {
const decodedScene = decodeURIComponent(options.scene)
decodedScene.split('&').forEach(item => {
const [key, value] = item.split('=')
if (key && value) {
params[key] = value
}
})
} catch (error) {
console.error('解析scene参数失败:', error)
}
}
// 合并普通参数(普通跳转进入)
Object.keys(options).forEach(key => {
if (key !== 'scene' && options[key]) {
params[key] = options[key]
}
})
return params
}
export function createApp() {
const app = createSSRApp(App)
// Vue3挂载全局属性的方式
app.config.globalProperties.$url = baseUrl
app.config.globalProperties.apiUrl = apiUrl
app.config.globalProperties.$parsePageParams = parsePageParams
return {
app