Navbar.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <template>
  2. <view class="navbar">
  3. <view class="logo">
  4. <image src="/static/left/logo.png"></image>
  5. </view>
  6. <view class="station_box">
  7. {{'No.'+codeState || '-'}}
  8. <image class="station_box_img" :src="cloud?`/static/left/link.png`:`/static/left/close.png`">
  9. </image>
  10. </view>
  11. <view class="routList">
  12. <view class="category" v-for="(item,index) in categoryList"
  13. :class="item.name==$store.state.currentpage?'active':''" @click="getPage(item.name)">
  14. <image
  15. :src="item.name==$store.state.currentpage?`/static/left/tab${index+1}-active.png`:`/static/left/tab${index+1}.png`">
  16. </image>
  17. <view>{{item.name}}</view>
  18. </view>
  19. </view>
  20. <view class="fiexd_footer">
  21. <view class="left_footer">
  22. <view class="box_click" @click="goTo">
  23. </view>
  24. <view class="left_footer_woring">
  25. {{alarmNum}}
  26. </view>
  27. <view class="left_footer_title">
  28. 智锂物联V1.0<br />
  29. 重卡换电智能站控系统
  30. </view>
  31. <view class="left_footer_btn" @click="login_off">
  32. {{userName}}
  33. <image src="../../static/login_img/login_off.png" mode="" class="login_off"></image>
  34. </view>
  35. </view>
  36. </view>
  37. <!-- 顶部公共提示信息 -->
  38. <uni-popup ref="Exchangepopup" type="message">
  39. <uni-popup-message :type="popupType" :message="popupMessage" :duration="2000"></uni-popup-message>
  40. </uni-popup>
  41. <!-- 顶部提示信息结束-->
  42. </view>
  43. </template>
  44. <script>
  45. export default {
  46. name: "Navbar",
  47. data() {
  48. return {
  49. currentPage: 0,
  50. popupType: '',
  51. popupMessage: '',
  52. userName: '',
  53. categoryList: [{
  54. name: '首页',
  55. url: '/pages/index/index',
  56. pathName: 'index'
  57. }, {
  58. name: '换电监控',
  59. url: '/pages/power-changer/index',
  60. pathName: 'powerchange'
  61. }, {
  62. name: '设备监控',
  63. url: '/pages/equipment-monitoring/index',
  64. pathName: 'equipment'
  65. }, {
  66. name: '服务记录',
  67. url: '/pages/service-recode/index'
  68. }, {
  69. name: '故障告警',
  70. url: '/pages/fault-alarm/index'
  71. }, {
  72. name: '基础数据',
  73. url: '/pages/basic-data/index'
  74. }],
  75. alarmNum: 0, //消防告警数量
  76. cloud: 0, //云端
  77. codeState: 0, //编号
  78. curAlarmNum:null,
  79. };
  80. },
  81. mounted() {
  82. // this.getRoute()
  83. this.getuserinfo()
  84. this.getState()
  85. this.cloudConnState()
  86. this.curAlarmNum=setInterval(()=>{
  87. this.cloudConnState()
  88. this.getnum()
  89. },5000)
  90. },
  91. destroyed() {
  92. clearInterval(this.curAlarmNum)
  93. },
  94. methods: {
  95. //编号
  96. getState() {
  97. this.$http.getStationCode().then(res => {
  98. if (res.code === 0) {
  99. this.codeState = res.data
  100. }
  101. });
  102. },
  103. //云端
  104. cloudConnState() {
  105. this.$http.getSwapcloudConnState().then(res => {
  106. if (res.code === 0) {
  107. this.cloud = res.data
  108. }
  109. });
  110. },
  111. getPage(name) {
  112. this.$store.commit("UPDATEPAGE", name);
  113. this.$storage.setJson("pageName", name)
  114. },
  115. login_off() {
  116. let that = this
  117. uni.showModal({
  118. title: "是否退出登录",
  119. content: "",
  120. success: function(res) {
  121. if (res.confirm) {
  122. // that.$storage.clear(); //清除所有本地存储
  123. that.$storage.remove("users")
  124. that.$storage.remove("token")
  125. that.$store.commit("DELETEUSERS")
  126. uni.navigateTo({
  127. url: "../../pages/login/index"
  128. })
  129. //用户点击确认按钮触发
  130. } else if (res.cancel) {
  131. return
  132. //用户点击取消按钮触发
  133. }
  134. }
  135. })
  136. },
  137. //根据用户id得到用户信息
  138. getuserinfo() {
  139. let userId = this.$storage.getJson("userId")
  140. let token = this.$storage.getJson("token")
  141. let data = {
  142. id: userId
  143. }
  144. this.$http.getInfo(data).then(res => {
  145. if (res.code == 0) {
  146. this.userName = res.data.userAccount
  147. } else {
  148. this.ExchangeMessage('error', res.msg)
  149. }
  150. })
  151. },
  152. //顶部公共消息提示
  153. ExchangeMessage(type, message) {
  154. this.popupType = type
  155. this.popupMessage = message ? message : '后端接口404错误!'
  156. this.$refs.Exchangepopup.open()
  157. },
  158. //跳转到消防告警列表
  159. goTo() {
  160. this.getPage('故障告警')
  161. this.$storage.setJson('gotoname', 1) //存本地用于判断显示的告警页面
  162. },
  163. //当前实时消防告警数量
  164. getnum() {
  165. this.$http.getToDayAlarm().then(res => {
  166. if (res.code == 0) {
  167. this.alarmNum = res.data.length
  168. }
  169. });
  170. }
  171. },
  172. }
  173. </script>
  174. <style lang="scss" scoped>
  175. .navbar {
  176. height: 100vh;
  177. width: 180px;
  178. padding-right: 20px;
  179. box-sizing: border-box;
  180. display: flex;
  181. flex-direction: column;
  182. border-right: 1px solid rgba(255, 255, 255, 0.1);
  183. .logo {
  184. width: 150px;
  185. height: 42px;
  186. margin-top: 24px;
  187. image {
  188. width: 150px;
  189. height: 42px;
  190. }
  191. }
  192. .routList {
  193. width: 160px;
  194. height: 336px;
  195. justify-content: space-between;
  196. display: flex;
  197. flex-direction: column;
  198. margin-top: 20px;
  199. .category {
  200. width: 100%;
  201. height: 36px;
  202. font-weight: 500;
  203. color: #636C97;
  204. letter-spacing: 1px;
  205. font-size: 16px;
  206. display: flex;
  207. box-sizing: border-box;
  208. align-items: center;
  209. padding-left: 16px;
  210. image {
  211. width: 18px;
  212. height: 18px;
  213. margin-right: 10px;
  214. }
  215. }
  216. .active {
  217. background-color: #2A3855;
  218. color: #91FDB9;
  219. border-radius: 4px;
  220. }
  221. }
  222. .fiexd_footer {
  223. position: fixed;
  224. bottom: 10px;
  225. left: 20px;
  226. }
  227. .left_footer {
  228. width: 160px;
  229. height: 120px;
  230. background-image: url(../../static/login_img/left_footer_bg.png);
  231. background-repeat: no-repeat;
  232. background-size: 100%;
  233. padding-top: 53px;
  234. position: relative;
  235. .box_click {
  236. position: absolute;
  237. // border: 1px solid red;
  238. width: 60px;
  239. height: 50px;
  240. top: 0px;
  241. left: 50px;
  242. }
  243. .left_footer_woring {
  244. position: absolute;
  245. min-width: 20px;
  246. min-height: 20px;
  247. background: #FF4D4F;
  248. font-size: 12px;
  249. font-family: PingFang SC-Semibold, PingFang SC;
  250. font-weight: 600;
  251. color: #FFFFFF;
  252. border-radius: 50%;
  253. text-align: center;
  254. line-height: 20px;
  255. right: 50px;
  256. top: 0px;
  257. }
  258. .left_footer_title {
  259. width: 100%;
  260. text-align: center;
  261. font-size: 12px;
  262. font-family: PingFang SC-Regular, PingFang SC;
  263. font-weight: 400;
  264. color: #636C97;
  265. line-height: 20px;
  266. }
  267. .left_footer_btn {
  268. width: 120px;
  269. height: 28px;
  270. background: #2A3855;
  271. border-radius: 6px 6px 6px 6px;
  272. color: #fff;
  273. text-align: center;
  274. line-height: 28px;
  275. margin-left: 20px;
  276. margin-top: 10px;
  277. font-size: 14px;
  278. .login_off {
  279. width: 14px;
  280. height: 14px;
  281. margin-left: 5px;
  282. vertical-align: middle;
  283. }
  284. }
  285. }
  286. }
  287. .station_box {
  288. width: 150px;
  289. // background: #1C263A;
  290. // border: 1px solid #26334C;
  291. font-size: 16px;
  292. font-weight: 500;
  293. color: rgba(153, 174, 197, 0.65);
  294. text-shadow: 0px 0px 4px rgba(39, 69, 201, 0.5);
  295. border-radius: 4px;
  296. margin-top: 10px;
  297. position: relative;
  298. .station_box_img {
  299. position: absolute;
  300. width: 20px;
  301. height: 20px;
  302. right: 20px;
  303. top: 3px;
  304. }
  305. }
  306. </style>