Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
E
ec-report-refactor
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lihuizhen
ec-report-refactor
Commits
748428f6
Commit
748428f6
authored
Mar 03, 2022
by
leon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: horizontal bar cache images
parent
599bc27b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
13 deletions
+49
-13
App.vue
App.vue
+1
-0
DashboardProgress.vue
components/DashboardProgress/DashboardProgress.vue
+8
-4
HorizontalBar.vue
components/HorizontalBar/HorizontalBar.vue
+40
-9
No files found.
App.vue
View file @
748428f6
<
script
>
<
script
>
export
default
{
export
default
{
onLaunch
:
function
()
{
onLaunch
:
function
()
{
uni
.
removeStorageSync
(
'cacheImages'
)
console
.
log
(
'App Launch'
)
console
.
log
(
'App Launch'
)
},
},
onShow
:
function
()
{
onShow
:
function
()
{
...
...
components/DashboardProgress/DashboardProgress.vue
View file @
748428f6
...
@@ -132,11 +132,15 @@
...
@@ -132,11 +132,15 @@
},
},
initChart
()
{
initChart
()
{
let
{
endVal
}
=
this
.
elementData
.
dataList
let
{
endVal
}
=
this
.
elementData
.
dataList
if
(
this
.
ec
.
option
.
title
)
{
this
.
ec
.
option
.
title
[
0
].
text
=
`
${
endVal
}
%`
this
.
ec
.
option
.
title
[
0
].
text
=
`
${
endVal
}
%`
}
if
(
this
.
ec
.
option
.
series
)
{
this
.
ec
.
option
.
series
[
0
].
axisLine
.
lineStyle
.
color
[
0
][
0
]
=
endVal
/
100
this
.
ec
.
option
.
series
[
0
].
axisLine
.
lineStyle
.
color
[
0
][
0
]
=
endVal
/
100
}
}
}
}
}
}
}
</
script
>
</
script
>
<
style
>
<
style
>
...
...
components/HorizontalBar/HorizontalBar.vue
View file @
748428f6
...
@@ -50,17 +50,21 @@
...
@@ -50,17 +50,21 @@
}
}
chart
.
setOption
(
this
.
ec
.
option
)
chart
.
setOption
(
this
.
ec
.
option
)
chart
.
on
(
'click'
,
event
=>
{
chart
.
on
(
'click'
,
event
=>
{
const
{
const
{
preview
,
images
}
=
this
.
elementData
.
dataList
dataList
:
{
var
urls
=
[]
preview
,
var
caches
=
uni
.
getStorageSync
(
'cacheImages'
)
images
images
.
forEach
(
url
=>
{
if
(
caches
.
hasOwnProperty
(
url
))
{
urls
.
push
(
caches
[
url
])
}
else
{
urls
.
push
(
url
)
}
}
}
=
this
.
elementData
}
)
// 特殊处理,如果preview为true,代表点击显示图片
// 特殊处理,如果preview为true,代表点击显示图片
if
(
preview
)
{
if
(
preview
)
{
uni
.
previewImage
({
uni
.
previewImage
({
current
:
event
.
dataIndex
,
current
:
event
.
dataIndex
,
urls
:
image
s
urls
:
url
s
})
})
}
else
{
}
else
{
this
.
handleEchartsClick
(
event
)
this
.
handleEchartsClick
(
event
)
...
@@ -69,9 +73,12 @@
...
@@ -69,9 +73,12 @@
return
chart
return
chart
},
},
initChart
()
{
initChart
()
{
const
{
categories
,
series
}
=
this
.
elementData
.
dataList
const
{
categories
,
series
,
preview
,
images
}
=
this
.
elementData
.
dataList
this
.
$set
(
this
.
ec
.
option
,
'yAxis.data'
,
categories
)
this
.
$set
(
this
.
ec
.
option
,
'yAxis.data'
,
categories
)
this
.
$set
(
this
.
ec
.
option
,
'series'
,
this
.
dealSeriesData
(
series
))
this
.
$set
(
this
.
ec
.
option
,
'series'
,
this
.
dealSeriesData
(
series
))
if
(
preview
)
{
this
.
cacheImages
(
images
)
}
},
},
/**
/**
* 处理数据
* 处理数据
...
@@ -97,7 +104,31 @@
...
@@ -97,7 +104,31 @@
}
}
})
})
return
newData
return
newData
},
/**
* 缓存图片数据
*/
cacheImages
(
images
)
{
var
caches
=
uni
.
getStorageSync
(
'cacheImages'
)
if
(
!
caches
)
{
caches
=
{}
}
images
.
forEach
(
url
=>
{
// 如果包含当前url,就不再下载
if
(
!
caches
.
hasOwnProperty
(
url
))
{
uni
.
downloadFile
({
url
:
url
,
success
:
(
res
)
=>
{
if
(
res
.
statusCode
===
200
)
{
caches
[
url
]
=
res
.
tempFilePath
uni
.
setStorageSync
(
'cacheImages'
,
caches
)
}
}
})
}
})
}
}
}
}
}
}
</
script
>
</
script
>
...
...
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