Navbar.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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. uni.navigateTo({
  124. url: "../../pages/login/index"
  125. })
  126. //用户点击确认按钮触发
  127. } else if (res.cancel) {
  128. return
  129. //用户点击取消按钮触发
  130. }
  131. }
  132. })
  133. },
  134. //根据用户id得到用户信息
  135. getuserinfo() {
  136. let userId = this.$storage.getJson("userId")
  137. let token = this.$storage.getJson("token")
  138. let data = {
  139. id: userId
  140. }
  141. this.$http.getInfo(data).then(res => {
  142. if (res.code == 0) {
  143. this.userName = res.data.userAccount
  144. } else {
  145. this.ExchangeMessage('error', res.msg)
  146. }
  147. })
  148. },
  149. //顶部公共消息提示
  150. ExchangeMessage(type, message) {
  151. this.popupType = type
  152. this.popupMessage = message ? message : '后端接口404错误!'
  153. this.$refs.Exchangepopup.open()
  154. },
  155. //跳转到消防告警列表
  156. goTo() {
  157. this.getPage('故障告警')
  158. this.$storage.setJson('gotoname', 1) //存本地用于判断显示的告警页面
  159. },
  160. //当前实时消防告警数量
  161. getnum() {
  162. this.$http.getToDayAlarm().then(res => {
  163. if (res.code == 0) {
  164. this.alarmNum = res.data.length
  165. }
  166. });
  167. }
  168. },
  169. }
  170. </script>
  171. <style lang="scss" scoped>
  172. .navbar {
  173. height: 100vh;
  174. width: 180px;
  175. padding-right: 20px;
  176. box-sizing: border-box;
  177. display: flex;
  178. flex-direction: column;
  179. border-right: 1px solid rgba(255, 255, 255, 0.1);
  180. .logo {
  181. width: 150px;
  182. height: 42px;
  183. margin-top: 24px;
  184. image {
  185. width: 150px;
  186. height: 42px;
  187. }
  188. }
  189. .routList {
  190. width: 160px;
  191. height: 336px;
  192. justify-content: space-between;
  193. display: flex;
  194. flex-direction: column;
  195. margin-top: 20px;
  196. .category {
  197. width: 100%;
  198. height: 36px;
  199. font-weight: 500;
  200. color: #636C97;
  201. letter-spacing: 1px;
  202. font-size: 16px;
  203. display: flex;
  204. box-sizing: border-box;
  205. align-items: center;
  206. padding-left: 16px;
  207. image {
  208. width: 18px;
  209. height: 18px;
  210. margin-right: 10px;
  211. }
  212. }
  213. .active {
  214. background-color: #2A3855;
  215. color: #91FDB9;
  216. border-radius: 4px;
  217. }
  218. }
  219. .fiexd_footer {
  220. position: fixed;
  221. bottom: 10px;
  222. left: 20px;
  223. }
  224. .left_footer {
  225. width: 160px;
  226. height: 120px;
  227. background-image: url(../../static/login_img/left_footer_bg.png);
  228. background-repeat: no-repeat;
  229. background-size: 100%;
  230. padding-top: 53px;
  231. position: relative;
  232. .box_click {
  233. position: absolute;
  234. // border: 1px solid red;
  235. width: 60px;
  236. height: 50px;
  237. top: 0px;
  238. left: 50px;
  239. }
  240. .left_footer_woring {
  241. position: absolute;
  242. min-width: 20px;
  243. min-height: 20px;
  244. background: #FF4D4F;
  245. font-size: 12px;
  246. font-family: PingFang SC-Semibold, PingFang SC;
  247. font-weight: 600;
  248. color: #FFFFFF;
  249. border-radius: 50%;
  250. text-align: center;
  251. line-height: 20px;
  252. right: 50px;
  253. top: 0px;
  254. }
  255. .left_footer_title {
  256. width: 100%;
  257. text-align: center;
  258. font-size: 12px;
  259. font-family: PingFang SC-Regular, PingFang SC;
  260. font-weight: 400;
  261. color: #636C97;
  262. line-height: 20px;
  263. }
  264. .left_footer_btn {
  265. width: 120px;
  266. height: 28px;
  267. background: #2A3855;
  268. border-radius: 6px 6px 6px 6px;
  269. color: #fff;
  270. text-align: center;
  271. line-height: 28px;
  272. margin-left: 20px;
  273. margin-top: 10px;
  274. font-size: 14px;
  275. .login_off {
  276. width: 14px;
  277. height: 14px;
  278. margin-left: 5px;
  279. vertical-align: middle;
  280. }
  281. }
  282. }
  283. }
  284. .station_box {
  285. width: 150px;
  286. // background: #1C263A;
  287. // border: 1px solid #26334C;
  288. font-size: 16px;
  289. font-weight: 500;
  290. color: rgba(153, 174, 197, 0.65);
  291. text-shadow: 0px 0px 4px rgba(39, 69, 201, 0.5);
  292. border-radius: 4px;
  293. margin-top: 10px;
  294. position: relative;
  295. .station_box_img {
  296. position: absolute;
  297. width: 20px;
  298. height: 20px;
  299. right: 20px;
  300. top: 3px;
  301. }
  302. }
  303. </style>