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