Commit fc5d9169 authored by zhanglw's avatar zhanglw

€请求方法封装 公共方法处理 请求提示共同方法抽取

parent 192a8edf
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
/**
* 确认提示框
*/
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
import msgTip from "./msgTip.js"
function formatTime(time) { function formatTime(time) {
if (typeof time !== 'number' || time < 0) { if (typeof time !== 'number' || time < 0) {
return time return time
...@@ -66,8 +67,34 @@ var dateUtils = { ...@@ -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 { export {
formatTime, formatTime,
formatLocation, formatLocation,
dateUtils dateUtils,
resErrorDeal
} }
import App from './App' import App from './App'
import store from './store' import store from './store'
import util from './common/util.js'
import API from '@/common/api.js'
import msgTip from "@/common/msgTip.js"
// #ifndef VUE3 // #ifndef VUE3
import Vue from 'vue' import Vue from 'vue'
...@@ -7,6 +10,11 @@ import Vue from 'vue' ...@@ -7,6 +10,11 @@ import Vue from 'vue'
// const BASEURL = 'http://117.34.103.191:8086' // 生产环境url // const BASEURL = 'http://117.34.103.191:8086' // 生产环境url
const BASEURL = 'http://192.168.3.23:8086' // 研发环境url const BASEURL = 'http://192.168.3.23:8086' // 研发环境url
Vue.prototype.$BASEURL = BASEURL Vue.prototype.$BASEURL = BASEURL
Vue.prototype.$UTIL = util
Vue.prototype.$API = API
Vue.prototype.$TIP = msgTip
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.prototype.$store = store Vue.prototype.$store = store
......
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
"Speech" : {}, "Speech" : {},
"VideoPlayer" : {} "VideoPlayer" : {}
}, },
"compatible" : {
"ignoreVersion" : true //true表示忽略版本检查提示框,HBuilderX1.9.0及以上版本支持
},
/* 应用发布信息 */ /* 应用发布信息 */
"distribute" : { "distribute" : {
/* android打包配置 */ /* android打包配置 */
......
...@@ -37,25 +37,40 @@ ...@@ -37,25 +37,40 @@
} }
}, },
methods: { methods: {
onLogin() { async onLogin() {
uni.request({ const res = await this.$API.call({
url: this.baseUrl + '/auth/login', url: '/auth/login2',
method: "POST",
header: {
'Accept':'application/json, text/plain, */*'
},
data: this.form, data: this.form,
}).then(result => { method: 'POST',
let [error, res] = result cb: (res) => {
if (res.data && res.data.token) { if (res.data && res.data.token) {
this.userInfo = res.data this.userInfo = res.data
uni.setStorageSync('userInfo', JSON.stringify(res.data)) uni.setStorageSync('userInfo', JSON.stringify(res.data))
uni.showToast({ uni.showToast({
title: '登录成功' title: '登录成功'
}) })
this.getProList() 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() { goToPage() {
// 跳转页面 // 跳转页面
...@@ -66,29 +81,46 @@ ...@@ -66,29 +81,46 @@
} }
}) })
}, },
getProList() { async getProList() {
uni.request({ const res = await this.$API.call({
url: this.baseUrl + '/api/static', url: '/api/static',
method: "get", cb: (res) => {
header: { if (res.data) {
'Accept':'application/json, text/plain, */*', let list = res.data.proListInfo || []
'Authorization':'Bearer '+this.userInfo.token this.proList = list.map(item=>{
} return {
}).then(result => { value: item.proId,
let [error, res] = result text: item.proName
if (res.data && res.data.code==200) { }
let list = res.data.data.proListInfo||[] })
this.proList = list.map(item=>{ uni.setStorageSync('proList', JSON.stringify(this.proList||[]))
return { uni.setStorageSync('currProInfo', JSON.stringify(this.proList[0]||{}))
value: item.proId, this.goToPage()
text: item.proName }
}
})
uni.setStorageSync('proList', JSON.stringify(this.proList||[]))
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()
// }
// })
} }
} }
} }
......
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
export default { export default {
data() { data() {
return { return {
baseUrl: "http://192.168.3.23:8086", // baseUrl: "http://192.168.3.23:8086",
userInfo: {}, // userInfo: {},
currProInfo: {}, // currProInfo: {},
iconList: [online, offline, wendu], iconList: [online, offline, wendu],
query: { query: {
name: '' name: ''
...@@ -77,9 +77,9 @@ ...@@ -77,9 +77,9 @@
} */] } */]
} }
}, },
onReady() { // onReady() {
this.loadData() // this.loadData()
}, // },
onShow() { onShow() {
this.loadData() this.loadData()
}, },
...@@ -89,31 +89,44 @@ ...@@ -89,31 +89,44 @@
}, },
methods: { methods: {
loadData() { loadData() {
this.userInfo = JSON.parse(uni.getStorageSync('userInfo')) // this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
this.currProInfo = JSON.parse(uni.getStorageSync('currProInfo')) const currProInfo = JSON.parse(uni.getStorageSync('currProInfo'))
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: `历史报警-${this.currProInfo.text}` title: `历史报警-${currProInfo.text}`
}); });
uni.request({ this.$API.call({
url: `${this.$BASEURL}/api/historyAlarm/loadHistoryAlarmByProId`, url: '/api/historyAlarm/loadHistoryAlarmByProId',
method: "get", method: "GET",
header: { data:{
'Accept':'application/json, text/plain, */*',
'Authorization':'Bearer '+this.userInfo.token
},
data: {
page: this.page, page: this.page,
pageSize: this.pageSize, pageSize: this.pageSize,
proId: this.currProInfo.value, proId: currProInfo.value,
deviceName: this.query.name||'' deviceName: this.query.name||''
} },
}).then(result => { cb: (res) => {
let [error, res] = result this.dataList = res.data.dataList
if (res.data && res.data.code==200) {
this.dataList = res.data.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
// }
// })
}, },
} }
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<uni-data-select v-model="query.item" :localdata="itemList" :clear="false" @input="loadData" <uni-data-select v-model="query.item" :localdata="itemList" :clear="false" @input="loadData"
style="text-align: center"></uni-data-select> style="text-align: center"></uni-data-select>
<uni-search-bar v-model="query.name" class="uni-mt-10 margin0" radius="5" placeholder="输入设备名查询" <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> </view>
<uni-card v-for="(item,index) in dataList" :title="item.name" :key='index' :isFull="true" <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)"> :sub-title="'检测项:'+item.item" :extra="'检测值:'+item.data" :thumbnail="incoDic[item.item]" @click="getChartsData(item)">
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<view v-if="!dataList.length" style="text-align:center;margin-top:55upx;color:#999;font-weight:bolder;">未查询的传感器数据</view> <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"> <uni-popup ref="chartPopup" background-color="#fff">
<view class="popup-view"> <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" <canvas canvas-id="canvasLine" id="canvasLine" class="charts" @touchmove="moveLine"
@touchend="moveLine"></canvas> @touchend="moveLine"></canvas>
<!-- <uni-datetime-picker v-model="chartDateRange" type="daterange" /> --> <!-- <uni-datetime-picker v-model="chartDateRange" type="daterange" /> -->
...@@ -49,8 +49,8 @@ ...@@ -49,8 +49,8 @@
data() { data() {
return { return {
// baseUrl: "http://117.34.103.191:8086", // baseUrl: "http://117.34.103.191:8086",
userInfo: {}, // userInfo: {},
currProInfo: {}, // currProInfo: {},
iconList: [online, offline], iconList: [online, offline],
incoDic: { incoDic: {
'光照': m1, '光照': m1,
...@@ -130,7 +130,7 @@ ...@@ -130,7 +130,7 @@
showpopup: true, showpopup: true,
cWidth: '', cWidth: '',
cHeight: '', //画布的宽高 cHeight: '', //画布的宽高
data: {}, // data: {},
// data: { // data: {
// categories: ["01时", "02时", "03时", "04时", "05时", "06时", "07时", "08时", "09时", "10时", "11时", "12时"], // categories: ["01时", "02时", "03时", "04时", "05时", "06时", "07时", "08时", "09时", "10时", "11时", "12时"],
// series: [{ // series: [{
...@@ -152,9 +152,9 @@ ...@@ -152,9 +152,9 @@
// _self.showLine("canvasLine", _self.data) // _self.showLine("canvasLine", _self.data)
// } // }
}, },
onReady() { // onReady() {
// this.loadData() // // this.loadData()
}, // },
onShow() { onShow() {
this.dateRange = [this.getDate(Date.now()), this.getDate(Date.now())] this.dateRange = [this.getDate(Date.now()), this.getDate(Date.now())]
this.loadData() this.loadData()
...@@ -185,63 +185,93 @@ ...@@ -185,63 +185,93 @@
_self = this _self = this
this.$refs.chartPopup.open('bottom') this.$refs.chartPopup.open('bottom')
this.cWidth = uni.upx2px(750) this.cWidth = uni.upx2px(750)
this.cHeight = uni.upx2px(500-100) this.cHeight = uni.upx2px(500-40)
// this.chartDateRange = [ // this.chartDateRange = [
// this.getDate(new Date(this.dateRange[0])), // this.getDate(new Date(this.dateRange[0])),
// this.getDate(new Date(this.dateRange[1])) // this.getDate(new Date(this.dateRange[1]))
// ] // ]
}, },
loadData() { async loadData() {
this.userInfo = JSON.parse(uni.getStorageSync('userInfo')) // this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
this.currProInfo = JSON.parse(uni.getStorageSync('currProInfo')) const currProInfo = JSON.parse(uni.getStorageSync('currProInfo'))
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: `历史数据-${this.currProInfo.text}` title: `历史数据-${currProInfo.text}`
}); });
uni.request({
url: `${this.$BASEURL}/api/historyData/loadHistoryDataByUserid`, const res = await this.$API.call({
method: "get", url: '/api/historyData/loadHistoryDataByUserid',
header: { method: "GET",
'Accept':'application/json, text/plain, */*', data:{
'Authorization':'Bearer '+this.userInfo.token
},
data: {
page: this.page, page: this.page,
pageSize: this.pageSize, pageSize: this.pageSize,
proId: this.currProInfo.value, proId: currProInfo.value,
item: this.query.item, item: this.query.item,
startTime: this.dateRange[0], startTime: this.dateRange[0],
endTime: this.dateRange[1], endTime: this.dateRange[1],
deviceName: this.query.name||'' deviceName: this.query.name||''
} },
}).then(result => { cb: (res) => {
let [error, res] = result this.dataList = res.data.dataList
if (res.data && res.data.code==200) {
this.dataList = res.data.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){ getChartsData(item){
this.initCharts() this.initCharts()
uni.request({
url: `${this.$BASEURL}/api/historyData/historyDataTrendChart`, this.$API.call({
method: "get", url: '/api/historyData/historyDataTrendChart',
header: { method: "GET",
'Accept':'application/json, text/plain, */*', data:{
'Authorization':'Bearer '+this.userInfo.token
},
data: {
deviceId: item.deviceId, deviceId: item.deviceId,
time: item.time time: item.time
} },
}).then(result => { cb: (res) => {
let [error, res] = result this.showLine("canvasLine", res.data)
if (res.data && res.data.code==200) {
this.data = res.data.data
console.log(this.data)
this.showLine("canvasLine", this.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) { showLine(canvasId, chartData) {
canvaLineIns = new uCharts({ //这些配置项的意思看这:https://www.kancloud.cn/qiun/ucharts/1172125 canvaLineIns = new uCharts({ //这些配置项的意思看这:https://www.kancloud.cn/qiun/ucharts/1172125
...@@ -324,7 +354,7 @@ ...@@ -324,7 +354,7 @@
.popup-title { .popup-title {
width: 100%; width: 100%;
font-size: 20upx; font-size: 26rpx;
margin-top: 10upx; margin-top: 10upx;
text-align: center; text-align: center;
} }
......
<template> <template>
<view class="uni-container"> <view class="uni-container">
<view style="background-color: white;"> <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" /> cancelButton="none" @confirm="loadData" />
</view> </view>
<uni-card v-for="(item,index) in dataList" :title="item.deviceName" :key='index' :isFull="true" <uni-card v-for="(item,index) in dataList" :title="item.deviceName" :key='index' :isFull="true"
...@@ -18,28 +18,28 @@ ...@@ -18,28 +18,28 @@
</uni-row> </uni-row>
</uni-card> </uni-card>
<view v-if="!dataList.length" style="text-align:center;margin-top:55upx;color:#999;font-weight:bolder;">未查询的传感器数据</view> <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-message :type="msgType" :message="messageText" :duration="2000"></uni-popup-message>
</uni-popup> </uni-popup> -->
<uni-popup ref="alertDialog" type="dialog"> <!-- <uni-popup ref="alertDialog" type="dialog">
<uni-popup-dialog type="info" cancelText="取消" confirmText="确定" content="您确定解除报警吗!" @confirm="dialogConfirm" <uni-popup-dialog type="info" cancelText="取消" confirmText="确定" content="您确定解除报警吗!" @confirm="dialogConfirm"
@close="dialogClose"></uni-popup-dialog> @close="dialogClose"></uni-popup-dialog>
</uni-popup> </uni-popup> -->
</view> </view>
</template> </template>
<script> <script>
import online from '@/icon/online.png' import online from '@/icon/online.png'
import offline from '@/icon/offline.png' import offline from '@/icon/offline.png'
import wendu from '@/icon/wendu.png' import wendu from '@/icon/wendu.png'
export default { export default {
data() { data() {
return { return {
baseUrl: "http://117.34.103.191:8086", // userInfo: {},
userInfo: {}, // currProInfo: {},
currProInfo: {},
iconList: [online, offline, wendu], iconList: [online, offline, wendu],
msgType: 'success', // msgType: 'success',
messageText: '', // messageText: '',
query: { query: {
name: '' name: ''
}, },
...@@ -50,117 +50,112 @@ ...@@ -50,117 +50,112 @@
offNum: 13, offNum: 13,
}, },
removeWarnId: '', removeWarnId: '',
dataList: [/* { 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'
} */]
} }
}, },
onReady() {
this.loadData()
},
onShow() { onShow() {
this.loadData() this.loadData()
}, },
methods: { methods: {
loadData() { loadData() {
this.userInfo = JSON.parse(uni.getStorageSync('userInfo')) // this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
this.currProInfo = JSON.parse(uni.getStorageSync('currProInfo')) const currProInfo = JSON.parse(uni.getStorageSync('currProInfo'))
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: `实时报警-${this.currProInfo.text}` title: `实时报警-${currProInfo.text}`
}); });
uni.request({ this.$API.call({
url: `${this.$BASEURL}/api/nowAlarm/loadNowAlarmByProId`, url: '/api/nowAlarm/loadNowAlarmByProId',
method: "get", method: "get",
header: { data:{
'Accept':'application/json, text/plain, */*',
'Authorization':'Bearer '+this.userInfo.token
},
data: {
page: this.page, page: this.page,
pageSize: this.pageSize, pageSize: this.pageSize,
proId: this.currProInfo.value, proId: currProInfo.value,
deviceName: this.query.name||'' deviceName: this.query.name||''
} },
}).then(result => { cb: (res) => {
let [error, res] = result if (res.data) {
if (res.data && res.data.code==200) { this.dataList = res.data.dataList || []
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() { // dialogClose() {
this.msgType = 'error', // this.msgType = 'error',
this.messageText = `取消解除报警` // this.messageText = `取消解除报警`
this.$refs.message.open() // this.$refs.message.open()
}, // },
dialogConfirm() { async dialogConfirm() {
if(!this.removeWarnId){ if(!this.removeWarnId){
alert('请求参数不可为空') alert('请求参数不可为空')
return return
} }
this.$API.call({
url: '/api/nowAlarm/releaseAlarm',
uni.request({
url: `${this.$BASEURL}/api/nowAlarm/releaseAlarm`,
method: "PUT", method: "PUT",
header: { showSuccessTip: true,
'Accept':'application/json, text/plain, */*', data:{
'Authorization':'Bearer '+this.userInfo.token
},
data: {
warnMsgId: this.removeWarnId warnMsgId: this.removeWarnId
} },
}).then(result => { cb: (res) => {
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) const removeIndex = this.dataList.findIndex(item=>item.warnMsgId === this.removeWarnId)
this.dataList.splice(removeIndex, 1) 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) { removeAlarm(item) {
this.removeWarnId = item.warnMsgId this.removeWarnId = item.warnMsgId
this.$refs.alertDialog.open() this.$TIP.confirmModal({
cb: (flag)=>{
if(flag){
this.dialogConfirm()
}
}
})
// this.$refs.alertDialog.open()
}, },
onReachBottom() { onReachBottom() {
this.pageSize += 10 this.pageSize += 10
......
...@@ -56,9 +56,9 @@ ...@@ -56,9 +56,9 @@
export default { export default {
data() { data() {
return { return {
baseUrl: "http://192.168.3.23:8086", // baseUrl: "http://192.168.3.23:8086",
userInfo: {}, // userInfo: {},
currProInfo: {}, // currProInfo: {},
iconList: [online, offline], iconList: [online, offline],
incoDic: { incoDic: {
'光照': m1, '光照': m1,
...@@ -87,9 +87,9 @@ ...@@ -87,9 +87,9 @@
dataList: [] dataList: []
} }
}, },
onReady() { // onReady() {
this.loadData() // this.loadData()
}, // },
onShow() { onShow() {
this.loadData() this.loadData()
}, },
...@@ -99,32 +99,48 @@ ...@@ -99,32 +99,48 @@
}, },
methods: { methods: {
loadData() { loadData() {
this.userInfo = JSON.parse(uni.getStorageSync('userInfo')) // this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
this.currProInfo = JSON.parse(uni.getStorageSync('currProInfo')) const currProInfo = JSON.parse(uni.getStorageSync('currProInfo'))
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: `实时监测-${this.currProInfo.text}` title: `实时监测-${currProInfo.text}`
}) })
uni.request({
url: this.baseUrl + '/api/nowData/loadNowDataByUserid', this.$API.call({
method: "get", url: '/api/nowData/loadNowDataByUserid',
header: { data:{
'Accept':'application/json, text/plain, */*',
'Authorization':'Bearer '+this.userInfo.token
},
data: {
page: this.page, page: this.page,
pageSize: this.pageSize, pageSize: this.pageSize,
deviceName: this.query.name||'', deviceName: this.query.name||'',
proId: this.currProInfo.value proId: currProInfo.value
} },
}).then(result => { cb: (res) => {
let [error, res] = result const data = res.data
if (res.data && res.data.code==200) { this.dataList = data.dataList
this.dataList = res.data.data.dataList this.devInfo.offNum = data.offlineNumbers
this.devInfo.offNum = res.data.data.offlineNumbers this.devInfo.onNum = data.onlineNumbers
this.devInfo.onNum = res.data.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
// }
// })
}, },
} }
} }
......
<template> <template>
<view class="uni-container" style="height: 100%;"> <view class="uni-container" style="height: 90%;">
<view class="uni-header-logo"> <view class="uni-header-logo">
<image class="uni-header-image" src="/static/avatar.png"></image> <image class="uni-header-image" src="/static/avatar.png"></image>
</view> </view>
...@@ -26,10 +26,11 @@ ...@@ -26,10 +26,11 @@
proList: [] proList: []
} }
}, },
onReady() { // onReady() {
this.loadData() // this.loadData()
}, // },
onShow() { onShow() {
this.loadData()
this.refresh() this.refresh()
}, },
methods: { methods: {
...@@ -50,7 +51,7 @@ ...@@ -50,7 +51,7 @@
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: `我的设置` title: `我的设置`
}); });
} }
} }
} }
</script> </script>
...@@ -60,6 +61,7 @@ ...@@ -60,6 +61,7 @@
page { page {
width: 100% !important; width: 100% !important;
height: 100% !important; height: 100% !important;
background-color: #f8f8f8;
} }
::v-deep .uni-icons { ::v-deep .uni-icons {
...@@ -84,4 +86,8 @@ ...@@ -84,4 +86,8 @@
.uni-pb-5 { .uni-pb-5 {
padding-bottom: 10px; padding-bottom: 10px;
} }
.uni-header-logo{
display: flex;
}
</style> </style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment