TopBar.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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 rolesList" :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. list: [],
  67. show: false,
  68. info: '',
  69. active: this.defaultActive,
  70. rolesList: [],
  71. color: '#ecf9ff',
  72. background: 'rgba(78,162,248,0.63)'
  73. }
  74. },
  75. computed: {
  76. ...mapGetters(['userName', 'orgName', 'orgId'])
  77. },
  78. created() {},
  79. mounted() {
  80. setTimeout(() => {
  81. if(this.orgId){
  82. this.getTheWeather()
  83. }
  84. }, 100);
  85. // this.rolesList=JSON.parse(window.sessionStorage.getItem('SET_USER_ROLELIST'))||[]
  86. },
  87. methods: {
  88. onChange(index){
  89. let alarmLevel = this.list[index].alarmLevel;
  90. switch (alarmLevel){
  91. case '蓝色':
  92. this.background = 'rgba(78,162,248,0.62)';
  93. //this.color = '#fff';
  94. break;
  95. case '黄色':
  96. this.background = 'rgba(238,227,103,0.63)';
  97. //this.color = '#fff';
  98. break;
  99. case '橙色':
  100. this.background = 'rgba(246,181,104,0.62)';
  101. //this.color = '#fff';
  102. break;
  103. case '红色':
  104. this.background = 'rgba(239,70,74,0.65)';
  105. //this.color = '#fff';
  106. }
  107. },
  108. clickOutLogin() {
  109. logout().then(res => {
  110. sessionStorage.clear()
  111. this.$router.replace('/login')
  112. this.$toast('退出登录')
  113. })
  114. },
  115. clickHandler(item) {
  116. console.log(item,'1111111')
  117. this.info = item.alarmContent
  118. this.show = true
  119. },
  120. //获取天气数据
  121. getTheWeather() {
  122. getTheAreaWeather(this.orgId).then(res => {
  123. this.list = res.data || [];
  124. setTimeout(() => {
  125. this.rolesList = JSON.parse(window.sessionStorage.getItem('SET_USER_ROLELIST')) || []
  126. }, 100)
  127. console.log(this.rolesList)
  128. })
  129. }
  130. }
  131. }
  132. </script>
  133. <style lang="scss">
  134. .van-notice-bar{
  135. line-height:60px;
  136. height: 60px;
  137. }
  138. .notice-swipe {
  139. height: 30px;
  140. line-height: 30px;
  141. }
  142. .van-swipe-item{
  143. text-shadow: 0 0 3px #888;
  144. }
  145. </style>
  146. <style scoped lang="scss">
  147. .top-bar-box{
  148. position: relative;
  149. }
  150. .top-bar {
  151. height: 300px;
  152. width: 100%;
  153. background: url('../assets/img/banner.png') no-repeat center rgba(255,255,255,.1);
  154. background-size: 100% 100%;
  155. padding: 40px 40px 20px 40px;
  156. text-shadow: 0 1px 3px #666;
  157. box-shadow: 0 1px 8px #ccc;
  158. color: #fff;
  159. > div {
  160. width: 100%;
  161. }
  162. }
  163. .top-box {
  164. display: flex;
  165. justify-content: space-between;
  166. align-items: center;
  167. > span {
  168. font-size: 40px;
  169. }
  170. }
  171. .notice-box{
  172. width: 100%;
  173. position: absolute;
  174. bottom: -80;
  175. z-index: 1000;
  176. }
  177. .bottom-box {
  178. padding-top: 30px;
  179. > div {
  180. .user-name {
  181. font-size: 30px;
  182. margin-bottom: 10px;
  183. }
  184. .org-info{
  185. font-size: 28px;
  186. display: flex;
  187. justify-content: space-between;
  188. }
  189. .introduce-info {
  190. font-size: 24px;
  191. line-height: 34px;
  192. >span{
  193. display: inline-block;
  194. margin-right: 20px;
  195. }
  196. }
  197. }
  198. }
  199. </style>