Header.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <div class="header_view">
  3. <div class="top_user">
  4. <div class="container">
  5. <div class="user">
  6. <span v-text="user ? user.vipName : '用户名'">用户名</span><span v-text="user ? user.spaceName : '公司名'">公司名</span>
  7. <a class="header-link" @click="logoutClick">退出</a>
  8. </div>
  9. </div>
  10. </div>
  11. <div class="header_time">
  12. <div class="container">
  13. <div class="tabs">
  14. <ul class="list-inline">
  15. <li :class="{active: linkTab === 'client'}" @click="hasClick('client')"><i class="iconfont icon-kehuzhongxin1"></i>客户中心</li>
  16. <li :class="{active: linkTab === 'sever'}" @click="hasClick('sever')"><i class="iconfont icon-ziyuan"></i>服务商中心</li>
  17. </ul>
  18. </div>
  19. <div class="info">
  20. <p><span v-text="user ? user.vipName : '用户名'">用户名</span>,欢迎使用晶琳报关系统 <strong>登陆时间 {{formatDate(user.lastLoginTime)}}</strong></p>
  21. <p>今天是 <b v-text="newTime"></b></p>
  22. </div>
  23. <div class="slide_info">
  24. <div class="mode">
  25. <ul class="list-inline" ref="slideInfo" :style="{left: leftSilide + 'px'}" :class="{no_transition: leftSilide === 600}">
  26. <li v-for="item in all"><span v-text="item.currencyName"></span>(<span v-text="item.currency"></span>)&nbsp;<span v-text="item.rate"></span></li>
  27. </ul>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. </template>
  34. <script>
  35. import {formatDate, showTime} from '@/utils/date'
  36. export default {
  37. name: 'ViewHeader',
  38. data () {
  39. return {
  40. linkTab: '',
  41. newTime: '',
  42. leftSilide: 100
  43. }
  44. },
  45. beforeMount () {
  46. let _this = this
  47. setInterval(function(){
  48. _this.stringTime()
  49. _this.leftSilide -= 5
  50. if (-(_this.widthSilde) > _this.leftSilide) {
  51. _this.leftSilide = 600
  52. }
  53. }, 100)
  54. },
  55. computed: {
  56. user () {
  57. return this.$store.state.option.user.data.content
  58. },
  59. all () {
  60. return this.$store.state.exchange.all.data.content
  61. },
  62. widthSilde () {
  63. return this.$refs.slideInfo.clientWidth
  64. }
  65. },
  66. mounted() {
  67. this.$route.path.indexOf('severPage') !== -1 ? this.linkTab = 'sever' : this.linkTab = 'client'
  68. },
  69. methods: {
  70. formatDate (type) {
  71. let date = new Date(type)
  72. return formatDate(date, 'hh:mm:ss')
  73. },
  74. stringTime () {
  75. return this.newTime = showTime()
  76. },
  77. hasClick: function (type) {
  78. this.linkTab = type
  79. this.$emit('hasEvent', type)
  80. if (type === 'client') {
  81. this.$router.push('/clientPage')
  82. } else {
  83. this.$router.push('/severPage')
  84. }
  85. },
  86. // 退出
  87. logoutClick () {
  88. this.$http.get('/logout')
  89. .then(response => {
  90. if (response.data.success) {
  91. this.$store.state.option.cookies = ''
  92. window.location.href = response.data.redirectUrl
  93. }
  94. })
  95. }
  96. }
  97. }
  98. </script>
  99. <style scoped type="text/scss" lang="scss">
  100. .header_view{
  101. margin-bottom:20px;
  102. .top_user{
  103. background: #0d5ffe;
  104. .user{
  105. text-align: right;
  106. height:100px;
  107. padding-top:40px;
  108. padding-right:20px;
  109. background:url(/img/banner.png)no-repeat;
  110. font-size:14px;
  111. color:#fff;
  112. span{
  113. margin-right:35px;
  114. }
  115. }
  116. }
  117. .header_time{
  118. position:relative;
  119. background: #fff;
  120. line-height: 30px;
  121. .tabs{
  122. position:absolute;
  123. top:-40px;
  124. left:50%;
  125. margin-left:-200px;
  126. ul{
  127. li{
  128. position:relative;
  129. left:-8px;
  130. height: 0;
  131. width: 200px;
  132. border-bottom: 40px solid #74a9fc;
  133. border-left: 10px solid transparent;
  134. border-right: 10px solid transparent;
  135. border-radius: 20px 20px 0 0 ;
  136. line-height: 40px;
  137. color:#c7ddfe;
  138. font-size: 16px;
  139. text-align: center;
  140. i{
  141. margin-right:15px;
  142. }
  143. &:first-child{
  144. left:0;
  145. }
  146. &.active,&:hover{
  147. cursor:pointer;
  148. border-bottom: 40px solid #fff;
  149. z-index:100;
  150. color:#0d5ffe;
  151. font-weight: bold;
  152. }
  153. }
  154. }
  155. }
  156. .slide_info{
  157. position:absolute;
  158. top:0;
  159. left:50%;
  160. width:600px;
  161. margin-left:-300px;
  162. background: #f4f7fe;
  163. border-radius:20px;
  164. overflow: hidden;
  165. .mode{
  166. position:relative;
  167. height:30px;
  168. line-height: 30px;
  169. ul{
  170. position:absolute;
  171. white-space:nowrap;
  172. &.no_transition{
  173. transition:none;
  174. }
  175. transition: .1s all linear;
  176. li{
  177. margin:0 10px;
  178. color:#fa6d48;
  179. }
  180. }
  181. }
  182. }
  183. .info{
  184. padding: 0 10px;
  185. p{
  186. display:inline-block;
  187. width:50%;
  188. margin:0;
  189. span{
  190. color:#0d5ffe;
  191. }
  192. strong{
  193. color:#666;
  194. font-weight: normal;
  195. }
  196. b{
  197. color:#f97f25;
  198. }
  199. &:last-child{
  200. text-align: right;
  201. }
  202. }
  203. }
  204. }
  205. }
  206. </style>