Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
m0_68066342
uni-app
提交
919c7d4d
U
uni-app
项目概览
m0_68066342
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
919c7d4d
编写于
8月 22, 2019
作者:
M
mehaotian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(stat) : 修复路由错误问题,
上级
7ccd61ee
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
119 addition
and
69 deletion
+119
-69
packages/uni-stat/dist/index.js
packages/uni-stat/dist/index.js
+54
-29
packages/uni-stat/package.json
packages/uni-stat/package.json
+1
-1
packages/uni-stat/src/parameter.js
packages/uni-stat/src/parameter.js
+5
-5
packages/uni-stat/src/stat.js
packages/uni-stat/src/stat.js
+59
-34
未找到文件。
packages/uni-stat/dist/index.js
浏览文件 @
919c7d4d
...
...
@@ -237,7 +237,7 @@ const getRoute = () => {
if
(
getPlatformName
()
===
'
bd
'
)
{
return
_self
.
$mp
&&
_self
.
$mp
.
page
.
is
;
}
else
{
return
_self
.
$scope
&&
_self
.
$scope
.
route
||
_self
.
$mp
&&
_self
.
$mp
.
page
.
route
;
return
(
_self
.
$scope
&&
_self
.
$scope
.
route
)
||
(
_self
.
$mp
&&
_self
.
$mp
.
page
.
route
)
;
}
};
...
...
@@ -252,14 +252,14 @@ const getPageRoute = (self) => {
if
(
getPlatformName
()
===
'
bd
'
)
{
return
_self
.
$mp
&&
_self
.
$mp
.
page
.
is
+
str
;
}
else
{
return
_self
.
$scope
&&
_self
.
$scope
.
route
+
str
||
_self
.
$mp
&&
_self
.
$mp
.
page
.
route
+
str
;
return
(
_self
.
$scope
&&
_self
.
$scope
.
route
+
str
)
||
(
_self
.
$mp
&&
_self
.
$mp
.
page
.
route
+
str
)
;
}
};
const
getPageTypes
=
(
self
)
=>
{
if
(
self
.
mpType
===
'
page
'
||
self
.
$mp
&&
self
.
$mp
.
mpType
===
'
page
'
)
{
return
true
;
}
if
(
self
.
mpType
===
'
page
'
||
(
self
.
$mp
&&
self
.
$mp
.
mpType
===
'
page
'
)
||
self
.
$options
.
mpType
===
'
page
'
)
{
return
true
;
}
return
false
;
};
...
...
@@ -371,8 +371,9 @@ class Util {
getLastTime
();
const
time
=
getResidenceTime
();
getFirstTime
();
const
route
=
getPageRoute
(
this
);
this
.
_sendHideRequest
({
urlref
:
this
.
_lastPageR
oute
,
urlref
:
r
oute
,
urlref_ts
:
time
.
residenceTime
},
type
);
}
...
...
@@ -562,20 +563,32 @@ class Util {
data
.
ttc
=
title
.
report
;
let
requestData
=
this
.
_reportingRequestData
;
if
(
getPlatformName
()
===
'
n
'
)
{
requestData
=
uni
.
getStorageSync
(
'
__UNI__STAT__DATA
'
)
||
{};
}
if
(
!
requestData
[
data
.
lt
])
{
this
.
_reportingRequestData
[
data
.
lt
]
=
[];
requestData
[
data
.
lt
]
=
[];
}
requestData
[
data
.
lt
].
push
(
data
);
if
(
getPlatformName
()
===
'
n
'
)
{
uni
.
setStorageSync
(
'
__UNI__STAT__DATA
'
,
requestData
);
}
this
.
_reportingRequestData
[
data
.
lt
].
push
(
data
);
if
(
getPageResidenceTime
()
<
OPERATING_TIME
&&
!
type
)
{
return
}
let
uniStatData
=
this
.
_reportingRequestData
;
if
(
getPlatformName
()
===
'
n
'
)
{
uniStatData
=
uni
.
getStorageSync
(
'
__UNI__STAT__DATA
'
);
}
// 时间超过,重新获取时间戳
setPageResidenceTime
();
let
firstArr
=
[];
let
contentArr
=
[];
let
lastArr
=
[];
for
(
let
i
in
this
.
_reportingRequestData
)
{
const
rd
=
this
.
_reportingRequestData
[
i
];
for
(
let
i
in
uniStatData
)
{
const
rd
=
uniStatData
[
i
];
rd
.
forEach
((
elm
)
=>
{
const
newData
=
getSplicing
(
elm
);
if
(
i
===
0
)
{
...
...
@@ -594,32 +607,40 @@ class Util {
t
:
time
,
//发送请求时的时间戮
requests
:
JSON
.
stringify
(
firstArr
),
};
this
.
_reportingRequestData
=
{};
if
(
getPlatformName
()
===
'
n
'
)
{
uni
.
removeStorageSync
(
'
__UNI__STAT__DATA
'
);
}
if
(
data
.
ut
===
'
h5
'
)
{
this
.
imageRequest
(
optionsData
);
return
}
uni
.
request
({
url
:
STAT_URL
,
method
:
'
POST
'
,
data
:
optionsData
,
success
:
()
=>
{
if
(
process
.
env
.
NODE_ENV
===
'
development
'
)
{
console
.
log
(
'
stat request success
'
);
}
},
fail
:
(
e
)
=>
{
if
(
process
.
env
.
NODE_ENV
===
'
development
'
)
{
console
.
log
(
'
stat request fail
'
,
e
);
}
if
(
++
this
.
_retry
<
3
)
{
setTimeout
(()
=>
{
this
.
request
(
data
);
},
1000
);
setTimeout
(()
=>
{
uni
.
request
({
url
:
STAT_URL
,
method
:
'
POST
'
,
data
:
optionsData
,
success
:
()
=>
{
if
(
process
.
env
.
NODE_ENV
===
'
development
'
)
{
console
.
log
(
'
stat request success
'
);
}
},
fail
:
(
e
)
=>
{
if
(
process
.
env
.
NODE_ENV
===
'
development
'
)
{
console
.
log
(
'
stat request fail
'
,
e
);
}
if
(
++
this
.
_retry
<
3
)
{
setTimeout
(()
=>
{
this
.
request
(
data
);
},
1000
);
}
}
}
});
});
},
200
);
}
/**
* h5 请求
...
...
@@ -722,6 +743,10 @@ class Stat extends Util {
}
load
(
options
,
self
)
{
if
(
!
self
.
$scope
&&
!
self
.
$mp
)
{
const
page
=
getCurrentPages
();
self
.
$scope
=
page
[
page
.
length
-
1
];
}
this
.
self
=
self
;
this
.
_query
=
options
;
}
...
...
packages/uni-stat/package.json
浏览文件 @
919c7d4d
{
"name"
:
"@dcloudio/uni-stat"
,
"version"
:
"0.0.1
08
"
,
"version"
:
"0.0.1
11
"
,
"description"
:
""
,
"main"
:
"dist/index.js"
,
"scripts"
:
{
...
...
packages/uni-stat/src/parameter.js
浏览文件 @
919c7d4d
...
...
@@ -236,7 +236,7 @@ export const getRoute = () => {
if
(
getPlatformName
()
===
'
bd
'
)
{
return
_self
.
$mp
&&
_self
.
$mp
.
page
.
is
;
}
else
{
return
_self
.
$scope
&&
_self
.
$scope
.
route
||
_self
.
$mp
&&
_self
.
$mp
.
page
.
route
;
return
(
_self
.
$scope
&&
_self
.
$scope
.
route
)
||
(
_self
.
$mp
&&
_self
.
$mp
.
page
.
route
)
;
}
};
...
...
@@ -251,14 +251,14 @@ export const getPageRoute = (self) => {
if
(
getPlatformName
()
===
'
bd
'
)
{
return
_self
.
$mp
&&
_self
.
$mp
.
page
.
is
+
str
;
}
else
{
return
_self
.
$scope
&&
_self
.
$scope
.
route
+
str
||
_self
.
$mp
&&
_self
.
$mp
.
page
.
route
+
str
;
return
(
_self
.
$scope
&&
_self
.
$scope
.
route
+
str
)
||
(
_self
.
$mp
&&
_self
.
$mp
.
page
.
route
+
str
)
;
}
};
export
const
getPageTypes
=
(
self
)
=>
{
if
(
self
.
mpType
===
'
page
'
||
self
.
$mp
&&
self
.
$mp
.
mpType
===
'
page
'
)
{
return
true
;
}
if
(
self
.
mpType
===
'
page
'
||
(
self
.
$mp
&&
self
.
$mp
.
mpType
===
'
page
'
)
||
self
.
$options
.
mpType
===
'
page
'
)
{
return
true
;
}
return
false
;
}
...
...
packages/uni-stat/src/stat.js
浏览文件 @
919c7d4d
...
...
@@ -106,8 +106,9 @@ class Util {
getLastTime
();
const
time
=
getResidenceTime
();
getFirstTime
();
const
route
=
getPageRoute
(
this
);
this
.
_sendHideRequest
({
urlref
:
this
.
_lastPageR
oute
,
urlref
:
r
oute
,
urlref_ts
:
time
.
residenceTime
},
type
)
}
...
...
@@ -297,64 +298,84 @@ class Util {
data
.
ttc
=
title
.
report
;
let
requestData
=
this
.
_reportingRequestData
;
if
(
getPlatformName
()
===
'
n
'
)
{
requestData
=
uni
.
getStorageSync
(
'
__UNI__STAT__DATA
'
)
||
{}
}
if
(
!
requestData
[
data
.
lt
])
{
this
.
_reportingRequestData
[
data
.
lt
]
=
[];
requestData
[
data
.
lt
]
=
[];
}
requestData
[
data
.
lt
].
push
(
data
);
if
(
getPlatformName
()
===
'
n
'
)
{
uni
.
setStorageSync
(
'
__UNI__STAT__DATA
'
,
requestData
)
}
this
.
_reportingRequestData
[
data
.
lt
].
push
(
data
);
if
(
getPageResidenceTime
()
<
OPERATING_TIME
&&
!
type
)
{
return
}
let
uniStatData
=
this
.
_reportingRequestData
if
(
getPlatformName
()
===
'
n
'
)
{
uniStatData
=
uni
.
getStorageSync
(
'
__UNI__STAT__DATA
'
)
}
// 时间超过,重新获取时间戳
setPageResidenceTime
();
let
firstArr
=
[]
let
contentArr
=
[]
let
lastArr
=
[]
for
(
let
i
in
this
.
_reportingRequestData
)
{
const
rd
=
this
.
_reportingRequestData
[
i
]
let
firstArr
=
[];
let
contentArr
=
[];
let
lastArr
=
[];
for
(
let
i
in
uniStatData
)
{
const
rd
=
uniStatData
[
i
];
rd
.
forEach
((
elm
)
=>
{
const
newData
=
getSplicing
(
elm
)
const
newData
=
getSplicing
(
elm
)
;
if
(
i
===
0
)
{
firstArr
.
push
(
newData
)
firstArr
.
push
(
newData
)
;
}
else
if
(
i
===
3
)
{
lastArr
.
push
(
newData
)
lastArr
.
push
(
newData
)
;
}
else
{
contentArr
.
push
(
newData
)
contentArr
.
push
(
newData
)
;
}
})
})
;
}
firstArr
.
push
(...
contentArr
,
...
lastArr
)
firstArr
.
push
(...
contentArr
,
...
lastArr
)
;
let
optionsData
=
{
usv
:
STAT_VERSION
,
//统计 SDK 版本号
t
:
time
,
//发送请求时的时间戮
requests
:
JSON
.
stringify
(
firstArr
),
};
this
.
_reportingRequestData
=
{};
if
(
getPlatformName
()
===
'
n
'
)
{
uni
.
removeStorageSync
(
'
__UNI__STAT__DATA
'
)
}
this
.
_reportingRequestData
=
{}
if
(
data
.
ut
===
'
h5
'
)
{
this
.
imageRequest
(
optionsData
)
return
}
uni
.
request
({
url
:
STAT_URL
,
method
:
'
POST
'
,
data
:
optionsData
,
success
:
()
=>
{
if
(
process
.
env
.
NODE_ENV
===
'
development
'
)
{
console
.
log
(
'
stat request success
'
);
}
},
fail
:
(
e
)
=>
{
if
(
process
.
env
.
NODE_ENV
===
'
development
'
)
{
console
.
log
(
'
stat request fail
'
,
e
);
}
if
(
++
this
.
_retry
<
3
)
{
setTimeout
(()
=>
{
this
.
request
(
data
);
},
1000
);
setTimeout
(()
=>
{
uni
.
request
({
url
:
STAT_URL
,
method
:
'
POST
'
,
data
:
optionsData
,
success
:
()
=>
{
if
(
process
.
env
.
NODE_ENV
===
'
development
'
)
{
console
.
log
(
'
stat request success
'
);
}
},
fail
:
(
e
)
=>
{
if
(
process
.
env
.
NODE_ENV
===
'
development
'
)
{
console
.
log
(
'
stat request fail
'
,
e
);
}
if
(
++
this
.
_retry
<
3
)
{
setTimeout
(()
=>
{
this
.
request
(
data
);
},
1000
);
}
}
}
});
});
},
200
)
}
/**
* h5 请求
...
...
@@ -457,6 +478,10 @@ class Stat extends Util {
}
load
(
options
,
self
)
{
if
(
!
self
.
$scope
&&
!
self
.
$mp
)
{
const
page
=
getCurrentPages
()
self
.
$scope
=
page
[
page
.
length
-
1
]
}
this
.
self
=
self
;
this
.
_query
=
options
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录