header.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <template>
  2. <header>
  3. <div class="header-wrap">
  4. <div class="header-con xs">
  5. <div class="wrapper1180 flex row-between">
  6. <div class="flex" style="height: 100%">
  7. <template v-if="
  8. publicData.article && publicData.article.length
  9. ">
  10. <img style="
  11. width: 16px;
  12. height: 16px;
  13. margin-right: 10px;
  14. " src="~/static/images/header_notice.png" />
  15. <client-only>
  16. <swiper ref="headerSwiper" :options="swiperOptions">
  17. <swiper-slide class="swiper-item" v-for="(
  18. item, index
  19. ) in publicData.article" :key="index">
  20. <nuxt-link class="flex-col row-center" style="height: 100%" :to="
  21. '/news_list/news_list_detail?id=' +
  22. item.id
  23. ">
  24. <div class="line1">
  25. {{ item.title }}
  26. </div>
  27. </nuxt-link>
  28. </swiper-slide>
  29. </swiper>
  30. </client-only>
  31. </template>
  32. </div>
  33. <div class="user flex flex-none">
  34. <div v-if="config.name">
  35. 您好,欢迎来到 {{ config.name }}!
  36. </div>
  37. <ul class="flex flex-none">
  38. <li>
  39. <nuxt-link to="/">首页</nuxt-link>
  40. </li>
  41. <li>
  42. <nuxt-link to="/policy/search">政策查询</nuxt-link>
  43. </li>
  44. <li>
  45. <nuxt-link to="/policy">政策计算器</nuxt-link>
  46. </li>
  47. <li>
  48. <nuxt-link to="/footprint/footprint">我的足迹</nuxt-link>
  49. </li>
  50. <li>
  51. <div
  52. @click.stop="showCompanyAdd = true">
  53. 企业反馈</div>
  54. </li>
  55. <li>
  56. <div
  57. @click.stop="showFeedbackAdd = true">
  58. 意见反馈</div>
  59. </li>
  60. <li v-if="publicData.nickname">
  61. <el-popover placement="bottom" trigger="hover" width="300">
  62. <!-- 统计 -->
  63. <div class="flex row-around w-full user-count">
  64. <div class="flex-1 flex flex-col col-center"
  65. v-for="(item, index) in publicData.count" :key="index"
  66. @tap="menuJump(item)">
  67. <div class="lg primary">{{ item.count }}</div>
  68. <div>{{ item.title }}</div>
  69. </div>
  70. </div>
  71. <div class="user-nav">
  72. <div class="lighter xs item" @click="onLogout">
  73. 退出登录
  74. </div>
  75. </div>
  76. <div slot="reference">
  77. {{ publicData.nickname }}
  78. <i class="el-icon-arrow-down"></i>
  79. </div>
  80. </el-popover>
  81. </li>
  82. <li v-else>
  83. <nuxt-link to="/account/login">聚才网登录</nuxt-link>
  84. </li>
  85. </ul>
  86. </div>
  87. </div>
  88. </div>
  89. <div class="header-main" :style="{
  90. 'background-image': `url(${config.pc_top_bg})`}">
  91. <div class="wrapper1180 flex flex-col row-center">
  92. <div class="app-name">{{config.name}}</div>
  93. <div class="search-wrap flex row-between">
  94. <!-- <nuxt-link to="/" class="flex row-center">-->
  95. <!-- <img-->
  96. <!-- :src="config.shop_login_logo"-->
  97. <!-- class="logo"-->
  98. <!-- alt="logo"-->
  99. <!-- />-->
  100. <!-- </nuxt-link>-->
  101. <div class="flex">
  102. <div class="search flex">
  103. <input type="text" v-model="name" placeholder="请输入关键字搜索" @focus="toFocus"
  104. @keyup.enter="toSearch" />
  105. <el-button class="search-btn" type="primary" @click="toSearch">
  106. 搜索
  107. </el-button>
  108. </div>
  109. </div>
  110. </div>
  111. <div>热搜词语: 知名企业家人才名录、全国高端人才名录 </div>
  112. </div>
  113. </div>
  114. </div>
  115. <feedback-add v-model="showFeedbackAdd" />
  116. <company-add v-model="showCompanyAdd" />
  117. </header>
  118. </template>
  119. <script>
  120. import {
  121. directive
  122. } from 'vue-awesome-swiper'
  123. import {
  124. mapState,
  125. mapMutations,
  126. mapActions
  127. } from 'vuex'
  128. export default {
  129. directives: {
  130. swiper: directive,
  131. },
  132. data() {
  133. return {
  134. name: '',
  135. search: false,
  136. swiperOptions: {
  137. direction: 'vertical',
  138. // autoHeight: true,
  139. height: 40,
  140. initialSlide: 0,
  141. autoplay: true,
  142. },
  143. showFeedbackAdd: false,
  144. showCompanyAdd: false,
  145. }
  146. },
  147. mounted() {
  148. this.$nuxt.$on('keyword', (val) => {
  149. this.name = val
  150. })
  151. },
  152. methods: {
  153. ...mapMutations(['logout']),
  154. ...mapActions(['getPublicData']),
  155. toSearch() {
  156. // if (!this.name) return this.$message.error('请输入商品名称')
  157. if (this.search) {
  158. this.$nuxt.$emit('search', this.name);
  159. }
  160. },
  161. toFocus() {
  162. if (!this.search) {
  163. this.$router.push({
  164. path: '/search/search',
  165. // query: {
  166. // name: this.name,
  167. // },
  168. })
  169. } else {
  170. this.$nuxt.$emit('searchFouce', true);
  171. }
  172. },
  173. onLogout() {
  174. this.logout()
  175. this.$message({
  176. message: '退出成功',
  177. type: 'success',
  178. })
  179. setTimeout(() => location.reload(), 1500)
  180. },
  181. },
  182. watch: {
  183. $route: {
  184. immediate: true,
  185. handler: function(val) {
  186. console.log(val)
  187. if (val.path == '/search/search') {
  188. this.search = true
  189. } else {
  190. this.search = false
  191. }
  192. },
  193. },
  194. },
  195. computed: {
  196. ...mapState(['publicData', 'config']),
  197. },
  198. }
  199. </script>
  200. <style lang="scss" scoped>
  201. .header-wrap {
  202. min-width: 1180px;
  203. position: relative;
  204. z-index: 1000;
  205. ::v-deep .swiper-container {
  206. margin-left: 0;
  207. margin-right: 0;
  208. height: 100%;
  209. width: 400px;
  210. }
  211. .swiper-item {
  212. color: #ccc;
  213. height: 17px;
  214. }
  215. .header-con {
  216. background-color: rgba(4, 4, 4, 0.56);
  217. border: 1px solid #707070;
  218. height: 57px;
  219. color: #f2f2f2;
  220. >div {
  221. height: 100%;
  222. color: #FFFFFF;
  223. a {
  224. color: #FFFFFF;
  225. &:hover {
  226. color: #fff;
  227. }
  228. }
  229. ul {
  230. li {
  231. margin-left: 20px;
  232. }
  233. #tel-phone-block {
  234. position: relative;
  235. &:hover .float-code {
  236. display: flex;
  237. box-shadow: 0 2px 8px 0 rgb(0 0 0 / 10%);
  238. }
  239. .float-code {
  240. display: none;
  241. position: absolute;
  242. padding: 22px 16px;
  243. background-color: white;
  244. top: 24px;
  245. right: -20px;
  246. &::after {
  247. content: '';
  248. width: 8px;
  249. box-shadow: 0 2px 8px 0 rgb(0 0 0 / 10%);
  250. transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
  251. right: 35px;
  252. top: -4px;
  253. height: 8px;
  254. background-color: #fff;
  255. position: absolute;
  256. }
  257. }
  258. }
  259. }
  260. }
  261. }
  262. .header-main {
  263. height: 360px;
  264. background-size: 100% 100%;
  265. .wrapper1180 {
  266. height: 360px;
  267. .app-name {
  268. font-size: 40px;
  269. font-weight: bold;
  270. color: #FFFFFF;
  271. text-shadow: 1px 1px 2px black;
  272. }
  273. .search-wrap {
  274. margin-top: 30px;
  275. height: 80px;
  276. //.logo {
  277. // height: 48px;
  278. // width: auto;
  279. //}
  280. .search {
  281. width: 460px;
  282. height: 42px;
  283. overflow: hidden;
  284. input {
  285. flex: 1;
  286. height: 100%;
  287. border-radius: 4px 0 0 4px;
  288. border: 1px solid $--color-primary;
  289. border-right-width: 0;
  290. padding: 0 10px;
  291. }
  292. .search-btn {
  293. width: 82px;
  294. height: 42px;
  295. cursor: pointer;
  296. border-radius: 0 4px 4px 0;
  297. }
  298. }
  299. .cart {
  300. cursor: pointer;
  301. border-radius: 4px;
  302. width: 108px;
  303. height: 42px;
  304. margin-left: 16px;
  305. }
  306. }
  307. }
  308. }
  309. .user li {
  310. cursor: pointer;
  311. }
  312. }
  313. .user-nav {
  314. .item {
  315. text-align: center;
  316. line-height: 34px;
  317. display: block;
  318. cursor: pointer;
  319. &:not(:last-child) {
  320. border-bottom: 1px solid #e5e5e5;
  321. }
  322. &:hover {
  323. color: $--color-primary;
  324. }
  325. }
  326. }
  327. .user-opts {
  328. padding: 50rpx;
  329. image {
  330. width: 70rpx;
  331. height: 70rpx;
  332. }
  333. }
  334. .user-count {
  335. color: #5D5D5D;
  336. }
  337. </style>