Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
shenmuApp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
zhanglw
shenmuApp
Commits
fc5d9169
Commit
fc5d9169
authored
Nov 03, 2023
by
zhanglw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
请求方法封装 公共方法处理 请求提示共同方法抽取
parent
192a8edf
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
466 additions
and
225 deletions
+466
-225
api.js
shenmu/common/api.js
+58
-0
msgTip.js
shenmu/common/msgTip.js
+53
-0
util.js
shenmu/common/util.js
+28
-1
main.js
shenmu/main.js
+8
-0
manifest.json
shenmu/manifest.json
+3
-0
login.vue
shenmu/pages/login.vue
+69
-37
logAlarm.vue
shenmu/pages/tabBar/monitor/logAlarm.vue
+36
-23
logData.vue
shenmu/pages/tabBar/monitor/logData.vue
+73
-43
realAlarm.vue
shenmu/pages/tabBar/monitor/realAlarm.vue
+86
-91
realData.vue
shenmu/pages/tabBar/monitor/realData.vue
+41
-25
userCenter.vue
shenmu/pages/tabBar/monitor/userCenter.vue
+11
-5
No files found.
shenmu/common/api.js
0 → 100644
View file @
fc5d9169
import
Vue
from
'
vue
'
import
{
resErrorDeal
}
from
'
./util.js
'
import
msgTip
from
"
./msgTip.js
"
const
BASEURL
=
'
http://192.168.3.23:8086
'
// 研发环境url
console
.
log
(
resErrorDeal
)
export
default
{
/**
* 封装请求(async await 封装uni.request)
*/
async
call
(
paramObj
)
{
let
resultObj
=
false
,
cb
=
paramObj
.
cb
;
const
header
=
{
'
Accept
'
:
'
application/json, text/plain, */*
'
,
'
Authorization
'
:
'
Bearer
'
+
JSON
.
parse
(
uni
.
getStorageSync
(
'
userInfo
'
)).
token
}
let
opt
=
{
url
:
BASEURL
+
paramObj
.
url
,
// 域名+接口地址
data
:
paramObj
.
data
,
method
:
paramObj
.
method
||
'
GET
'
,
loadFlag
:
paramObj
.
loadFlag
===
"
N
"
?
false
:
true
,
// 默认带有加载条
timeout
:
paramObj
.
timeout
||
1200000
,
// 默认登录超时时间20min
sslVerify
:
false
,
header
}
if
(
opt
.
loadFlag
)
{
// 请求是加载进度条
msgTip
.
showLoading
()
}
console
.
log
(
'
请求信息
'
,
JSON
.
stringify
(
opt
))
let
[
error
,
response
]
=
await
uni
.
request
(
opt
);
if
(
response
===
undefined
){
msgTip
.
toast
(
'
网络错误
'
)
msgTip
.
showLoading
(
false
)
return
}
if
(
!
response
.
data
){
msgTip
.
toast
(
'
网络错误
'
)
msgTip
.
showLoading
(
false
)
return
}
const
resData
=
response
.
data
if
(
resData
.
code
===
200
){
cb
&&
cb
(
resData
)
// 自定义处理回调函数
if
(
paramObj
.
showSuccessTip
){
// 成功调用接口时,默认不显示提醒信息
msgTip
.
toast
(
resData
.
message
)
}
}
else
{
resErrorDeal
(
response
)
}
uni
.
hideLoading
()
console
.
log
(
'
登录响应信息
'
,
response
)
},
}
\ No newline at end of file
shenmu/common/msgTip.js
0 → 100644
View file @
fc5d9169
/**
* 确认提示框
*/
const
confirmModal
=
(
config
)
=>
{
uni
.
showModal
({
title
:
config
.
title
||
'
信息提示
'
,
content
:
config
.
content
||
'
确认要继续该操作吗
'
,
showCancel
:
config
.
showCancel
!==
'
NO
'
,
confirmText
:
config
.
confirmText
||
'
确定
'
,
cancelText
:
config
.
cancelText
||
'
取消
'
,
success
:
(
res
)
=>
{
console
.
log
(
'
***confirmmodasl**
'
,
res
)
if
(
res
.
confirm
)
{
config
.
cb
&&
config
.
cb
(
true
)
}
else
if
(
res
.
cancel
)
{
config
.
cb
&&
config
.
cb
(
false
)
}
}
});
}
/**
* 显示提示框
*/
const
toast
=
(
title
,
icon
=
'
none
'
,
duration
=
2800
)
=>
{
setTimeout
(()
=>
{
uni
.
showToast
({
title
,
icon
,
duration
//显示时间
});
},
0
)
}
const
showLoading
=
(
showFlag
=
true
)
=>
{
if
(
showFlag
){
uni
.
showLoading
({
title
:
'
正在加载中...
'
,
mask
:
true
});
}
else
{
uni
.
hideLoading
()
}
}
const
hideKeyboard
=
()
=>
{
uni
.
hideKeyboard
()
}
export
default
{
confirmModal
,
toast
,
showLoading
,
hideKeyboard
}
\ No newline at end of file
shenmu/common/util.js
View file @
fc5d9169
import
msgTip
from
"
./msgTip.js
"
function
formatTime
(
time
)
{
if
(
typeof
time
!==
'
number
'
||
time
<
0
)
{
return
time
...
...
@@ -66,8 +67,34 @@ var dateUtils = {
}
};
const
resErrorDeal
=
(
response
)
=>
{
const
res
=
response
.
data
if
(
!
res
){
return
}
if
(
res
.
code
===
401
){
msgTip
.
confirmModal
({
content
:
'
系统登录超时,请重新登录
'
,
showCancel
:
'
NO
'
,
cb
:
(
res
)
=>
{
if
(
res
)
{
uni
.
reLaunch
({
url
:
'
/pages/login
'
});
}
}
});
}
else
{
msgTip
.
confirmModal
({
content
:
res
.
message
,
showCancel
:
'
NO
'
})
}
}
export
{
formatTime
,
formatLocation
,
dateUtils
dateUtils
,
resErrorDeal
}
shenmu/main.js
View file @
fc5d9169
import
App
from
'
./App
'
import
store
from
'
./store
'
import
util
from
'
./common/util.js
'
import
API
from
'
@/common/api.js
'
import
msgTip
from
"
@/common/msgTip.js
"
// #ifndef VUE3
import
Vue
from
'
vue
'
...
...
@@ -7,6 +10,11 @@ import Vue from 'vue'
// const BASEURL = 'http://117.34.103.191:8086' // 生产环境url
const
BASEURL
=
'
http://192.168.3.23:8086
'
// 研发环境url
Vue
.
prototype
.
$BASEURL
=
BASEURL
Vue
.
prototype
.
$UTIL
=
util
Vue
.
prototype
.
$API
=
API
Vue
.
prototype
.
$TIP
=
msgTip
Vue
.
config
.
productionTip
=
false
Vue
.
prototype
.
$store
=
store
...
...
shenmu/manifest.json
View file @
fc5d9169
...
...
@@ -26,6 +26,9 @@
"Speech"
:
{},
"VideoPlayer"
:
{}
},
"compatible"
:
{
"ignoreVersion"
:
true
//
true
表示忽略版本检查提示框,HBuilderX
1.9
.
0
及以上版本支持
},
/*
应用发布信息
*/
"distribute"
:
{
/*
android打包配置
*/
...
...
shenmu/pages/login.vue
View file @
fc5d9169
...
...
@@ -37,16 +37,12 @@
}
},
methods
:
{
onLogin
()
{
uni
.
request
({
url
:
this
.
baseUrl
+
'
/auth/login
'
,
method
:
"
POST
"
,
header
:
{
'
Accept
'
:
'
application/json, text/plain, */*
'
},
async
onLogin
()
{
const
res
=
await
this
.
$API
.
call
({
url
:
'
/auth/login2
'
,
data
:
this
.
form
,
}).
then
(
result
=>
{
let
[
error
,
res
]
=
result
method
:
'
POST
'
,
cb
:
(
res
)
=>
{
if
(
res
.
data
&&
res
.
data
.
token
)
{
this
.
userInfo
=
res
.
data
uni
.
setStorageSync
(
'
userInfo
'
,
JSON
.
stringify
(
res
.
data
))
...
...
@@ -55,7 +51,26 @@
})
this
.
getProList
()
}
}
})
// uni.request({
// url: this.baseUrl + '/auth/login',
// method: "POST",
// header: {
// 'Accept':'application/json, text/plain, */*'
// },
// data: this.form,
// }).then(result => {
// let [error, res] = result
// if (res.data && res.data.token) {
// this.userInfo = res.data
// uni.setStorageSync('userInfo', JSON.stringify(res.data))
// uni.showToast({
// title: '登录成功'
// })
// this.getProList()
// }
// })
},
goToPage
()
{
// 跳转页面
...
...
@@ -66,18 +81,12 @@
}
})
},
getProList
()
{
uni
.
request
({
url
:
this
.
baseUrl
+
'
/api/static
'
,
method
:
"
get
"
,
header
:
{
'
Accept
'
:
'
application/json, text/plain, */*
'
,
'
Authorization
'
:
'
Bearer
'
+
this
.
userInfo
.
token
}
}).
then
(
result
=>
{
let
[
error
,
res
]
=
result
if
(
res
.
data
&&
res
.
data
.
code
==
200
)
{
let
list
=
res
.
data
.
data
.
proListInfo
||
[]
async
getProList
()
{
const
res
=
await
this
.
$API
.
call
({
url
:
'
/api/static
'
,
cb
:
(
res
)
=>
{
if
(
res
.
data
)
{
let
list
=
res
.
data
.
proListInfo
||
[]
this
.
proList
=
list
.
map
(
item
=>
{
return
{
value
:
item
.
proId
,
...
...
@@ -88,7 +97,30 @@
uni
.
setStorageSync
(
'
currProInfo
'
,
JSON
.
stringify
(
this
.
proList
[
0
]
||
{}))
this
.
goToPage
()
}
}
})
// uni.request({
// url: this.baseUrl + '/api/static',
// method: "get",
// header: {
// 'Accept':'application/json, text/plain, */*',
// 'Authorization':'Bearer '+this.userInfo.token
// }
// }).then(result => {
// let [error, res] = result
// if (res.data && res.data.code==200) {
// let list = res.data.data.proListInfo||[]
// this.proList = list.map(item=>{
// return {
// value: item.proId,
// text: item.proName
// }
// })
// uni.setStorageSync('proList', JSON.stringify(this.proList||[]))
// uni.setStorageSync('currProInfo', JSON.stringify(this.proList[0]||{}))
// this.goToPage()
// }
// })
}
}
}
...
...
shenmu/pages/tabBar/monitor/logAlarm.
n
vue
→
shenmu/pages/tabBar/monitor/logAlarm.vue
View file @
fc5d9169
...
...
@@ -25,9 +25,9 @@
export
default
{
data
()
{
return
{
baseUrl: "http://192.168.3.23:8086",
userInfo: {},
currProInfo: {},
//
baseUrl: "http://192.168.3.23:8086",
//
userInfo: {},
//
currProInfo: {},
iconList
:
[
online
,
offline
,
wendu
],
query
:
{
name
:
''
...
...
@@ -77,9 +77,9 @@
} */
]
}
},
onReady() {
this.loadData()
},
//
onReady() {
//
this.loadData()
//
},
onShow
()
{
this
.
loadData
()
},
...
...
@@ -89,31 +89,44 @@
},
methods
:
{
loadData
()
{
this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
this.
currProInfo = JSON.parse(uni.getStorageSync('currProInfo'))
//
this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
const
currProInfo
=
JSON
.
parse
(
uni
.
getStorageSync
(
'
currProInfo
'
))
uni
.
setNavigationBarTitle
({
title: `历史报警-${
this.
currProInfo.text}`
title
:
`历史报警-
${
currProInfo
.
text
}
`
});
uni.request({
url: `${this.$BASEURL}/api/historyAlarm/loadHistoryAlarmByProId`,
method: "get",
header: {
'Accept':'application/json, text/plain, */*',
'Authorization':'Bearer '+this.userInfo.token
},
data: {
this
.
$API
.
call
({
url
:
'
/api/historyAlarm/loadHistoryAlarmByProId
'
,
method
:
"
GET
"
,
data
:{
page
:
this
.
page
,
pageSize
:
this
.
pageSize
,
proId:
this.
currProInfo.value,
proId
:
currProInfo
.
value
,
deviceName
:
this
.
query
.
name
||
''
}
}).then(result => {
let [error, res] = result
if (res.data && res.data.code==200) {
this.dataList = res.data.data.dataList
},
cb
:
(
res
)
=>
{
this
.
dataList
=
res
.
data
.
dataList
}
})
// uni.request({
// url: `${this.$BASEURL}/api/historyAlarm/loadHistoryAlarmByProId`,
// method: "get",
// header: {
// 'Accept':'application/json, text/plain, */*',
// 'Authorization':'Bearer '+this.userInfo.token
// },
// data: {
// page: this.page,
// pageSize: this.pageSize,
// proId: this.currProInfo.value,
// deviceName: this.query.name||''
// }
// }).then(result => {
// let [error, res] = result
// if (res.data && res.data.code==200) {
// this.dataList = res.data.data.dataList
// }
// })
},
}
}
...
...
shenmu/pages/tabBar/monitor/logData.
n
vue
→
shenmu/pages/tabBar/monitor/logData.vue
View file @
fc5d9169
...
...
@@ -5,7 +5,7 @@
<uni-data-select
v-model=
"query.item"
:localdata=
"itemList"
:clear=
"false"
@
input=
"loadData"
style=
"text-align: center"
></uni-data-select>
<uni-search-bar
v-model=
"query.name"
class=
"uni-mt-10 margin0"
radius=
"5"
placeholder=
"输入设备名查询"
clearButton="auto"
cancelButton="none" @confirm="loadData" />
cancelButton=
"none"
@
confirm=
"loadData"
/>
</view>
<uni-card
v-for=
"(item,index) in dataList"
:title=
"item.name"
:key=
'index'
:isFull=
"true"
:sub-title=
"'检测项:'+item.item"
:extra=
"'检测值:'+item.data"
:thumbnail=
"incoDic[item.item]"
@
click=
"getChartsData(item)"
>
...
...
@@ -21,7 +21,7 @@
<view
v-if=
"!dataList.length"
style=
"text-align:center;margin-top:55upx;color:#999;font-weight:bolder;"
>
未查询的传感器数据
</view>
<uni-popup
ref=
"chartPopup"
background-color=
"#fff"
>
<view
class=
"popup-view"
>
<
text class="popup-title"近12个小时监测变化曲线 </text
>
<
view
class=
"popup-title"
>
近12个小时监测变化曲线
</view
>
<canvas
canvas-id=
"canvasLine"
id=
"canvasLine"
class=
"charts"
@
touchmove=
"moveLine"
@
touchend=
"moveLine"
></canvas>
<!--
<uni-datetime-picker
v-model=
"chartDateRange"
type=
"daterange"
/>
-->
...
...
@@ -49,8 +49,8 @@
data
()
{
return
{
// baseUrl: "http://117.34.103.191:8086",
userInfo: {},
currProInfo: {},
//
userInfo: {},
//
currProInfo: {},
iconList
:
[
online
,
offline
],
incoDic
:
{
'
光照
'
:
m1
,
...
...
@@ -130,7 +130,7 @@
showpopup
:
true
,
cWidth
:
''
,
cHeight
:
''
,
//画布的宽高
data: {},
//
data: {},
// data: {
// categories: ["01时", "02时", "03时", "04时", "05时", "06时", "07时", "08时", "09时", "10时", "11时", "12时"],
// series: [{
...
...
@@ -152,9 +152,9 @@
// _self.showLine("canvasLine", _self.data)
// }
},
onReady() {
// this.loadData()
},
//
onReady() {
//
// this.loadData()
//
},
onShow
()
{
this
.
dateRange
=
[
this
.
getDate
(
Date
.
now
()),
this
.
getDate
(
Date
.
now
())]
this
.
loadData
()
...
...
@@ -185,63 +185,93 @@
_self
=
this
this
.
$refs
.
chartPopup
.
open
(
'
bottom
'
)
this
.
cWidth
=
uni
.
upx2px
(
750
)
this.cHeight = uni.upx2px(500-
10
0)
this
.
cHeight
=
uni
.
upx2px
(
500
-
4
0
)
// this.chartDateRange = [
// this.getDate(new Date(this.dateRange[0])),
// this.getDate(new Date(this.dateRange[1]))
// ]
},
loadData() {
this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
this.
currProInfo = JSON.parse(uni.getStorageSync('currProInfo'))
async
loadData
()
{
//
this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
const
currProInfo
=
JSON
.
parse
(
uni
.
getStorageSync
(
'
currProInfo
'
))
uni
.
setNavigationBarTitle
({
title: `历史数据-${
this.
currProInfo.text}`
title
:
`历史数据-
${
currProInfo
.
text
}
`
});
uni.request({
url: `${this.$BASEURL}/api/historyData/loadHistoryDataByUserid`,
method: "get",
header: {
'Accept':'application/json, text/plain, */*',
'Authorization':'Bearer '+this.userInfo.token
},
data: {
const
res
=
await
this
.
$API
.
call
({
url
:
'
/api/historyData/loadHistoryDataByUserid
'
,
method
:
"
GET
"
,
data
:{
page
:
this
.
page
,
pageSize
:
this
.
pageSize
,
proId:
this.
currProInfo.value,
proId
:
currProInfo
.
value
,
item
:
this
.
query
.
item
,
startTime
:
this
.
dateRange
[
0
],
endTime
:
this
.
dateRange
[
1
],
deviceName
:
this
.
query
.
name
||
''
}
}).then(result => {
let [error, res] = result
if (res.data && res.data.code==200) {
this.dataList = res.data.data.dataList
},
cb
:
(
res
)
=>
{
this
.
dataList
=
res
.
data
.
dataList
}
})
// uni.request({
// url: `${this.$BASEURL}/api/historyData/loadHistoryDataByUserid`,
// method: "get",
// header: {
// 'Accept':'application/json, text/plain, */*',
// 'Authorization':'Bearer '+this.userInfo.token
// },
// data: {
// page: this.page,
// pageSize: this.pageSize,
// proId: this.currProInfo.value,
// item: this.query.item,
// startTime: this.dateRange[0],
// endTime: this.dateRange[1],
// deviceName: this.query.name||''
// }
// }).then(result => {
// let [error, res] = result
// if (res.data && res.data.code==200) {
// this.dataList = res.data.data.dataList
// }
// })
},
getChartsData
(
item
){
this
.
initCharts
()
uni.request({
url: `${this.$BASEURL}/api/historyData/historyDataTrendChart`,
method: "get",
header: {
'Accept':'application/json, text/plain, */*',
'Authorization':'Bearer '+this.userInfo.token
},
data: {
this
.
$API
.
call
({
url
:
'
/api/historyData/historyDataTrendChart
'
,
method
:
"
GET
"
,
data
:{
deviceId
:
item
.
deviceId
,
time
:
item
.
time
}
}).then(result => {
let [error, res] = result
if (res.data && res.data.code==200) {
this.data = res.data.data
console.log(this.data)
this.showLine("canvasLine", this.data)
},
cb
:
(
res
)
=>
{
this
.
showLine
(
"
canvasLine
"
,
res
.
data
)
}
})
// uni.request({
// url: `${this.$BASEURL}/api/historyData/historyDataTrendChart`,
// method: "get",
// header: {
// 'Accept':'application/json, text/plain, */*',
// 'Authorization':'Bearer '+this.userInfo.token
// },
// data: {
// deviceId: item.deviceId,
// time: item.time
// }
// }).then(result => {
// let [error, res] = result
// if (res.data && res.data.code==200) {
// this.data = res.data.data
// console.log(this.data)
// this.showLine("canvasLine", this.data)
// }
// })
},
showLine
(
canvasId
,
chartData
)
{
canvaLineIns
=
new
uCharts
({
//这些配置项的意思看这:https://www.kancloud.cn/qiun/ucharts/1172125
...
...
@@ -324,7 +354,7 @@
.popup-title
{
width
:
100%
;
font-size: 2
0u
px;
font-size
:
2
6
r
px
;
margin-top
:
10
upx
;
text-align
:
center
;
}
...
...
shenmu/pages/tabBar/monitor/realAlarm.
n
vue
→
shenmu/pages/tabBar/monitor/realAlarm.vue
View file @
fc5d9169
<
template
>
<view
class=
"uni-container"
>
<view
style=
"background-color: white;"
>
<uni-search-bar v-model="query.name" class="uni-mt-10 margin0" radius="5" placeholder="输入设备名查询"
clearButton="auto"
<uni-search-bar
v-model=
"query.name"
class=
"uni-mt-10 margin0"
radius=
"5"
placeholder=
"输入设备名查询"
cancelButton=
"none"
@
confirm=
"loadData"
/>
</view>
<uni-card
v-for=
"(item,index) in dataList"
:title=
"item.deviceName"
:key=
'index'
:isFull=
"true"
...
...
@@ -18,28 +18,28 @@
</uni-row>
</uni-card>
<view
v-if=
"!dataList.length"
style=
"text-align:center;margin-top:55upx;color:#999;font-weight:bolder;"
>
未查询的传感器数据
</view>
<uni-popup ref="message" type="message">
<!--
<uni-popup
ref=
"message"
type=
"message"
>
<uni-popup-message
:type=
"msgType"
:message=
"messageText"
:duration=
"2000"
></uni-popup-message>
</uni-popup>
<uni-popup ref="alertDialog" type="dialog">
</uni-popup>
-->
<!--
<uni-popup
ref=
"alertDialog"
type=
"dialog"
>
<uni-popup-dialog
type=
"info"
cancelText=
"取消"
confirmText=
"确定"
content=
"您确定解除报警吗!"
@
confirm=
"dialogConfirm"
@
close=
"dialogClose"
></uni-popup-dialog>
</uni-popup>
</uni-popup>
-->
</view>
</
template
>
<
script
>
import
online
from
'
@/icon/online.png
'
import
offline
from
'
@/icon/offline.png
'
import
wendu
from
'
@/icon/wendu.png
'
export
default
{
data
()
{
return
{
baseUrl: "http://117.34.103.191:8086",
userInfo: {},
currProInfo: {},
// userInfo: {},
// currProInfo: {},
iconList
:
[
online
,
offline
,
wendu
],
msgType: 'success',
messageText: '',
//
msgType: 'success',
//
messageText: '',
query
:
{
name
:
''
},
...
...
@@ -50,117 +50,112 @@
offNum
:
13
,
},
removeWarnId
:
''
,
dataList: [/* {
name: '气象站7号',
type: '温度',
value: '39.7℃',
status: '报警',
time: '2023-10-18 10:03:58'
}, {
name: '气象站7号',
type: '温度',
value: '39.7℃',
status: '报警',
time: '2023-10-18 10:03:58'
}, {
name: '气象站7号',
type: '温度',
value: '39.7℃',
status: '报警',
time: '2023-10-18 10:03:58'
}, {
name: '气象站7号',
type: '温度',
value: '39.7℃',
status: '报警',
time: '2023-10-18 10:03:58'
}, {
name: '气象站7号',
type: '温度',
value: '39.7℃',
status: '报警',
time: '2023-10-18 10:03:58'
}, {
name: '气象站7号',
type: '温度',
value: '39.7℃',
status: '报警',
time: '2023-10-18 10:03:58'
} */]
dataList
:
[]
}
},
onReady() {
this.loadData()
},
onShow
()
{
this
.
loadData
()
},
methods
:
{
loadData
()
{
this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
this.
currProInfo = JSON.parse(uni.getStorageSync('currProInfo'))
//
this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
const
currProInfo
=
JSON
.
parse
(
uni
.
getStorageSync
(
'
currProInfo
'
))
uni
.
setNavigationBarTitle
({
title: `实时报警-${
this.
currProInfo.text}`
title
:
`实时报警-
${
currProInfo
.
text
}
`
});
uni.request
({
url:
`${this.$BASEURL}/api/nowAlarm/loadNowAlarmByProId`
,
this
.
$API
.
call
({
url
:
'
/api/nowAlarm/loadNowAlarmByProId
'
,
method
:
"
get
"
,
header: {
'Accept':'application/json, text/plain, */*',
'Authorization':'Bearer '+this.userInfo.token
},
data: {
data
:{
page
:
this
.
page
,
pageSize
:
this
.
pageSize
,
proId:
this.
currProInfo.value,
proId
:
currProInfo
.
value
,
deviceName
:
this
.
query
.
name
||
''
},
cb
:
(
res
)
=>
{
if
(
res
.
data
)
{
this
.
dataList
=
res
.
data
.
dataList
||
[]
}
}).then(result => {
let [error, res] = result
if (res.data && res.data.code==200) {
this.dataList = res.data.data.dataList
}
})
// uni.request({
// url: `${this.$BASEURL}/api/nowAlarm/loadNowAlarmByProId`,
// method: "get",
// header: {
// 'Accept':'application/json, text/plain, */*',
// 'Authorization':'Bearer '+this.userInfo.token
// },
// data: {
// page: this.page,
// pageSize: this.pageSize,
// proId: this.currProInfo.value,
// deviceName: this.query.name||''
// }
// }).then(result => {
// let [error, res] = result
// if (res.data && res.data.code==200) {
// this.dataList = res.data.data.dataList
// }
// })
},
dialogClose() {
this.msgType = 'error',
this.messageText = `取消解除报警`
this.$refs.message.open()
},
dialogConfirm() {
//
dialogClose() {
//
this.msgType = 'error',
//
this.messageText = `取消解除报警`
//
this.$refs.message.open()
//
},
async
dialogConfirm
()
{
if
(
!
this
.
removeWarnId
){
alert
(
'
请求参数不可为空
'
)
return
}
uni.request({
url: `${this.$BASEURL}/api/nowAlarm/releaseAlarm`,
this
.
$API
.
call
({
url
:
'
/api/nowAlarm/releaseAlarm
'
,
method
:
"
PUT
"
,
header: {
'Accept':'application/json, text/plain, */*',
'Authorization':'Bearer '+this.userInfo.token
},
data: {
showSuccessTip
:
true
,
data
:{
warnMsgId
:
this
.
removeWarnId
}
}).then(result => {
let [error, res] = result
if (res.data && res.data.code==200) {
this.msgType = 'success',
this.messageText = `确认解除报警`
this.$refs.message.open()
// 删除本地数据
},
cb
:
(
res
)
=>
{
const
removeIndex
=
this
.
dataList
.
findIndex
(
item
=>
item
.
warnMsgId
===
this
.
removeWarnId
)
this
.
dataList
.
splice
(
removeIndex
,
1
)
}
})
// uni.request({
// url: `${this.$BASEURL}/api/nowAlarm/releaseAlarm`,
// method: "PUT",
// header: {
// 'Accept':'application/json, text/plain, */*',
// 'Authorization':'Bearer '+this.userInfo.token
// },
// data: {
// warnMsgId: this.removeWarnId
// }
// }).then(result => {
// let [error, res] = result
// if (res.data && res.data.code==200) {
// this.msgType = 'success',
// this.messageText = `确认解除报警`
// this.$refs.message.open()
// // 删除本地数据
// const removeIndex = this.dataList.findIndex(item=>item.warnMsgId === this.removeWarnId)
// this.dataList.splice(removeIndex, 1)
// }else{
// this.$UTIL.resErrorDeal(res)
// }
// })
},
removeAlarm
(
item
)
{
this
.
removeWarnId
=
item
.
warnMsgId
this.$refs.alertDialog.open()
this
.
$TIP
.
confirmModal
({
cb
:
(
flag
)
=>
{
if
(
flag
){
this
.
dialogConfirm
()
}
}
})
// this.$refs.alertDialog.open()
},
onReachBottom
()
{
this
.
pageSize
+=
10
...
...
shenmu/pages/tabBar/monitor/realData.
n
vue
→
shenmu/pages/tabBar/monitor/realData.vue
View file @
fc5d9169
...
...
@@ -56,9 +56,9 @@
export
default
{
data
()
{
return
{
baseUrl: "http://192.168.3.23:8086",
userInfo: {},
currProInfo: {},
//
baseUrl: "http://192.168.3.23:8086",
//
userInfo: {},
//
currProInfo: {},
iconList
:
[
online
,
offline
],
incoDic
:
{
'
光照
'
:
m1
,
...
...
@@ -87,9 +87,9 @@
dataList
:
[]
}
},
onReady() {
this.loadData()
},
//
onReady() {
//
this.loadData()
//
},
onShow
()
{
this
.
loadData
()
},
...
...
@@ -99,32 +99,48 @@
},
methods
:
{
loadData
()
{
this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
this.
currProInfo = JSON.parse(uni.getStorageSync('currProInfo'))
//
this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
const
currProInfo
=
JSON
.
parse
(
uni
.
getStorageSync
(
'
currProInfo
'
))
uni
.
setNavigationBarTitle
({
title: `实时监测-${
this.
currProInfo.text}`
title
:
`实时监测-
${
currProInfo
.
text
}
`
})
uni.request({
url: this.baseUrl + '/api/nowData/loadNowDataByUserid',
method: "get",
header: {
'Accept':'application/json, text/plain, */*',
'Authorization':'Bearer '+this.userInfo.token
},
data: {
this
.
$API
.
call
({
url
:
'
/api/nowData/loadNowDataByUserid
'
,
data
:{
page
:
this
.
page
,
pageSize
:
this
.
pageSize
,
deviceName
:
this
.
query
.
name
||
''
,
proId: this.currProInfo.value
}
}).then(result => {
let [error, res] = result
if (res.data && res.data.code==200) {
this.dataList = res.data.data.dataList
this.devInfo.offNum = res.data.data.offlineNumbers
this.devInfo.onNum = res.data.data.onlineNumbers
proId
:
currProInfo
.
value
},
cb
:
(
res
)
=>
{
const
data
=
res
.
data
this
.
dataList
=
data
.
dataList
this
.
devInfo
.
offNum
=
data
.
offlineNumbers
this
.
devInfo
.
onNum
=
data
.
onlineNumbers
}
})
// uni.request({
// url: this.baseUrl + '/api/nowData/loadNowDataByUserid',
// method: "get",
// header: {
// 'Accept':'application/json, text/plain, */*',
// 'Authorization':'Bearer '+this.userInfo.token
// },
// data: {
// page: this.page,
// pageSize: this.pageSize,
// deviceName: this.query.name||'',
// proId: this.currProInfo.value
// }
// }).then(result => {
// let [error, res] = result
// if (res.data && res.data.code==200) {
// this.dataList = res.data.data.dataList
// this.devInfo.offNum = res.data.data.offlineNumbers
// this.devInfo.onNum = res.data.data.onlineNumbers
// }
// })
},
}
}
...
...
shenmu/pages/tabBar/monitor/userCenter.
n
vue
→
shenmu/pages/tabBar/monitor/userCenter.vue
View file @
fc5d9169
<
template
>
<view class="uni-container" style="height:
10
0%;">
<view
class=
"uni-container"
style=
"height:
9
0%;"
>
<view
class=
"uni-header-logo"
>
<image
class=
"uni-header-image"
src=
"/static/avatar.png"
></image>
</view>
...
...
@@ -26,10 +26,11 @@
proList
:
[]
}
},
onReady() {
this.loadData()
},
//
onReady() {
//
this.loadData()
//
},
onShow
()
{
this
.
loadData
()
this
.
refresh
()
},
methods
:
{
...
...
@@ -60,6 +61,7 @@
page
{
width
:
100%
!important
;
height
:
100%
!important
;
background-color
:
#f8f8f8
;
}
::v-deep
.uni-icons
{
...
...
@@ -84,4 +86,8 @@
.uni-pb-5
{
padding-bottom
:
10px
;
}
.uni-header-logo
{
display
:
flex
;
}
</
style
>
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