Commit 0f5a5a93 by 李伟康

feat(utils): 优化 Track 类以获取页面路径

- 在 Track 类中添加获取当前页面和前一页的逻辑
- 更新 prePagePath 和 pagePath 的赋值,使其更准确地反映页面路径
- 优化了页面路径的获取方式,提高了代码的健壮性
1 parent 105bfbe6
...@@ -15,14 +15,18 @@ class Track { ...@@ -15,14 +15,18 @@ class Track {
userType userType
} = uni.$storage.get('userInfo') || {}, } = uni.$storage.get('userInfo') || {},
trackList = uni.getStorageSync('TRACK_LIST') || [] trackList = uni.getStorageSync('TRACK_LIST') || []
let pages = getCurrentPages(),
currentPage = pages[pages.length - 1],
prePage = {}
if (pages.length > 1) prePage = pages[pages.length - 2]
let item = { let item = {
userType, userType,
loginAccount, loginAccount,
phoneNumber, phoneNumber,
uuid, uuid,
scene, scene,
prePagePath: '/', prePagePath: data.prePagePath || prePage.route || '/',
pagePath:data.pagePath|| '/', pagePath: data.pagePath || currentPage.route || '/',
eventTime: dayjs(Date.now()).format('YYYY-MM-DD HH:mm:ss'), eventTime: dayjs(Date.now()).format('YYYY-MM-DD HH:mm:ss'),
systemSource: 3, systemSource: 3,
eventType: data.eventType || 0 eventType: data.eventType || 0
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!