123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428 |
- <template>
- <header class="header">
- <!--<div class="apply-adv" v-if="isShowApplyAdv">-->
- <!--<a href="/applyPurchase#opportunities">-->
- <!--<img src="/images/applyPurchase/apply-top-ad.jpg" alt="">-->
- <!--</a>-->
- <!--<i @click="ShowApplyAdv = false"></i>-->
- <!--</div>-->
- <nav class="navbar">
- <div class="navbar-container container">
- <div class="navbar-header">
- <a href="http://www.usoftchina.com" class="item navbar-link">
- <img src="/images/logo/uas.png" class="navbar-logo">
- <span class="navbar-slogan">进入优软云</span>
- </a>
- </div>
- <div class="navbar-right">
- <template v-if="user.logged">
- <div class="item-wrap dropdown">
- <div class="item dropdown-toggle">
- 欢迎您,{{ user.data.userName }} |
- <a @click="logout()">[退出]</a>
- <span>{{enterprise.enName}}</span>
- </div>
- <div class="dropdown-menu" v-if="user.data.enterprises && user.data.enterprises.length > 0">
- <div class="menu-item-first">
- <span>您可切换至以下账户:</span>
- </div>
- <ul>
- <!-- <li class="menu-item-first">
- <span class="member-text" :title="enterprise.enName"><i class="fa fa-map-marker"></i> {{ enterprise.uu?enterprise.enName: user.data.userName + '(个人账户)' }}</span>
- <a class="pull-right" @click="toggleEnterprises()" v-if="user.data.enterprises && user.data.enterprises.length > 0">
- {{ showEnterprises ? '取消' : '切换' }}
- </a>
- <span>您可切换至以下账户:</span>
- <input type="text" placeholder="请输入公司名称" v-model="keyword"><span class="search-enterprise" @click="searchEnterprise()">搜索</span>
- </li>-->
- <li class="menu-item"
- v-for="en in sortEnterprises"
- v-if="en.uu!=enterprise.uu">
- <a @click="switchEnterprise(en)" :title="en.enName">{{ en.enName }}</a>
- </li>
- <li class="menu-item" v-if="enterprise.uu">
- <a @click="switchEnterprise({uu: 0})"><span v-text="user.data.userName"></span>(个人账户)</a>
- </li>
- </ul>
- </div>
- </div>
- <nuxt-link class="item" :to="'/'">商城首页</nuxt-link>
- <!--<nuxt-link class="item" to="/user">买家中心</nuxt-link>
- <nuxt-link class="item" to="/vendor">卖家中心</nuxt-link>-->
- <!--<a class="item" :href="url + '/user'">买家中心</a>
- <a class="item" :href="url + '/vendor'">卖家中心</a>-->
- <a class="item" href="/user#/index">买家中心</a>
- <a class="item" @click="toVendor">卖家中心</a>
- <a class="item" href="/sso#/index">帐户中心</a>
- <a class="item" href="/user#/messagePersonal">消息 ({{count}})</a>
- </template>
- <template v-else>
- <a class="item" @click="onLoginClick()">登录</a>
- <a class="item" @click="onRegisterClick">注册</a>
- <nuxt-link class="item" :to="'/'">商城首页</nuxt-link>
- </template>
- <nuxt-link class="item" to="/help/home" target="_blank">帮助中心</nuxt-link>
- <!--<a class="item" href="/help#/home">帮助中心</a>-->
- </div>
- </div>
- </nav>
- </header>
- </template>
- <script>
- export default {
- name: 'headerView',
- data () {
- return {
- // showEnterprises: false
- // searchEnterpriseArr: [],
- // keyword: '',
- // isSearching: false
- // ShowApplyAdv: true,
- showEnterpriseToggle: false,
- messageUrl: process.env.messageUrl,
- count: 0
- }
- },
- computed: {
- // isShowApplyAdv () {
- // if (this.$route.path.indexOf('/applyPurchase') === -1) {
- // this.ShowApplyAdv = true
- // }
- // return this.ShowApplyAdv && this.$route.path.indexOf('/applyPurchase') !== -1
- // },
- user () {
- // console.log(this.$store.state.option.user)
- return this.$store.state.option.user
- },
- enterprise () {
- return this.user.data.enterprise || {}
- },
- url () {
- return this.$store.state.option.url
- }
- },
- mounted () {
- if(this.user.logged && this.user.data) {
- let userUU = this.user.data.userUU
- let enUU = this.user.data.enterprise ? this.user.data.enterprise.uu : null
- if(userUU && enUU) {
- let param = {
- 'receiverUu': userUU,
- 'receiverEnuu': enUU,
- 'consumerApp': 'MALL',
- 'isRead': 0
- }
- this.$http.get(`/messages/count`, {params: param})
- .then((res) => {
- if(res.data) {
- this.count = res.data.count ? (res.data.count < 100 ? res.data.count : '99+') : 0
- } else {
- this.count = 0
- }
- }).catch((err) => {
- console.log(err)
- })
- }
- }
- },
- methods: {
- logout () {
- this.$http.get('/logout/crossBefore').then(response => {
- if (response.data) {
- window.location.href = response.data.logoutUrl + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
- }
- })
- },
- onLoginClick () {
- this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
- if (response.data) {
- window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
- }
- })
- // TODO 待Account Center改版
- },
- onRegisterClick () {
- this.$http.get('/register/page').then(response => {
- if (response.data) {
- window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + '/newLogin/other')
- }
- })
- },
- // 切换当前企业
- switchEnterprise (en) {
- this.showEnterpriseToggle = false
- this.$http.get(`/user/authentication/${en.uu}`).then(() => {
- this.$store.dispatch('loadUserInfo')
- // let path = this.$route.path
- // if (path === '/register-saler' && en.uu !== 0 && en.isVendor === 313) {
- // window.location.href = '/vendor#/index'
- // } else {
- // window.location.reload()
- // }
- window.location.href = '/'
- })
- // 切换帐套用
- this.$jsonp(`${process.env.ssoUrl}/sso/login/change/userspace?spaceUU=${en.uu}`, {timeout: 5000, name: 'successCallback'}, (err) => {
- console.log(err)
- })
- },
- toVendor: function () {
- let isSelf = true
- let tempEnterprise = {}
- let ens = this.user.data.enterprises
- if (ens && ens.length) {
- ens.forEach(function (item) {
- if (item.current) {
- isSelf = false
- tempEnterprise = item
- }
- })
- } else {
- isSelf = true
- }
- if (isSelf) {
- window.location.href = '/personalMaterial'
- } else {
- if (tempEnterprise.isVendor === 313) {
- // window.location.href = '/vendor'
- window.location.href = '/vendor#/index'
- } else {
- window.location.href = '/register-saler'
- }
- }
- }
- // searchEnterprise () {
- // let key = this.keyword
- // let enterprise = this.user.data.enterprises
- // this.isSearching = true
- // this.searchEnterpriseArr = []
- // if (this.keyword === '') {
- // this.isSearching = false
- // } else {
- // for (let i = 0; i < enterprise.length; i++) {
- // if (enterprise[i].enName.indexOf(key) !== -1) {
- // this.searchEnterpriseArr.push(enterprise[i])
- // }
- // }
- // }
- // }
- }
- }
- </script>
- <style lang="scss" scoped>
- .header .navbar{
- min-height: inherit;
- border-radius: 0;
- }
- .header .navbar .navbar-container .navbar-right .dropdown .dropdown-menu li span,.header .navbar .navbar-container .navbar-right .dropdown .dropdown-menu li a{
- font-size: 12px;
- }
- .header .navbar .navbar-container .navbar-right .dropdown .dropdown-menu .menu-item a{
- width: 100%;
- display: inline-block;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- height: 25px;
- }
- .header .navbar .navbar-container .navbar-right .dropdown .dropdown-menu .menu-item{
- height: 30px;
- }
- .apply-adv{
- margin: 0 auto;
- min-width: 1190px;
- position: relative;
- img{
- max-width: 100%;
- min-width: 1190px;
- }
- i {
- background: url("/images/search/search-close.png")no-repeat;
- width: 16px;
- height: 16px;
- position: absolute;
- right: 8px;
- top: 8px;
- cursor: pointer;
- z-index: 20000;
- }
- }
- .dropdown-menu>li>a{
- padding: 0;
- line-height: 30px;
- }
- .dropdown-menu>li a:hover{
- background: none;
- text-decoration: underline !important;
- }
- .dropdown-menu>li>a.pull-right{
- padding: 0;
- color: #1162a4 !important;
- line-height: inherit;
- }
- .member-text{
- width: 80%;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- display: inline-block;
- }
- @import '~assets/scss/mixins';
- @import '~assets/scss/variables';
- $nav-height: 38px;
- .header {
- /* height: $nav-height;*/
- .navbar {
- width: 100%;
- height: 100%;
- font-size: $font-size-small;
- background-color: $black-light;
- .navbar-container {
- .item-wrap {
- display: inline-block;
- }
- .item {
- color: $grey;
- display: inline-block;
- height: 35px;
- line-height: 35px;
- }
- a {
- color: $grey;
- }
- .navbar-header {
- float: left;
- .navbar-logo {
- margin-bottom: 2px;
- }
- .navbar-slogan {
- margin-left: $sm-pad;
- }
- }
- .navbar-right {
- float: right;
- .item {
- padding: 0 $pad;
- }
- .dropdown {
- .dropdown-toggle {
- line-height: $nav-height;
- border-left: 1px solid $black-light;
- border-right: 1px solid $black-light;
- height: 35px;
- a {
- margin-left: 15px;
- float: right;
- &:hover {
- color: $red !important;
- }
- }
- &:hover {
- border-left: 1px solid #999;
- border-right: 1px solid #999;
- }
- span {
- display: inline-block;
- max-width: 190px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- float: right;
- }
- }
- .menu-item-first {
- background: #eee;
- padding: 0 12px;
- line-height: 30px;
- font-size: 12px;
- >span:nth-child(1) {
- cursor: default;
- font-weight: bold;
- }
- input {
- width: 174px;
- height: 24px;
- margin-left: 35px;
- background: #fff;
- border: 1px solid #5078cb;
- padding-left: 4px;
- }
- .search-enterprise {
- display: inline-block;
- width: 36px;
- height: 24px;
- color: #fff;
- background: #5078cb;
- text-align: center;
- line-height: 24px;
- cursor: pointer;
- }
- }
- .dropdown-menu {
- padding: 0 6px 13px;
- margin:0;
- border-radius: 0;
- right: unset;
- background: #fff;
- border: 1px solid #999999;
- border-top: none;
- -webkit-box-shadow: none;
- -moz-box-shadow: none;
- box-shadow: none;
- ::-webkit-scrollbar {
- background: #f6f6f6;
- }
- ul {
- max-height: 300px;
- overflow-y: auto;
- background: #f6f6f6;
- }
- .menu-item {
- padding: 0 12px;
- a {
- color: #333;
- max-width: 300px;
- line-height: 30px;
- width: auto;
- &:hover {
- color: #5078cb;
- text-decoration: none!important;
- }
- }
- }
- }
- &:hover {
- background-color: $white;
- .dropdown-toggle {
- color: $text;
- }
- a {
- color: $text
- }
- }
- }
- }
- }
- }
- }
- </style>
|