userHeader.vue 8.3 KB

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