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
454ae70b
Commit
454ae70b
authored
Jan 18, 2022
by
Jenny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 全局数据
parent
4cfcbebd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
45 deletions
+75
-45
echartElementData.js
mixins/echartElementData.js
+14
-1
index.vue
pages/index/index.vue
+59
-42
index.js
store/index.js
+2
-2
No files found.
mixins/echartElementData.js
View file @
454ae70b
...
@@ -38,7 +38,13 @@ export default {
...
@@ -38,7 +38,13 @@ export default {
* 全局数据
* 全局数据
*/
*/
handlePublicData
(
value
)
{
handlePublicData
(
value
)
{
if
(
!
this
.
globalData
)
return
const
{
dataProcessing
}
=
{
...
value
}
if
(
dataProcessing
)
{
elementData
.
value
.
dataList
=
this
.
$u
.
common
.
converFunction
(
dataProcessing
,
JSON
.
parse
(
this
.
globalData
))
return
false
}
elementData
.
value
.
dataList
=
JSON
.
parse
(
this
.
globalData
)
},
},
/**
/**
* 配置数据 - 数据集
* 配置数据 - 数据集
...
@@ -101,6 +107,13 @@ export default {
...
@@ -101,6 +107,13 @@ export default {
},
},
immediate
:
true
,
immediate
:
true
,
deep
:
true
deep
:
true
},
/**
* 全局数据更新监测
*/
globalData
()
{
console
.
log
(
'----globalData----'
,
this
.
globalData
)
if
(
this
.
elementInfo
.
data
.
dataType
===
'public'
)
this
.
handlePublicData
(
this
.
elementInfo
.
data
)
}
}
}
}
}
}
pages/index/index.vue
View file @
454ae70b
...
@@ -37,7 +37,8 @@
...
@@ -37,7 +37,8 @@
data
()
{
data
()
{
return
{
return
{
reportInfo
:
{},
reportInfo
:
{},
reportData
:
[]
reportData
:
[],
timer
:
null
}
}
},
},
computed
:
{
computed
:
{
...
@@ -54,52 +55,68 @@
...
@@ -54,52 +55,68 @@
async
onLoad
()
{
async
onLoad
()
{
this
.
getReportList
()
this
.
getReportList
()
},
},
onShow
()
{
onShow
()
{
this
.
userAuthCheck
()
this
.
userAuthCheck
()
},
},
methods
:
{
methods
:
{
//检查是否登录
//检查是否登录
userAuthCheck
()
{
userAuthCheck
()
{
var
userId
=
uni
.
getStorageSync
(
'userId'
)
var
userId
=
uni
.
getStorageSync
(
'userId'
)
this
.
getNewestAuthFromServer
()
this
.
getNewestAuthFromServer
()
var
authorized
=
uni
.
getStorageSync
(
'authorized'
)
var
authorized
=
uni
.
getStorageSync
(
'authorized'
)
if
(
userId
)
{
if
(
userId
)
{
if
(
authorized
)
{
if
(
authorized
)
{
}
else
{
}
else
{
uni
.
reLaunch
({
uni
.
reLaunch
({
url
:
'../login/authorized'
url
:
'../login/authorized'
})
})
}
}
}
else
{
}
else
{
uni
.
reLaunch
({
uni
.
reLaunch
({
url
:
'../login/login'
url
:
'../login/login'
})
})
}
}
},
//获取最新的授权信息
},
getNewestAuthFromServer
()
{
var
param
=
{
//获取最新的授权信息
id
:
uni
.
getStorageSync
(
'userId'
)
getNewestAuthFromServer
()
{
}
var
param
=
{
this
.
$u
.
api
.
getAuthorized
(
param
).
then
(
res
=>
{
id
:
uni
.
getStorageSync
(
'userId'
)
const
{
Status
,
Result
}
=
res
.
data
}
if
(
Status
===
'true'
)
{
this
.
$u
.
api
.
getAuthorized
(
param
).
then
(
res
=>
{
uni
.
setStorageSync
(
'authorized'
,
Result
.
authorized
)
const
{
Status
,
Result
}
=
res
.
data
}
if
(
Status
===
'true'
)
{
})
uni
.
setStorageSync
(
'authorized'
,
Result
.
authorized
)
},
}
/**
})
* 获取页面报表配置
},
*/
async
getReportList
()
{
async
getReportList
()
{
clearInterval
(
this
.
timer
)
let
res
=
await
this
.
$u
.
api
.
getReportList
({
id
:
'61c424a4c06bff0ce05d9a53'
})
let
res
=
await
this
.
$u
.
api
.
getReportList
({
id
:
'61c424a4c06bff0ce05d9a53'
})
const
{
Status
,
Result
}
=
res
.
data
const
{
Status
,
Result
:
{
info
,
list
}
}
=
res
.
data
if
(
Status
===
'true'
)
{
if
(
Status
===
'true'
)
{
this
.
reportInfo
=
Result
.
info
this
.
reportInfo
=
info
this
.
reportData
=
Result
.
list
this
.
reportData
=
list
if
(
info
.
dataUrl
)
{
this
.
getGlobalData
(
info
)
if
(
info
.
dataPollingInterval
)
{
this
.
timer
=
setInterval
(()
=>
{
this
.
getGlobalData
(
info
)
},
parseInt
(
info
.
dataPollingInterval
)
*
1000
)
}
}
}
}
},
/**
* 获取全局接口数据
*/
async
getGlobalData
(
info
)
{
const
dataUrl
=
info
.
dataUrl
.
replace
(
/^
(\/
dashboardCharts
)?
|^
(\/
dashboardAPI
)?
/
,
''
)
let
res
=
await
this
.
$u
[
info
.
dataMethod
.
toLowerCase
()](
dataUrl
,
info
.
dataFormatter
)
this
.
$u
.
vuex
(
'globalData'
,
JSON
.
stringify
(
res
.
data
))
}
}
},
},
onReachBottom
()
{
onReachBottom
()
{
...
...
store/index.js
View file @
454ae70b
...
@@ -12,7 +12,7 @@ try {
...
@@ -12,7 +12,7 @@ try {
}
}
// 需要永久存储,且在下次 APP 启动需要取出的,在 state 中的变量名。
// 需要永久存储,且在下次 APP 启动需要取出的,在 state 中的变量名。
let
saveStateKeys
=
[
'vuex_
user'
,
'vuex_
token'
]
let
saveStateKeys
=
[
'vuex_token'
]
// 保存变量到本地存储中
// 保存变量到本地存储中
const
saveLifeData
=
function
(
key
,
value
)
{
const
saveLifeData
=
function
(
key
,
value
)
{
...
@@ -30,8 +30,8 @@ const saveLifeData = function(key, value) {
...
@@ -30,8 +30,8 @@ const saveLifeData = function(key, value) {
const
store
=
new
Vuex
.
Store
({
const
store
=
new
Vuex
.
Store
({
state
:
{
state
:
{
vuex_user
:
lifeData
.
vuex_user
||
{
name
:
'test'
},
vuex_token
:
lifeData
.
vuex_token
||
''
,
vuex_token
:
lifeData
.
vuex_token
||
''
,
globalData
:
""
},
},
mutations
:
{
mutations
:
{
$uStore
(
state
,
payload
)
{
$uStore
(
state
,
payload
)
{
...
...
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