Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
51344a59
authored
Mar 27, 2023
by
zhangjinlong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Vue3重构:公众号统计
parent
1a431130
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
0 deletions
+79
-0
src/utils/dateUtils.ts
+79
-0
src/views/mp/statistics/index.vue
+0
-0
No files found.
src/utils/dateUtils.ts
0 → 100644
View file @
51344a59
/**
* 将毫秒,转换成时间字符串。例如说,xx 分钟
*
* @param ms 毫秒
* @returns {string} 字符串
*/
export
function
getDate
(
ms
)
{
const
day
=
Math
.
floor
(
ms
/
(
24
*
60
*
60
*
1000
))
const
hour
=
Math
.
floor
(
ms
/
(
60
*
60
*
1000
)
-
day
*
24
)
const
minute
=
Math
.
floor
(
ms
/
(
60
*
1000
)
-
day
*
24
*
60
-
hour
*
60
)
const
second
=
Math
.
floor
(
ms
/
1000
-
day
*
24
*
60
*
60
-
hour
*
60
*
60
-
minute
*
60
)
if
(
day
>
0
)
{
return
day
+
'天'
+
hour
+
'小时'
+
minute
+
'分钟'
}
if
(
hour
>
0
)
{
return
hour
+
'小时'
+
minute
+
'分钟'
}
if
(
minute
>
0
)
{
return
minute
+
'分钟'
}
if
(
second
>
0
)
{
return
second
+
'秒'
}
else
{
return
0
+
'秒'
}
}
export
function
beginOfDay
(
date
)
{
return
new
Date
(
date
.
getFullYear
(),
date
.
getMonth
(),
date
.
getDate
())
}
export
function
endOfDay
(
date
)
{
return
new
Date
(
date
.
getFullYear
(),
date
.
getMonth
(),
date
.
getDate
(),
23
,
59
,
59
,
999
)
}
export
function
betweenDay
(
date1
,
date2
)
{
date1
=
convertDate
(
date1
)
date2
=
convertDate
(
date2
)
// 计算差值
return
Math
.
floor
((
date2
.
getTime
()
-
date1
.
getTime
())
/
(
24
*
3600
*
1000
))
}
export
function
formatDate
(
date
,
fmt
)
{
date
=
convertDate
(
date
)
const
o
=
{
'M+'
:
date
.
getMonth
()
+
1
,
//月份
'd+'
:
date
.
getDate
(),
//日
'H+'
:
date
.
getHours
(),
//小时
'm+'
:
date
.
getMinutes
(),
//分
's+'
:
date
.
getSeconds
(),
//秒
'q+'
:
Math
.
floor
((
date
.
getMonth
()
+
3
)
/
3
),
//季度
S
:
date
.
getMilliseconds
()
//毫秒
}
if
(
/
(
y+
)
/
.
test
(
fmt
))
{
// 年份
fmt
=
fmt
.
replace
(
RegExp
.
$1
,
(
date
.
getFullYear
()
+
''
).
substr
(
4
-
RegExp
.
$1
.
length
))
}
for
(
const
k
in
o
)
{
if
(
new
RegExp
(
'('
+
k
+
')'
).
test
(
fmt
))
{
fmt
=
fmt
.
replace
(
RegExp
.
$1
,
RegExp
.
$1
.
length
===
1
?
o
[
k
]
:
(
'00'
+
o
[
k
]).
substr
((
''
+
o
[
k
]).
length
)
)
}
}
return
fmt
}
export
function
addTime
(
date
,
time
)
{
date
=
convertDate
(
date
)
return
new
Date
(
date
.
getTime
()
+
time
)
}
export
function
convertDate
(
date
)
{
if
(
typeof
date
===
'string'
)
{
return
new
Date
(
date
)
}
return
date
}
src/views/mp/statistics/index.vue
View file @
51344a59
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment