Navbar.vue 7.1 KB

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