Header.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. <template>
  2. <header class="header">
  3. <!--<div class="apply-adv" v-if="isShowApplyAdv">-->
  4. <!--<a href="/applyPurchase#opportunities">-->
  5. <!--<img src="/images/applyPurchase/apply-top-ad.jpg" alt="">-->
  6. <!--</a>-->
  7. <!--<i @click="ShowApplyAdv = false"></i>-->
  8. <!--</div>-->
  9. <nav class="navbar">
  10. <div class="navbar-container container">
  11. <div class="navbar-header">
  12. <a href="http://www.ubtob.com" class="item navbar-link">
  13. <img src="/images/logo/uas.png" class="navbar-logo">
  14. <span class="navbar-slogan">进入优软云</span>
  15. </a>
  16. </div>
  17. <div class="navbar-right">
  18. <template v-if="user.logged">
  19. <div class="item-wrap dropdown">
  20. <div class="item dropdown-toggle">
  21. 欢迎您,{{ user.data.userName }}&nbsp;|&nbsp;
  22. <a @click="logout()">[退出]</a>
  23. <span>{{enterprise.enName}}</span>
  24. </div>
  25. <div class="dropdown-menu" v-if="user.data.enterprises && user.data.enterprises.length > 0">
  26. <div class="menu-item-first">
  27. <span>您可切换至以下账户:</span>
  28. </div>
  29. <ul>
  30. <!-- <li class="menu-item-first">
  31. <span class="member-text" :title="enterprise.enName"><i class="fa fa-map-marker"></i>&nbsp;{{ enterprise.uu?enterprise.enName: user.data.userName + '(个人账户)' }}</span>
  32. <a class="pull-right" @click="toggleEnterprises()" v-if="user.data.enterprises && user.data.enterprises.length > 0">
  33. {{ showEnterprises ? '取消' : '切换' }}
  34. </a>
  35. <span>您可切换至以下账户:</span>
  36. <input type="text" placeholder="请输入公司名称" v-model="keyword"><span class="search-enterprise" @click="searchEnterprise()">搜索</span>
  37. </li>-->
  38. <li class="menu-item"
  39. v-for="en in sortEnterprises"
  40. v-if="en.uu!=enterprise.uu">
  41. <a @click="switchEnterprise(en)" :title="en.enName">{{ en.enName }}</a>
  42. </li>
  43. <li class="menu-item" v-if="enterprise.uu">
  44. <a @click="switchEnterprise({uu: 0})"><span v-text="user.data.userName"></span>(个人账户)</a>
  45. </li>
  46. </ul>
  47. </div>
  48. </div>
  49. <nuxt-link class="item" :to="'/'">商城首页</nuxt-link>
  50. <!--<nuxt-link class="item" to="/user">买家中心</nuxt-link>
  51. <nuxt-link class="item" to="/vendor">卖家中心</nuxt-link>-->
  52. <!--<a class="item" :href="url + '/user'">买家中心</a>
  53. <a class="item" :href="url + '/vendor'">卖家中心</a>-->
  54. <a class="item" href="/user#/index">买家中心</a>
  55. <a class="item" @click="toVendor">卖家中心</a>
  56. <a class="item" href="/sso#/index">帐户中心</a>
  57. </template>
  58. <template v-else>
  59. <a class="item" @click="onLoginClick()">登录</a>
  60. <a class="item" @click="onRegisterClick">注册</a>
  61. <nuxt-link class="item" :to="'/'">商城首页</nuxt-link>
  62. </template>
  63. <nuxt-link class="item" to="/help/home" target="_blank">帮助中心</nuxt-link>
  64. <!--<a class="item" href="/help#/home">帮助中心</a>-->
  65. </div>
  66. </div>
  67. </nav>
  68. </header>
  69. </template>
  70. <script>
  71. export default {
  72. name: 'headerView',
  73. data () {
  74. return {
  75. // showEnterprises: false
  76. // searchEnterpriseArr: [],
  77. // keyword: '',
  78. // isSearching: false
  79. // ShowApplyAdv: true,
  80. showEnterpriseToggle: false
  81. }
  82. },
  83. computed: {
  84. // isShowApplyAdv () {
  85. // if (this.$route.path.indexOf('/applyPurchase') === -1) {
  86. // this.ShowApplyAdv = true
  87. // }
  88. // return this.ShowApplyAdv && this.$route.path.indexOf('/applyPurchase') !== -1
  89. // },
  90. user () {
  91. // console.log(this.$store.state.option.user)
  92. return this.$store.state.option.user
  93. },
  94. enterprise () {
  95. return this.user.data.enterprise || {}
  96. },
  97. url () {
  98. return this.$store.state.option.url
  99. }
  100. },
  101. methods: {
  102. logout () {
  103. this.$http.get('/logout/crossBefore').then(response => {
  104. if (response.data) {
  105. window.location.href = response.data.logoutUrl + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
  106. }
  107. })
  108. },
  109. onLoginClick () {
  110. this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
  111. if (response.data) {
  112. window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
  113. }
  114. })
  115. // TODO 待Account Center改版
  116. },
  117. onRegisterClick () {
  118. this.$http.get('/register/page').then(response => {
  119. if (response.data) {
  120. window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + '/newLogin/other')
  121. }
  122. })
  123. },
  124. // 切换当前企业
  125. switchEnterprise (en) {
  126. this.showEnterpriseToggle = false
  127. this.$http.get(`/user/authentication/${en.uu}`).then(() => {
  128. this.$store.dispatch('loadUserInfo')
  129. // let path = this.$route.path
  130. // if (path === '/register-saler' && en.uu !== 0 && en.isVendor === 313) {
  131. // window.location.href = '/vendor#/index'
  132. // } else {
  133. // window.location.reload()
  134. // }
  135. window.location.href = '/'
  136. })
  137. // 切换帐套用
  138. this.$jsonp(`${process.env.ssoUrl}/sso/login/change/userspace?spaceUU=${en.uu}`, {timeout: 5000, name: 'successCallback'}, (err) => {
  139. console.log(err)
  140. })
  141. },
  142. toVendor: function () {
  143. let isSelf = true
  144. let tempEnterprise = {}
  145. let ens = this.user.data.enterprises
  146. if (ens && ens.length) {
  147. ens.forEach(function (item) {
  148. if (item.current) {
  149. isSelf = false
  150. tempEnterprise = item
  151. }
  152. })
  153. } else {
  154. isSelf = true
  155. }
  156. if (isSelf) {
  157. window.location.href = '/personalMaterial'
  158. } else {
  159. if (tempEnterprise.isVendor === 313) {
  160. // window.location.href = '/vendor'
  161. window.location.href = '/vendor#/index'
  162. } else {
  163. window.location.href = '/register-saler'
  164. }
  165. }
  166. }
  167. // searchEnterprise () {
  168. // let key = this.keyword
  169. // let enterprise = this.user.data.enterprises
  170. // this.isSearching = true
  171. // this.searchEnterpriseArr = []
  172. // if (this.keyword === '') {
  173. // this.isSearching = false
  174. // } else {
  175. // for (let i = 0; i < enterprise.length; i++) {
  176. // if (enterprise[i].enName.indexOf(key) !== -1) {
  177. // this.searchEnterpriseArr.push(enterprise[i])
  178. // }
  179. // }
  180. // }
  181. // }
  182. }
  183. }
  184. </script>
  185. <style lang="scss" scoped>
  186. .header .navbar{
  187. min-height: inherit;
  188. border-radius: 0;
  189. }
  190. .header .navbar .navbar-container .navbar-right .dropdown .dropdown-menu li span,.header .navbar .navbar-container .navbar-right .dropdown .dropdown-menu li a{
  191. font-size: 12px;
  192. }
  193. .header .navbar .navbar-container .navbar-right .dropdown .dropdown-menu .menu-item a{
  194. width: 100%;
  195. display: inline-block;
  196. overflow: hidden;
  197. text-overflow: ellipsis;
  198. white-space: nowrap;
  199. height: 25px;
  200. }
  201. .header .navbar .navbar-container .navbar-right .dropdown .dropdown-menu .menu-item{
  202. height: 30px;
  203. }
  204. .apply-adv{
  205. margin: 0 auto;
  206. min-width: 1190px;
  207. position: relative;
  208. img{
  209. max-width: 100%;
  210. min-width: 1190px;
  211. }
  212. i {
  213. background: url("/images/search/search-close.png")no-repeat;
  214. width: 16px;
  215. height: 16px;
  216. position: absolute;
  217. right: 8px;
  218. top: 8px;
  219. cursor: pointer;
  220. z-index: 20000;
  221. }
  222. }
  223. .dropdown-menu>li>a{
  224. padding: 0;
  225. line-height: 30px;
  226. }
  227. .dropdown-menu>li a:hover{
  228. background: none;
  229. text-decoration: underline !important;
  230. }
  231. .dropdown-menu>li>a.pull-right{
  232. padding: 0;
  233. color: #1162a4 !important;
  234. line-height: inherit;
  235. }
  236. .member-text{
  237. width: 80%;
  238. white-space: nowrap;
  239. overflow: hidden;
  240. text-overflow: ellipsis;
  241. display: inline-block;
  242. }
  243. @import '~assets/scss/mixins';
  244. @import '~assets/scss/variables';
  245. $nav-height: 38px;
  246. .header {
  247. /* height: $nav-height;*/
  248. .navbar {
  249. width: 100%;
  250. height: 100%;
  251. font-size: $font-size-small;
  252. background-color: $black-light;
  253. .navbar-container {
  254. .item-wrap {
  255. display: inline-block;
  256. }
  257. .item {
  258. color: $grey;
  259. display: inline-block;
  260. height: 35px;
  261. line-height: 35px;
  262. }
  263. a {
  264. color: $grey;
  265. }
  266. .navbar-header {
  267. float: left;
  268. .navbar-logo {
  269. margin-bottom: 2px;
  270. }
  271. .navbar-slogan {
  272. margin-left: $sm-pad;
  273. }
  274. }
  275. .navbar-right {
  276. float: right;
  277. .item {
  278. padding: 0 $pad;
  279. }
  280. .dropdown {
  281. .dropdown-toggle {
  282. line-height: $nav-height;
  283. border-left: 1px solid $black-light;
  284. border-right: 1px solid $black-light;
  285. height: 35px;
  286. a {
  287. margin-left: 15px;
  288. float: right;
  289. &:hover {
  290. color: $red !important;
  291. }
  292. }
  293. &:hover {
  294. border-left: 1px solid #999;
  295. border-right: 1px solid #999;
  296. }
  297. span {
  298. display: inline-block;
  299. max-width: 190px;
  300. overflow: hidden;
  301. text-overflow: ellipsis;
  302. white-space: nowrap;
  303. float: right;
  304. }
  305. }
  306. .menu-item-first {
  307. background: #eee;
  308. padding: 0 12px;
  309. line-height: 30px;
  310. font-size: 12px;
  311. >span:nth-child(1) {
  312. cursor: default;
  313. font-weight: bold;
  314. }
  315. input {
  316. width: 174px;
  317. height: 24px;
  318. margin-left: 35px;
  319. background: #fff;
  320. border: 1px solid #5078cb;
  321. padding-left: 4px;
  322. }
  323. .search-enterprise {
  324. display: inline-block;
  325. width: 36px;
  326. height: 24px;
  327. color: #fff;
  328. background: #5078cb;
  329. text-align: center;
  330. line-height: 24px;
  331. cursor: pointer;
  332. }
  333. }
  334. .dropdown-menu {
  335. padding: 0 6px 13px;
  336. margin:0;
  337. border-radius: 0;
  338. right: unset;
  339. background: #fff;
  340. border: 1px solid #999999;
  341. border-top: none;
  342. -webkit-box-shadow: none;
  343. -moz-box-shadow: none;
  344. box-shadow: none;
  345. ::-webkit-scrollbar {
  346. background: #f6f6f6;
  347. }
  348. ul {
  349. max-height: 300px;
  350. overflow-y: auto;
  351. background: #f6f6f6;
  352. }
  353. .menu-item {
  354. padding: 0 12px;
  355. a {
  356. color: #333;
  357. max-width: 300px;
  358. line-height: 30px;
  359. width: auto;
  360. &:hover {
  361. color: #5078cb;
  362. text-decoration: none!important;
  363. }
  364. }
  365. }
  366. }
  367. &:hover {
  368. background-color: $white;
  369. .dropdown-toggle {
  370. color: $text;
  371. }
  372. a {
  373. color: $text
  374. }
  375. }
  376. }
  377. }
  378. }
  379. }
  380. }
  381. </style>