|
@@ -20,7 +20,6 @@ const getUrlParams = (appPath) => {
|
|
|
let params = {}
|
|
|
for (let i = 0; i < query.length; i++) {
|
|
|
let q = query[i].split('=')
|
|
|
- console.log(q, 'q')
|
|
|
if (q.length === 2) {
|
|
|
params[q[0]] = q[1]
|
|
|
}
|
|
@@ -32,7 +31,11 @@ const isInclude = (url) => {
|
|
|
if (!url) return false
|
|
|
return includeList.some(item => url.indexOf(item.url) > -1)
|
|
|
}
|
|
|
-
|
|
|
+// 校验返回页面类型
|
|
|
+const isIncludeType = (url) => {
|
|
|
+ if (!url) return false
|
|
|
+ return includeList.find(item => url === item.url)
|
|
|
+}
|
|
|
// 参数
|
|
|
const userSync = uni.getStorageSync('userInfo')
|
|
|
const defaultParams = {
|
|
@@ -47,10 +50,10 @@ const defaultParams = {
|
|
|
const userRecordStatistics = (params) => {
|
|
|
UserApi.userRecordStatistics(params)
|
|
|
.then(response => {
|
|
|
- console.log('<=上送用户行为记录成功=>',response.msg)
|
|
|
+ console.log('◆◇◆◇上送用户行为记录成功◇◆◇◆')
|
|
|
})
|
|
|
.catch(error => {
|
|
|
- console.log('<=上送用户行为记录异常=>',error.msg)
|
|
|
+ console.log('◇◆◇◆上送用户行为记录异常◇◆◇◆')
|
|
|
return
|
|
|
})
|
|
|
}
|
|
@@ -58,7 +61,7 @@ const userRecordStatistics = (params) => {
|
|
|
// 跳过路由白名单拦截
|
|
|
guard.beforeEach((to, from, next) => {
|
|
|
console.log('\n')
|
|
|
- console.log('============')
|
|
|
+ console.log('◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆')
|
|
|
console.log('guard.beforeEach')
|
|
|
console.log('to:', to)
|
|
|
console.log('from:', from)
|
|
@@ -67,27 +70,28 @@ guard.beforeEach((to, from, next) => {
|
|
|
// bucketStack.push(to.url)
|
|
|
// console.log('入栈:', to.url)
|
|
|
// }
|
|
|
-
|
|
|
if (isInclude(to.url)) {
|
|
|
console.log('stay time started')
|
|
|
- map.set(to.url.split('?')[0], Date.now())
|
|
|
defaultParams.pagePath = to.url
|
|
|
- console.log('pagePath', defaultParams.pagePath)
|
|
|
- const urlParams = getUrlParams(to.url)
|
|
|
- if(urlParams){
|
|
|
- defaultParams.productId = urlParams ? urlParams.id : 0
|
|
|
- console.log('defaultParams', defaultParams)
|
|
|
+ if (to.url.indexOf('?') != -1) {
|
|
|
+ map.set(to.url.split('?')[0], Date.now())
|
|
|
+ const urlParams = getUrlParams(to.url)
|
|
|
+ if (urlParams) {
|
|
|
+ defaultParams.productId = urlParams ? urlParams.id : 0
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ map.set(to.url, Date.now())
|
|
|
}
|
|
|
}
|
|
|
// map.set(to.url.split('?')[0], Date.now())
|
|
|
- console.log('============')
|
|
|
+ console.log('◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆')
|
|
|
console.log('\n')
|
|
|
next()
|
|
|
})
|
|
|
|
|
|
guard.afterEach((to, from) => {
|
|
|
console.log('\n')
|
|
|
- console.log('============')
|
|
|
+ console.log('◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆')
|
|
|
console.log('guard.afterEach')
|
|
|
console.log('to:', to)
|
|
|
console.log('from:', from)
|
|
@@ -100,15 +104,16 @@ guard.afterEach((to, from) => {
|
|
|
// }
|
|
|
// console.log('未关闭页面栈列表:', bucketStack)
|
|
|
// }
|
|
|
-
|
|
|
if (map.has(from.url)) {
|
|
|
const beginTime = map.get(from.url)
|
|
|
+ defaultParams.pageType = isIncludeType(from.url).pageType
|
|
|
defaultParams.accessDuration = Date.now() - beginTime
|
|
|
- console.log('页面停留时间:', (Date.now() - beginTime), '秒')
|
|
|
+ defaultParams.pageLabel = uni.getStorageSync('pageLabel')
|
|
|
+ console.log('页面停留时间:', (Date.now() - beginTime), '毫秒')
|
|
|
// api
|
|
|
console.log('api is action ...')
|
|
|
userRecordStatistics(defaultParams)
|
|
|
}
|
|
|
- console.log('============')
|
|
|
+ console.log('◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆')
|
|
|
console.log('\n')
|
|
|
})
|