userHeader.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <div class="user-contentCompontent">
  3. <div class="user-name">
  4. <img src="/images/component/default.png"/>
  5. <div class="user-info">
  6. <p v-text="userInfo.data.userName"></p>
  7. <p>
  8. <span class="en-name">{{enterpriseInfo.enName}}</span>
  9. <a @click="setShowEnterpriseToggle(!showEnterpriseToggle, $event)">切换</a>
  10. <span class="vir">|</span>
  11. <a class="exit" @click="showLogout = true">退出</a>
  12. </p>
  13. <ul class="en-list" v-show="showEnterpriseToggle">
  14. <li class="menu-item"
  15. v-for="en in sortEnterprises"
  16. v-if="en.uu != enterpriseInfo.uu"
  17. v-bind:key="en.uu">
  18. <a @click="switchEnterprise(en)">{{ en.enName }}</a>
  19. </li>
  20. <li class="menu-item" v-if="enterpriseInfo.uu">
  21. <a @click="switchEnterprise({uu: 0})"><span v-text="userInfo.data.userName"></span>(个人账户)</a>
  22. </li>
  23. </ul>
  24. </div>
  25. </div>
  26. <div class="deleteKuang" v-if="showLogout">
  27. <div class="kuangContent">
  28. <div class="title">系统提示</div>
  29. <div class="titleinfo">是否退出登录</div>
  30. <!--<div class="info" v-show="isUploadpro">*存在已上架信息</div>-->
  31. <div class="K_btn">
  32. <div class="cancelBtn" @click="showLogout = false">取消</div>
  33. <div class="answerBtn" @click="logout()">确定</div>
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. </template>
  39. <script>
  40. export default {
  41. data () {
  42. return {
  43. showEnterpriseToggle: false,
  44. showLogout: false // 退出登录提示框
  45. }
  46. },
  47. methods: {
  48. // 切换当前企业
  49. switchEnterprise(en) {
  50. this.showEnterpriseToggle = false
  51. this.$http.get(`/user/authentication/${en.uu}`).then(() => {
  52. this.$store.dispatch('loadUserInfo')
  53. })
  54. },
  55. setShowEnterpriseToggle(flag, e) {
  56. if (e) {
  57. e.stopPropagation()
  58. }
  59. this.showEnterpriseToggle = flag
  60. },
  61. logout () {
  62. this.$http.get('/logout/crossBefore', {params: {returnUrl: window.location.protocol + '//' + window.location.host}}).then(response => {
  63. if (response.data) {
  64. window.location.href = response.data.logoutUrl + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
  65. }
  66. })
  67. }
  68. },
  69. computed: {
  70. userInfo () {
  71. return this.$store.state.option.user
  72. },
  73. enterpriseInfo () {
  74. if (this.userInfo.data.enterprises) {
  75. let ens = this.userInfo.data.enterprises.slice()
  76. if (ens && ens.length) {
  77. for (let i = 0; i < ens.length; i++) {
  78. if (ens[i].current) {
  79. return ens[i]
  80. }
  81. }
  82. }
  83. return {enName: this.userInfo.data.userName + '(个人账户)'}
  84. } else {
  85. return ''
  86. }
  87. },
  88. sortEnterprises () {
  89. if (this.user.data.enterprises) {
  90. let ens = this.user.data.enterprises.slice()
  91. if (ens && ens.length) {
  92. ens.sort(function (a, b) {
  93. return b.lastLoginTime - a.lastLoginTime
  94. })
  95. }
  96. return ens
  97. } else {
  98. return ''
  99. }
  100. }
  101. }
  102. }
  103. </script>
  104. <style lang="scss">
  105. .user-contentCompontent{
  106. .user-name{
  107. height: 1.8rem;
  108. padding: .28rem 0 .28rem .34rem;
  109. background: #fff;
  110. width: 100%;
  111. position: relative;
  112. img{
  113. display: inline-block;
  114. width: 1.25rem;
  115. height: 1.25rem;
  116. border: 1px solid #c5dbfc;
  117. border-radius: .05rem;
  118. vertical-align: middle;
  119. }
  120. .user-info {
  121. margin-left:.25rem;
  122. display: inline-block;
  123. vertical-align: middle;
  124. position: relative;
  125. p{
  126. font-size:.3rem;
  127. margin:0;
  128. display: block;
  129. overflow: hidden;
  130. text-overflow: ellipsis;
  131. white-space: nowrap;
  132. max-width: 3.92rem;
  133. &:nth-child(2) {
  134. position: relative;
  135. margin-top: .2rem;
  136. padding-right: .7rem;
  137. overflow: unset;
  138. max-width: unset;
  139. .en-name {
  140. overflow: hidden;
  141. text-overflow: ellipsis;
  142. white-space: nowrap;
  143. max-width: 3.22rem;
  144. display: inline-block;
  145. }
  146. a {
  147. position: absolute;
  148. right: 0;
  149. }
  150. .exit {
  151. right: -.8rem;
  152. }
  153. .vir {
  154. position: absolute;
  155. right: -.14rem;
  156. }
  157. }
  158. }
  159. .en-list {
  160. position: absolute;
  161. max-width: 5rem;
  162. max-height: 3rem;
  163. overflow-y: auto;
  164. border-radius: .05rem;
  165. background: rgba(0, 0, 0, .6);
  166. z-index: 10;
  167. .menu-item {
  168. height: .6rem;
  169. line-height: .6rem;
  170. font-size: .3rem;
  171. padding: 0 .2rem;
  172. overflow: hidden;
  173. white-space: nowrap;
  174. text-overflow: ellipsis;
  175. &:active, &:focus, &:hover {
  176. background: #7d7d7d;
  177. }
  178. a {
  179. color: #fff;
  180. }
  181. }
  182. }
  183. }
  184. > a {
  185. font-size: .24rem;
  186. position: absolute;
  187. top: .45rem;
  188. right: .1rem;
  189. color: #3f84f6;
  190. border: 1px solid #3f84f6;
  191. border-radius: .2rem;
  192. padding: .06rem .12rem;
  193. }
  194. }
  195. ul.switch-list {
  196. li {
  197. display: inline-block;
  198. width: 50%;
  199. height: .63rem;
  200. line-height: .63rem;
  201. text-align: center;
  202. font-size: .28rem;
  203. color: #666;
  204. background: #fff;
  205. border: 1px solid #b4b4b4;
  206. border-right: none;
  207. &.active {
  208. background: #0067e7;
  209. border: 1px solid #0067e7;
  210. color: #fff;
  211. }
  212. &:first-child {
  213. border-left: none;
  214. }
  215. &:last-child {
  216. border-right: none;
  217. }
  218. }
  219. &.vendor-switch {
  220. li {
  221. width: 50%;
  222. }
  223. }
  224. }
  225. .seek {
  226. .seek-type {
  227. margin-top: .15rem;
  228. li {
  229. font-size: .28rem;
  230. color: #666;
  231. display: inline-block;
  232. width: 50%;
  233. text-align: center;
  234. div {
  235. border-bottom: 1px solid #c1c4c9;
  236. margin: 0 auto;
  237. height: .46rem;
  238. line-height: .46rem;
  239. }
  240. &.active {
  241. color: #3f84f6;
  242. div {
  243. border-color: #3f84f6;
  244. }
  245. }
  246. }
  247. }
  248. }
  249. .deleteKuang {
  250. position: fixed;
  251. background: rgba(0,0,0,0.5);
  252. top: 0;
  253. left: 0;
  254. right: 0;
  255. bottom: 0;
  256. z-index: 9999;
  257. .kuangContent {
  258. border-radius: 5px;
  259. background: #fff;
  260. width: 5rem;
  261. position: absolute;
  262. left: 50%;
  263. top: 50%;
  264. transform: translate3d(-50%, -50%, 0);
  265. overflow: hidden;
  266. .titleinfo {
  267. font-size: .3rem;
  268. color: #666;
  269. text-align: center;
  270. margin-top: 0.5rem;
  271. margin-bottom: 0.1rem;
  272. }
  273. .title {
  274. background: #5078cb;
  275. height: .7rem;
  276. line-height: .7rem;
  277. font-size: .3rem;
  278. color: #fff;
  279. text-align: center;
  280. }
  281. .info {
  282. color: #f00;
  283. text-align: center;
  284. }
  285. .K_btn {
  286. margin-top: 0.4rem;
  287. line-height: 0.7rem;
  288. height: 0.7rem;
  289. &::after{
  290. clear: both;
  291. display: block;
  292. content: ' ';
  293. visibility: hidden;
  294. zoom: 1;
  295. }
  296. div {
  297. float: left;
  298. width: 50%;
  299. font-size: 0.3rem;
  300. text-align: center;
  301. &.cancelBtn {
  302. background: #b4b5b9;
  303. color: #333;
  304. }
  305. &.answerBtn {
  306. background: #5078cb;
  307. color: #fff;
  308. }
  309. }
  310. }
  311. }
  312. }
  313. }
  314. </style>