TopBar.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <div class="top-bar-box">
  3. <div class="top-bar">
  4. <div class="top-box">
  5. <span>移动安全保卫管理平台</span>
  6. <van-icon name="setting-o" size="26" @click="clickOutLogin" />
  7. </div>
  8. <div class="bottom-box">
  9. <div>
  10. <p class="user-name">{{ userName }}</p>
  11. <p class="org-info">
  12. <span>{{ orgName }}</span>
  13. <van-icon name="arrow" size="20" />
  14. </p>
  15. <p class="van-multi-ellipsis--l2 introduce-info ">
  16. <span v-for="item in roleList" :key="item.roleId">{{ item.roleName }}</span>
  17. </p>
  18. </div>
  19. </div>
  20. </div>
  21. <div v-if="showNotice" class="notice-box">
  22. <div>
  23. <van-notice-bar v-if="list.length>0" left-icon="volume-o" mode="closeable" :color="color" :background="background">
  24. <van-swipe
  25. @change="onChange"
  26. vertical
  27. class="notice-swipe"
  28. :autoplay="8000"
  29. :show-indicators="false">
  30. <van-swipe-item v-for="item in list" :key="item.id" @click="clickHandler(item)" >
  31. {{item.alarmTitle}}
  32. </van-swipe-item>
  33. </van-swipe>
  34. </van-notice-bar>
  35. </div>
  36. </div>
  37. <!-- &lt;!&ndash; 天气预警 &ndash;&gt;-->
  38. <!-- <van-swipe v-if="list.length > 0" style="height: 50px" vertical autoplay="2000">-->
  39. <!-- <van-swipe-item v-for="item in list" :key="item.id" @click="clickHandler(item)">-->
  40. <!-- <div class="color" :style="{ color: item.bgc, backgroundColor: '#fff' }">-->
  41. <!-- <van-icon name="warn-o" /> {{ item.alarmTitle }}-->
  42. <!-- </div>-->
  43. <!-- </van-swipe-item>-->
  44. <!-- <template #indicator>-->
  45. <!-- <div class="custom-indicator"></div>-->
  46. <!-- </template>-->
  47. <!-- </van-swipe>-->
  48. </div>
  49. </template>
  50. <script>
  51. import { Icon } from 'vant'
  52. import { mapGetters } from 'vuex'
  53. import { logout, getTheAreaWeather } from '@/api/public'
  54. export default {
  55. components: {
  56. [Icon.name]: Icon
  57. },
  58. props:{
  59. showNotice:{
  60. type:Boolean,
  61. default:true
  62. },
  63. },
  64. data() {
  65. return {
  66. show: false,
  67. info: '',
  68. active: this.defaultActive,
  69. color: '#ecf9ff',
  70. background: 'rgba(78,162,248,0.63)'
  71. }
  72. },
  73. computed: {
  74. ...mapGetters(['userName', 'orgName','roleList', 'orgId']),
  75. //获取天气数据
  76. list() {
  77. if(!this.orgId)return [];
  78. let lists = [];
  79. getTheAreaWeather(this.orgId).then(res => {
  80. lists = res.data
  81. })
  82. return lists;
  83. }
  84. },
  85. methods: {
  86. onChange(index){
  87. let alarmLevel = this.list[index].alarmLevel;
  88. switch (alarmLevel){
  89. case '蓝色':
  90. this.background = 'rgba(78,162,248,0.62)';
  91. //this.color = '#fff';
  92. break;
  93. case '黄色':
  94. this.background = 'rgba(238,227,103,0.63)';
  95. //this.color = '#fff';
  96. break;
  97. case '橙色':
  98. this.background = 'rgba(246,181,104,0.62)';
  99. //this.color = '#fff';
  100. break;
  101. case '红色':
  102. this.background = 'rgba(239,70,74,0.65)';
  103. //this.color = '#fff';
  104. }
  105. },
  106. clickOutLogin() {
  107. logout().then(res => {
  108. sessionStorage.clear()
  109. this.$router.replace('/login')
  110. this.$toast('退出登录')
  111. })
  112. },
  113. clickHandler(item) {
  114. console.log(item,'1111111')
  115. this.info = item.alarmContent
  116. this.show = true
  117. },
  118. }
  119. }
  120. </script>
  121. <style lang="scss">
  122. .van-notice-bar{
  123. line-height:60px;
  124. height: 60px;
  125. }
  126. .notice-swipe {
  127. height: 30px;
  128. line-height: 30px;
  129. }
  130. .van-swipe-item{
  131. text-shadow: 0 0 3px #888;
  132. }
  133. </style>
  134. <style scoped lang="scss">
  135. .top-bar-box{
  136. position: relative;
  137. }
  138. .top-bar {
  139. height: 300px;
  140. width: 100%;
  141. background: url('../assets/img/banner.png') no-repeat center rgba(255,255,255,.1);
  142. background-size: 100% 100%;
  143. padding: 40px 40px 20px 40px;
  144. text-shadow: 0 1px 3px #666;
  145. box-shadow: 0 1px 10px #5ebaee;
  146. color: #fff;
  147. > div {
  148. width: 100%;
  149. }
  150. }
  151. .top-box {
  152. display: flex;
  153. justify-content: space-between;
  154. align-items: center;
  155. > span {
  156. font-size: 40px;
  157. }
  158. }
  159. .notice-box{
  160. width: 100%;
  161. position: absolute;
  162. bottom: -80;
  163. z-index: 1000;
  164. }
  165. .bottom-box {
  166. padding-top: 30px;
  167. > div {
  168. .user-name {
  169. font-size: 30px;
  170. margin-bottom: 10px;
  171. }
  172. .org-info{
  173. font-size: 28px;
  174. display: flex;
  175. justify-content: space-between;
  176. }
  177. .introduce-info {
  178. font-size: 24px;
  179. line-height: 34px;
  180. >span{
  181. display: inline-block;
  182. margin-right: 20px;
  183. }
  184. }
  185. }
  186. }
  187. </style>