home.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <template>
  2. <view id="home">
  3. <view class="home-max-big-box">
  4. <!-- 物联设备信息 -->
  5. <view class="devices-info-max-big-box">
  6. <view class="devices-info-max-box">
  7. <view class="devices-info-big-box">
  8. <view class="devices-image-box">
  9. <image :src="hardwareImg"></image>
  10. </view>
  11. <view class="devices-info-box">
  12. <view>{{devicesData.hardwareCount?devicesData.hardwareCount:0}}</view>
  13. <view>硬件设备</view>
  14. </view>
  15. </view>
  16. <view class="devices-null-box"></view>
  17. <view class="devices-info-big-box">
  18. <view class="devices-image-box">
  19. <image :src="iotImg"></image>
  20. </view>
  21. <view class="devices-info-box">
  22. <view>{{devicesData.iotDeviceCount?devicesData.iotDeviceCount:0}}</view>
  23. <view>物联设备</view>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="devices-info-max-box">
  28. <view class="devices-info-big-box">
  29. <view class="devices-image-box">
  30. <image :src="onlineImg"></image>
  31. </view>
  32. <view class="devices-info-box">
  33. <view>{{devicesData.onlineRate?devicesData.onlineRate:0}}%</view>
  34. <view>在线设备</view>
  35. </view>
  36. </view>
  37. <view class="devices-null-box"></view>
  38. <view class="devices-info-big-box">
  39. <view class="devices-image-box">
  40. <image :src="offlineImg"></image>
  41. </view>
  42. <view class="devices-info-box">
  43. <view>{{devicesData.offlineRate?devicesData.offlineRate:0}}%</view>
  44. <view>离线设备</view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <!-- 物联功能模块 -->
  50. <view class="devices-button-max-big-box">
  51. <view class="devices-button-big-box" @click="buttonGoPath('iot:type:list')">
  52. <view class="devices-button-box button-one">
  53. <image :src="buttonTwoImg"></image>
  54. </view>
  55. <view class="devices-button-name">物联分类</view>
  56. </view>
  57. <view class="devices-button-big-box" @click="buttonGoPath('iot:device:list')">
  58. <view class="devices-button-box button-two">
  59. <image :src="buttonThreeImg"></image>
  60. </view>
  61. <view class="devices-button-name">物联设备</view>
  62. </view>
  63. <view class="devices-button-big-box" @click="buttonGoPath('iot:hardware:list')">
  64. <view class="devices-button-box button-three">
  65. <image :src="buttonFourImg"></image>
  66. </view>
  67. <view class="devices-button-name">硬件设备</view>
  68. </view>
  69. <view class="devices-button-big-box" @click="buttonGoPath('iot:network:list')">
  70. <view class="devices-button-box button-four">
  71. <image :src="buttonOneImg"></image>
  72. </view>
  73. <view class="devices-button-name">网络组件</view>
  74. </view>
  75. </view>
  76. <!-- 告警消息列表 -->
  77. <view class="devices-list-max-big-box">
  78. <view class="devices-list-title-box">
  79. <view>告警消息</view>
  80. <view @click="buttonGoPath('iot:alertLog:list')">更多>></view>
  81. </view>
  82. <view class="devices-list-max">
  83. <view class="devices-list-null" v-if="!logList[0]">暂无数据</view>
  84. <view class="devices-list-for" v-for="(item,index) in logList">
  85. <!--
  86. {name:"钉钉",id:1,},
  87. {name:"微信",id:2,},
  88. {name:"邮件",id:3,},
  89. {name:"电话",id:4,},
  90. {name:"短信",id:5,},
  91. -->
  92. <view>
  93. {{item.alarmType == 1?'钉钉':(
  94. item.alarmType == 2?'微信':(
  95. item.alarmType == 3?'邮件':(
  96. item.alarmType == 4?'电话':(
  97. item.alarmType == 5?'短信':''))))}}
  98. </view>
  99. <view>{{item.content}}</view>
  100. <view>{{ parseTime(item.createTime,"{y}-{m}-{d} {h}:{i}") }}</view>
  101. </view>
  102. <view class="devices-list-null" v-if="!logList[0]">暂无数据</view>
  103. </view>
  104. </view>
  105. </view>
  106. <!-- 底部导航 -->
  107. <view class="tab-bottom-max-box">
  108. <view class="tab-null-view"></view>
  109. <view class="tab-button-box">
  110. <image :src="workbenchImg"></image>
  111. <view>工作台</view>
  112. </view>
  113. <view class="tab-null-view"></view>
  114. </view>
  115. </view>
  116. </template>
  117. <script>
  118. import { iotStatisticsDevices,iotAlarmLogSelect } from '@/api/index.js'
  119. export default {
  120. data() {
  121. return {
  122. //设备信息
  123. devicesData:{
  124. hardwareCount:null,
  125. iotDeviceCount:null,
  126. offlineRate:null,
  127. onlineRate:null
  128. },
  129. //按钮图片
  130. hardwareImg:require('@/images/home_hardware_icon.png'),
  131. iotImg:require('@/images/home_iot_icon.png'),
  132. offlineImg:require('@/images/home_offline_icon.png'),
  133. onlineImg:require('@/images/home_online_icon.png'),
  134. buttonOneImg:require('@/images/home_button_1.png'),
  135. buttonTwoImg:require('@/images/home_button_2.png'),
  136. buttonThreeImg:require('@/images/home_button_3.png'),
  137. buttonFourImg:require('@/images/home_button_4.png'),
  138. workbenchImg:require('@/images/tab_workbench_2.png'),
  139. //权限数据
  140. permissions:uni.getStorageSync('permissions'),
  141. //告警消息
  142. logList:[],
  143. }
  144. },
  145. onLoad(option) {
  146. },
  147. onShow(){
  148. this.iotStatisticsDevices();
  149. this.iotAlarmLogSelect();
  150. },
  151. methods: {
  152. //获取设备信息
  153. async iotStatisticsDevices(){
  154. const {data} = await iotStatisticsDevices();
  155. if(data.code==200){
  156. this.$set(this,'devicesData',data.data);
  157. }
  158. },
  159. //获取告警消息列表
  160. async iotAlarmLogSelect(){
  161. const {data} = await iotAlarmLogSelect();
  162. if(data.code==200){
  163. this.$set(this,'logList',data.data.records);
  164. }
  165. },
  166. //跳转业务页面
  167. buttonGoPath(text){
  168. let num = 0;
  169. this.permissions.forEach((item) => {
  170. if(item == text){
  171. num++
  172. return
  173. }
  174. })
  175. if(num == 0){
  176. uni.showToast({
  177. mask:true,
  178. icon:"none",
  179. position:"center",
  180. title: '没有相关权限,请联系管理员',
  181. duration: 2000
  182. });
  183. }else{
  184. if(text == 'iot:type:list'){
  185. //物联分类
  186. uni.navigateTo({
  187. url: '/pages/iotClassification/index',
  188. });
  189. }else if(text == 'iot:device:list'){
  190. //物联设备
  191. uni.navigateTo({
  192. url: '/pages/iotDevice/index',
  193. });
  194. }else if(text == 'iot:hardware:list'){
  195. //硬件设备
  196. uni.navigateTo({
  197. url: '/pages/hardware/index',
  198. });
  199. }else if(text == 'iot:network:list'){
  200. //网络组件
  201. uni.navigateTo({
  202. url: '/pages/networkComponent/index',
  203. });
  204. }else if(text == 'iot:alertLog:list'){
  205. //告警日志
  206. uni.navigateTo({
  207. url: '/pages/warningLog/index',
  208. });
  209. }
  210. }
  211. },
  212. },
  213. }
  214. </script>
  215. <style lang="stylus" scoped>
  216. #home{
  217. flex:1;
  218. display: flex;
  219. flex-direction: column;
  220. overflow: hidden;
  221. .home-max-big-box{
  222. flex:1;
  223. flex-direction: column;
  224. overflow: hidden;
  225. padding:40rpx;
  226. overflow-x: hidden;
  227. overflow-y: scroll;
  228. .devices-info-max-big-box{
  229. height:200rpx;
  230. padding:20rpx 40rpx;
  231. background-color: #fff;
  232. box-shadow: 0 0 8px 1px rgba(0, 0, 0, 0.1);
  233. border-radius:12rpx;
  234. .devices-info-max-box{
  235. display: flex;
  236. .devices-info-big-box{
  237. flex:1;
  238. display: flex;
  239. .devices-image-box{
  240. height:100rpx;
  241. image{
  242. width:60rpx;
  243. height:60rpx;
  244. margin:20rpx;
  245. }
  246. }
  247. .devices-info-box{
  248. flex:1;
  249. view{
  250. text-align: center;
  251. color:#333;
  252. }
  253. view:nth-child(1){
  254. font-size:30rpx;
  255. margin-top:12rpx;
  256. }
  257. view:nth-child(2){
  258. font-size:28rpx;
  259. margin-top:6rpx;
  260. }
  261. }
  262. }
  263. .devices-null-box{
  264. width:60rpx;
  265. }
  266. }
  267. }
  268. .devices-button-max-big-box{
  269. height:240rpx;
  270. margin:40rpx 0;
  271. background-color: #fff;
  272. box-shadow: 0 0 8px 1px rgba(0, 0, 0, 0.1);
  273. border-radius:12rpx;
  274. display: flex;
  275. .devices-button-big-box{
  276. margin:40rpx 0 0 39rpx;
  277. .devices-button-box{
  278. width:120rpx;
  279. height:120rpx;
  280. border-radius:12rpx;
  281. image{
  282. width:80rpx;
  283. height:80rpx;
  284. margin:20rpx;
  285. }
  286. }
  287. .button-one{
  288. background-color: #4FA6ED;
  289. }
  290. .button-two{
  291. background-color: #30CAA1;
  292. }
  293. .button-three{
  294. background-color: #F17262;
  295. }
  296. .button-four{
  297. background-color: #33BCD5;
  298. }
  299. .devices-button-name{
  300. line-height:60rpx;
  301. font-size:26rpx;
  302. text-align: center;
  303. }
  304. }
  305. }
  306. .devices-list-max-big-box{
  307. flex:1;
  308. background-color: #fff;
  309. box-shadow: 0 0 8px 1px rgba(0, 0, 0, 0.1);
  310. border-radius:12rpx;
  311. display: flex;
  312. flex-direction: column;
  313. .devices-list-title-box{
  314. display: flex;
  315. border-bottom:1px solid #dedede;
  316. margin:0 20rpx;
  317. padding:0 20rpx;
  318. view:nth-child(1){
  319. flex:1;
  320. line-height:80rpx;
  321. font-size:28rpx;
  322. color:#333;
  323. }
  324. view:nth-child(2){
  325. width:120rpx;
  326. text-align: center;
  327. line-height:80rpx;
  328. font-size:28rpx;
  329. color:#0183FA;
  330. }
  331. }
  332. .devices-list-max{
  333. min-height:300rpx;
  334. padding:10rpx 0;
  335. }
  336. .devices-list-null{
  337. font-size:28rpx;
  338. text-align:center;
  339. line-height:100rpx;
  340. color:#999;
  341. }
  342. .devices-list-for{
  343. padding:10rpx 20rpx;
  344. display: flex;
  345. view{
  346. font-size:26rpx;
  347. }
  348. view:nth-child(1){
  349. width:80rpx;
  350. }
  351. view:nth-child(2){
  352. flex:1;
  353. /*单行省略号*/
  354. display:block;
  355. overflow:hidden;
  356. text-overflow:ellipsis;
  357. white-space:nowrap;
  358. }
  359. view:nth-child(3){
  360. width:240rpx;
  361. text-align: right;
  362. }
  363. }
  364. .devices-list-null{
  365. text-align: center;
  366. font-size:28rpx;
  367. line-height:200rpx;
  368. color:#999;
  369. }
  370. }
  371. }
  372. .tab-bottom-max-box{
  373. display: flex;
  374. height:120rpx;
  375. background-color: #fff;
  376. box-shadow: 0 0 8px 1px rgba(0, 0, 0, 0.1);
  377. .tab-null-view{
  378. flex:1;
  379. }
  380. .tab-button-box{
  381. image{
  382. display: block;
  383. width:40rpx;
  384. height:40rpx;
  385. margin:25rpx auto 10rpx;
  386. }
  387. view{
  388. text-align: center;
  389. font-size:26rpx;
  390. color:#0183FA;
  391. }
  392. }
  393. }
  394. }
  395. </style>