index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <template>
  2. <div class="navbar-group">
  3. <div class="logo">
  4. <img :src="logo" alt="logo">
  5. </div>
  6. <div class="nav-group">
  7. <div
  8. class="nav-item"
  9. :class="nav.class"
  10. v-for="(nav, index) in navs"
  11. :key="index"
  12. @click="onSelectNav(nav)"
  13. >
  14. <template v-if="nav.plugin">
  15. <navbar-item :badge="nav.badge" :svg="nav.svg" :nav="nav" v-popover:[nav.plugin]></navbar-item>
  16. </template>
  17. <navbar-item :badge="nav.badge" :svg="nav.svg" :nav="nav" v-else></navbar-item>
  18. </div>
  19. <el-popover
  20. popper-class="nav-popover"
  21. ref="navInfo"
  22. placement="bottom"
  23. trigger="hover"
  24. :visible-arrow="false"
  25. >
  26. <div class="user-info-group">
  27. <navbar-item :nav="{ icon: userInfo.avatar }" mode="vertical">
  28. <div class="info-group">
  29. <span v-if="userInfo.name">{{userInfo.name}}</span>
  30. <span v-if="userInfo.phone">{{userInfo.phone}}</span>
  31. </div>
  32. </navbar-item>
  33. <button @click="onClickOut">退出登录</button>
  34. </div>
  35. </el-popover>
  36. <el-popover
  37. popper-class="nav-popover"
  38. ref="navCustomer"
  39. placement="bottom"
  40. trigger="hover"
  41. :visible-arrow="false"
  42. >
  43. <div class="custom-info-group">
  44. <div class="info-item" v-if="hasExclusiveCustomer">
  45. <div class="after-tag-box recommend-tag">推荐</div>
  46. <navbar-item :nav="{ label: '专属客服:' + exclusiveCustomerInfo.name, icon: 'icon-weixin_line' }"></navbar-item>
  47. <navbar-item
  48. class="qrcode-group"
  49. :nav="{
  50. label: '微信扫一扫',
  51. icon: exclusiveCustomerInfo.qrcode
  52. }"
  53. mode="vertical"
  54. >
  55. </navbar-item>
  56. </div>
  57. <div class="info-item">
  58. <navbar-item :nav="{ label: '在线咨询', icon: 'icon-kefu_xian' }" :svg="true"></navbar-item>
  59. </div>
  60. <div class="info-item">
  61. <navbar-item :nav="{ label: '客服热线:400-108-6670', icon: 'icon-telphone_line' }"></navbar-item>
  62. </div>
  63. </div>
  64. </el-popover>
  65. </div>
  66. </div>
  67. </template>
  68. <script>
  69. import NavbarItem from './components/item'
  70. import { mapActions, mapGetters, mapState } from 'vuex'
  71. export default {
  72. name: 'header-navbar',
  73. components: {
  74. NavbarItem,
  75. [NavbarItem.name]: NavbarItem
  76. },
  77. created () {
  78. this.getPower()
  79. this.getUserSimpleInfo().then(() => {
  80. const userInfo = this.navs.find(v => v.plugin === 'navInfo')
  81. userInfo.label = this.userInfo.name || this.userInfo.phone
  82. userInfo.icon = this.userInfo.avatar
  83. })
  84. this.getMessageCount().then(() => {
  85. this.navs.find(v => v.label === '消息中心').badge = this.messageCount
  86. })
  87. },
  88. data () {
  89. return {
  90. home: 'https://jybx-webtest.jydev.jianyu360.com',
  91. logo: 'https://cdn-ali.jianyu360.com/images/swordfish/sf_01_new.png',
  92. navs: [
  93. {
  94. label: '前往官网',
  95. icon: 'icon-houtui'
  96. },
  97. {
  98. label: '消息中心',
  99. icon: 'icon-a-Property1gongzuozhuomianProperty2xiaoxizhongxinProperty3grey',
  100. badge: 0
  101. // plugin: 'navMessage'
  102. },
  103. {
  104. label: '客服',
  105. icon: 'icon-kefu_xian',
  106. svg: true,
  107. plugin: 'navCustomer'
  108. },
  109. {
  110. label: '',
  111. icon: 'https://www.jianyu360.cn/common-module/public/image/auto.png',
  112. plugin: 'navInfo',
  113. class: 'nav-user-info'
  114. }
  115. ]
  116. }
  117. },
  118. computed: {
  119. ...mapState('work-bench/navbar', [
  120. 'messageCount'
  121. ]),
  122. ...mapGetters('work-bench/user', [
  123. 'hasExclusiveCustomer',
  124. 'exclusiveCustomerInfo',
  125. 'userInfo'
  126. ])
  127. },
  128. methods: {
  129. ...mapActions('work-bench', [
  130. 'getPower',
  131. 'getUserSimpleInfo',
  132. 'setSignOut',
  133. 'getMessageCount'
  134. ]),
  135. onClickOut () {
  136. this.setSignOut()
  137. document.cookie = 'userid_secure=;expires=-1;path=/'
  138. this.goSiteHome()
  139. },
  140. onSelectNav (nav) {
  141. console.log(nav, 'xxx')
  142. switch (nav.label) {
  143. case '消息中心': {
  144. this.$router.push({
  145. name: 'page',
  146. query: {
  147. link: 'https://jybx-webtest.jydev.jianyu360.com/swordfish/frontPage/messageCenter/sess/index'
  148. }
  149. })
  150. break
  151. }
  152. case '前往官网': {
  153. this.goSiteHome()
  154. break
  155. }
  156. }
  157. },
  158. goSiteHome () {
  159. location.href = this.home
  160. }
  161. }
  162. }
  163. </script>
  164. <style lang="scss">
  165. .flex-horizontal {
  166. display: flex;
  167. flex-direction: row;
  168. align-items: center;
  169. }
  170. .flex-vertical {
  171. display: flex;
  172. flex-direction: column;
  173. align-items: center;
  174. justify-content: center;
  175. }
  176. .nav-popover {
  177. &.el-popper[x-placement^=bottom] {
  178. margin-top: 20px;
  179. }
  180. padding: 0;
  181. border: none;
  182. background: #FFFFFF;
  183. box-shadow: 0px 5px 5px -3px rgba(0,0,0,0.1000), 0px 8px 10px 1px rgba(0,0,0,0.0600), 0px 3px 14px 2px rgba(0,0,0,0.0500);
  184. border-radius: 8px;
  185. overflow: hidden;
  186. }
  187. .custom-info-group {
  188. min-width: 229px;
  189. .info-item {
  190. position: relative;
  191. padding: 12px 16px;
  192. .after-tag-box {
  193. position: absolute;
  194. right: 0;
  195. top: 16px;
  196. }
  197. .qrcode-group {
  198. padding-bottom: 4px;
  199. .img-icon {
  200. width: 90px;
  201. height: 90px;
  202. margin-right: 0;
  203. }
  204. span {
  205. margin-left: 0;
  206. }
  207. }
  208. span {
  209. margin-left: 4px;
  210. font-size: 14px;
  211. color: #686868;
  212. line-height: 22px;
  213. }
  214. & + .info-item {
  215. border-top: 1px solid #ECECEC;
  216. }
  217. }
  218. }
  219. .user-info-group {
  220. width: 150px;
  221. padding-top: 18px;
  222. .info-group {
  223. width: 100%;
  224. @extend .flex-vertical;
  225. padding: 0 16px 8px 18px;
  226. box-sizing: border-box;
  227. span {
  228. width: 100%;
  229. text-align: center;
  230. display: inline-block;
  231. overflow:hidden;
  232. text-overflow:ellipsis;
  233. white-space:nowrap;
  234. }
  235. }
  236. button {
  237. width: 100%;
  238. height: 34px;
  239. background: #F5F6F7;
  240. text-align: center;
  241. font-size: 12px;
  242. font-weight: 400;
  243. color: #686868;
  244. cursor: pointer;
  245. }
  246. }
  247. .recommend-tag {
  248. position: relative;
  249. @extend .flex-horizontal;
  250. display: inline-flex;
  251. height: 20px;
  252. padding-left: 16px;
  253. padding-right: 8px;
  254. background: linear-gradient(136deg, #FF9F40 0%, #FF3A20 100%);
  255. font-size: 12px;
  256. font-weight: 400;
  257. color: #FFFFFF;
  258. &::before {
  259. content: "";
  260. position: absolute;
  261. top: 3px;
  262. left: -8px;
  263. background: #fff;
  264. width: 14px;
  265. height: 14px;
  266. transform: rotate(45deg);
  267. border-radius: 2px;
  268. }
  269. }
  270. </style>
  271. <style scoped lang="scss">
  272. .flex-horizontal {
  273. display: flex;
  274. flex-direction: row;
  275. align-items: center;
  276. }
  277. .flex-vertical {
  278. display: flex;
  279. flex-direction: column;
  280. align-items: center;
  281. justify-content: center;
  282. }
  283. .navbar-group {
  284. position: relative;
  285. z-index: 2;
  286. @extend .flex-horizontal;
  287. justify-content: space-between;
  288. padding: 16px 36px;
  289. box-sizing: border-box;
  290. background-color: #ffffff;
  291. box-shadow: 0px 2px 8px -1px rgba(0,0,0,0.0800);
  292. .nav-user-info {
  293. ::v-deep .navbar-item--label {
  294. max-width: 118px;
  295. overflow:hidden;
  296. text-overflow:ellipsis;
  297. white-space:nowrap;
  298. }
  299. }
  300. .logo {
  301. display: inline-block;
  302. width: auto;
  303. height: 32px;
  304. img {
  305. height: 100%;
  306. }
  307. }
  308. .nav-group {
  309. @extend .flex-horizontal;
  310. font-size: 16px;
  311. font-weight: 400;
  312. color: #1D1D1D;
  313. line-height: 24px;
  314. .nav-item {
  315. height: 32px;
  316. }
  317. .nav-item + .nav-item {
  318. margin-left: 48px;
  319. }
  320. }
  321. }
  322. </style>