header.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. <template>
  2. <div id="proginn-header" :class="{transparent: transparent}">
  3. <div class="list">
  4. <a :href="baseUrl" class="nav-item">
  5. <img
  6. class="logo"
  7. :src="transparent ? blueWhiteLogo : 'https://stacdn.proginn.com/image/common/logo3@2x.png'"
  8. />
  9. </a>
  10. <a :href="baseUrl" class="nav-item">首页</a>
  11. <a :href="baseUrl+'/cloud?from=top_nav'" class="nav-item">云端工作</a>
  12. <a :href="baseUrl+'/users'" class="nav-item">程序员</a>
  13. <el-dropdown class="nav-dropdown">
  14. <el-button type="text" class="dashboard-title">更多服务</el-button>
  15. <el-dropdown-menu slot="dropdown">
  16. <el-dropdown-item>
  17. <a
  18. class="workstation"
  19. :href="jishuBaseUrl+'/?from=top_nav'"
  20. style="display: flex; align-items: center;"
  21. >
  22. <img
  23. src="@/assets/img/header/jishuin.png"
  24. style="width: 24px;height: 24px;margin-right: 5px;"
  25. />技术圈
  26. </a>
  27. </el-dropdown-item>
  28. <el-dropdown-item>
  29. <a
  30. class="workstation"
  31. href="http://www.binstd.com/?from=proginn"
  32. style="display: flex; align-items: center;"
  33. >
  34. <img
  35. src="@/assets/img/header/binstd.png"
  36. style="width: 24px;height: 24px;margin-right: 5px;"
  37. />进制数据
  38. </a>
  39. </el-dropdown-item>
  40. <el-dropdown-item>
  41. <a
  42. class="workstation"
  43. :href="'/credit'"
  44. style="display: flex; align-items: center;"
  45. >
  46. <img
  47. src="@/assets/img/header/creditIconMore.png"
  48. style="width: 24px;height: 24px;margin-right: 5px;"
  49. />技术信用
  50. </a>
  51. </el-dropdown-item>
  52. <el-dropdown-item>
  53. <a
  54. class="workstation"
  55. href="/kaifain"
  56. style="display: flex; align-items: center;"
  57. >
  58. <img
  59. src="@/assets/img/header/partners.png"
  60. style="width: 24px;height: 24px;margin-right: 5px;"
  61. />解决方案
  62. </a>
  63. </el-dropdown-item>
  64. </el-dropdown-menu>
  65. </el-dropdown>
  66. <div>
  67. <div style="position: relative;">
  68. <input
  69. class="input"
  70. autocomplete="off"
  71. placeholder="搜索您感兴趣的程序员"
  72. v-model="keywork"
  73. @keyup.enter="clickInputEnter"
  74. />
  75. <i class="el-icon-search" @click="clickInputEnter"></i>
  76. </div>
  77. <div class="dropdown" style="display:none;"></div>
  78. <div class="dropdown" style="display:none;"></div>
  79. </div>
  80. <template v-if="myInfo.nickname">
  81. <el-dropdown class="nav-dropdown">
  82. <el-button type="text" class="dashboard-title" :class>
  83. <i class="el-icon-tickets"></i>工作台
  84. </el-button>
  85. <el-dropdown-menu slot="dropdown">
  86. <el-dropdown-item>
  87. <a class="workstation" :href="baseUrl+'/wo/work_todo'">
  88. <i class="el-icon-edit"></i>我的待办
  89. </a>
  90. </el-dropdown-item>
  91. <el-dropdown-item>
  92. <a class="workstation" :href="baseUrl+'/wo/work_platform'">
  93. <i class="el-icon-date"></i>我的项目
  94. </a>
  95. </el-dropdown-item>
  96. <el-dropdown-item>
  97. <a class="workstation" :href="baseUrl+'/wo/work_hire'">
  98. <i class="el-icon-news"></i>我的雇佣
  99. </a>
  100. </el-dropdown-item>
  101. <el-dropdown-item>
  102. <a class="workstation" :href="baseUrl+'/wo/work_cloud'">
  103. <i class="el-icon-service"></i>我的云端
  104. </a>
  105. </el-dropdown-item>
  106. </el-dropdown-menu>
  107. </el-dropdown>
  108. <el-dropdown class="nav-dropdown">
  109. <el-button type="text" class="message-box-title">
  110. <i class="el-icon-message"></i>消息
  111. <span
  112. v-if="messageCount.total > 0"
  113. class="message-count message-total"
  114. >{{messageCount.total}}</span>
  115. </el-button>
  116. <el-dropdown-menu slot="dropdown">
  117. <el-dropdown-item class="message-box" @click.native="clickMessages('/message/system')">
  118. <i class="circle blue"></i>系统消息
  119. <span v-if="messageCount.system" class="message-count">{{messageCount.system}}</span>
  120. </el-dropdown-item>
  121. <el-dropdown-item class="message-box" @click.native="clickMessages('/message/project')">
  122. <i class="circle orange"></i>工作通知
  123. <span v-if="messageCount.work" class="message-count">{{messageCount.work}}</span>
  124. </el-dropdown-item>
  125. <el-dropdown-item class="message-box" @click.native="clickMessages('/message/comment')">
  126. <i class="circle red"></i>评论回复
  127. <span v-if="messageCount.reply" class="message-count">{{messageCount.reply}}</span>
  128. </el-dropdown-item>
  129. <el-dropdown-item class="message-box" @click.native="clickMessages('/message/at')">
  130. <i class="circle green"></i>@我的
  131. <span v-if="messageCount.at" class="message-count">{{messageCount.at}}</span>
  132. </el-dropdown-item>
  133. <el-dropdown-item class="message-box" @click.native="clickMessages('/message/plus')">
  134. <i class="circle pink"></i>赞及其它
  135. <span
  136. v-if="messageCount.community_other"
  137. class="message-count"
  138. >{{messageCount.community_other}}</span>
  139. </el-dropdown-item>
  140. <el-dropdown-item class="message-box" @click.native="clickMessages('/message/coin')">
  141. <i class="circle yellow"></i>收支信息
  142. <span v-if="messageCount.balance" class="message-count">{{messageCount.balance}}</span>
  143. </el-dropdown-item>
  144. </el-dropdown-menu>
  145. </el-dropdown>
  146. <el-popover class="nav-popover" placement="bottom" width="226" trigger="hover">
  147. <div class="ref" slot="reference">
  148. <a class="nav-header" href="/wo/work_todo">
  149. <img class="header-user" :src="myInfo.icon_url" />
  150. <img
  151. v-if="myInfo.is_vip"
  152. class="header-vip-icon"
  153. :src="baseUrl+`/Public/image/h5/vip_icon${vipImage}.png`"
  154. alt="vip-icon"
  155. />
  156. </a>
  157. <span class="nickname">{{myInfo.nickname}}</span>
  158. </div>
  159. <div class="menu">
  160. <div v-if="myInfo.is_vip" class="vip-info vip-info-com">
  161. <div class="vip-info-top" >
  162. <img class="vip-icon" :src="baseUrl+`/Public/image/h5/vip_icon${vipImage}.png`" alt="vip-icon"/>
  163. <span class="vip-content">
  164. <span class="vip-title" :class="vipTextClass">{{vipText}}</span>
  165. <br />
  166. <span class="vip-end-date">{{vipInfo.endDate}}到期</span>
  167. </span>
  168. </div>
  169. <div class="vip-arcs">
  170. <a class="vip-arc" :class="vipTextClass" :href="baseUrl+'/type/vip/'+vipType">查看权益</a>
  171. <a
  172. class="vip-arc"
  173. :class="vipTextClass"
  174. :href="baseUrl+'/vip/pay?number=3&amp;product_id='+this.$store.state.userinfo.vip_type_id+'&amp;next=/type/vip/'+vipType"
  175. >立即续费</a>
  176. </div>
  177. </div>
  178. <div class="vip-items">
  179. <a class="vip-item divider" :href="baseUrl+'/wo/work_platform'">
  180. <i class="el-icon-date"></i>我的项目
  181. </a>
  182. <a class="vip-item" :href="baseUrl+'/wo/work_hire'">
  183. <i class="el-icon-news"></i>我的雇佣
  184. </a>
  185. <a class="vip-item" :href="baseUrl+'/wo/work_cloud'">
  186. <i class="el-icon-service"></i>我的云端
  187. </a>
  188. <a class="vip-item divider" :href="baseUrl+`/wo/${myInfo.uid}`">
  189. <i class="el-icon-document"></i>我的主页
  190. </a>
  191. <a class="vip-item" :href="baseUrl+'/index/app'">
  192. <i class="el-icon-view"></i>关注微信
  193. </a>
  194. <a class="vip-item" :href="'/credit/pages'">
  195. <i class="el-icon-credit"></i>技术信用
  196. </a>
  197. <a class="vip-item divider" @click="clickQuit">
  198. <i class="el-icon-back"></i>退出
  199. </a>
  200. </div>
  201. </div>
  202. </el-popover>
  203. </template>
  204. <div v-else>
  205. <a class="account-ctrl" :href="baseUrl+'/?loginbox=show'">登录</a>
  206. <a class="account-ctrl" style="margin-left: 40px;" :href="baseUrl+'/user/register'">注册</a>
  207. </div>
  208. </div>
  209. </div>
  210. </template>
  211. <script>
  212. import blueWhiteLogo from "@/assets/img/logo_blue_white.png";
  213. export default {
  214. props: ["transparent"],
  215. data() {
  216. return {
  217. baseUrl: "",
  218. jishuBaseUrl: "",
  219. // 搜索的关键词
  220. keywork: "",
  221. // 消息数量
  222. messageCount: {},
  223. blueWhiteLogo
  224. };
  225. },
  226. computed: {
  227. vipInfo() {
  228. let userinfo = this.$store.state.userinfo;
  229. return {
  230. id: userinfo.vip_type_id,
  231. endDate: userinfo.vip_end_date
  232. };
  233. },
  234. myInfo() {
  235. return this.$store.state.userinfo;
  236. },
  237. isCom() {
  238. return this.$store.state.userinfo.vip_type_id === "1";
  239. },
  240. vipImage(){
  241. switch (parseInt(this.$store.state.userinfo.vip_type_id)) {
  242. case 1:
  243. return '_com';
  244. case 2:
  245. return '';
  246. case 3:
  247. return '_premium';
  248. default:
  249. return '';
  250. }
  251. },
  252. vipType(){
  253. switch (parseInt(this.$store.state.userinfo.vip_type_id)) {
  254. case 1:
  255. case 3:
  256. return 'enterprise';
  257. break;
  258. case 2:
  259. return 'developer';
  260. }
  261. },
  262. vipTextClass(){
  263. switch (parseInt(this.$store.state.userinfo.vip_type_id)) {
  264. case 1:
  265. return 'is-newly';
  266. case 2:
  267. return 'is-dev';
  268. case 3:
  269. return 'is-premium';
  270. default:
  271. return '';
  272. }
  273. },
  274. vipText(){
  275. switch (parseInt(this.$store.state.userinfo.vip_type_id)) {
  276. case 1:
  277. return '初创版会员';
  278. case 2:
  279. return '开发者会员';
  280. case 3:
  281. return '企业版会员';
  282. default:
  283. return '';
  284. }
  285. }
  286. },
  287. mounted() {
  288. if (this.myInfo && this.myInfo.nickname) {
  289. this.getMessageCount();
  290. }
  291. },
  292. methods: {
  293. async clickQuit() {
  294. location.href = this.baseUrl + "/user/quit";
  295. },
  296. clickMessages(url) {
  297. location.href = url;
  298. },
  299. clickInputEnter() {
  300. window.location.href = this.baseUrl + "/search/?keyword=" + this.keywork;
  301. },
  302. async getMessageCount() {
  303. let res = await this.$axios.$get(
  304. "/api/message/getUnreadCount",
  305. {},
  306. { neverLogout: true }
  307. );
  308. if (res) {
  309. this.messageCount = res.data;
  310. }
  311. }
  312. },
  313. created() {
  314. this.baseUrl = this.$store.state.domainConfig.siteUrl;
  315. this.jishuBaseUrl = this.$store.state.domainConfig.jishuinUrl;
  316. }
  317. };
  318. </script>
  319. <style scoped>
  320. #proginn-header {
  321. position: relative;
  322. display: flex;
  323. justify-content: center;
  324. width: 100%;
  325. background: white;
  326. z-index: 10;
  327. }
  328. .list {
  329. display: flex;
  330. justify-content: space-between;
  331. align-items: center;
  332. width: 1000px;
  333. }
  334. .nav-item {
  335. display: flex;
  336. height: 83px;
  337. align-items: center;
  338. font-size: 15px;
  339. color: #515151;
  340. /* padding: 0 15px; */
  341. box-sizing: border-box;
  342. }
  343. .nav-item:first-child {
  344. padding: 0;
  345. }
  346. .nav-item:nth-child(n + 2):hover {
  347. color: #1782d9;
  348. border-top: 5px solid transparent;
  349. border-bottom: 5px solid #1782d9;
  350. }
  351. .nav-dropdown,
  352. .nav-popover {
  353. --imgWidth: 28px;
  354. height: 40px;
  355. display: flex;
  356. align-items: center;
  357. }
  358. .nav-popover > .ref {
  359. display: flex;
  360. align-items: center;
  361. }
  362. .nav-header {
  363. position: relative;
  364. width: var(--imgWidth);
  365. height: var(--imgWidth);
  366. margin-right: 5px;
  367. }
  368. .logo {
  369. width: 140px;
  370. height: auto;
  371. }
  372. .input {
  373. width: 234px;
  374. height: 40px;
  375. border-radius: 20px;
  376. background: #f6f6f6;
  377. padding: 0 40px;
  378. border: 1px solid #ebebeb;
  379. font-size: 13px;
  380. }
  381. .el-icon-search {
  382. position: absolute;
  383. top: 12px;
  384. right: 20px;
  385. color: grey;
  386. cursor: pointer;
  387. }
  388. .el-icon-credit {
  389. background: url('~@/assets/img/header/creditIconMine.png') no-repeat;
  390. background-size: cover;
  391. width: 18px;
  392. height: 18px;
  393. vertical-align: middle;
  394. margin: 0 8px;
  395. }
  396. .el-icon-search::before {
  397. font-size: 14px;
  398. font-weight: 800;
  399. }
  400. i {
  401. margin-right: 4px;
  402. }
  403. i.circle {
  404. display: inline-block;
  405. --width: 12px;
  406. width: var(--width);
  407. height: var(--width);
  408. border-radius: calc(var(--width) / 2);
  409. }
  410. i.blue {
  411. background: #3b83c0;
  412. }
  413. i.orange {
  414. background: #e07b53;
  415. }
  416. i.red {
  417. background: #d95c5c;
  418. }
  419. i.green {
  420. background: #5bbd72;
  421. }
  422. i.pink {
  423. background: #d9499a;
  424. }
  425. i.yellow {
  426. background: #f2c61f;
  427. }
  428. .message-box {
  429. position: relative;
  430. display: flex;
  431. align-items: center;
  432. }
  433. .message-count {
  434. color: white;
  435. margin-left: 4px;
  436. display: block;
  437. line-height: 18px;
  438. padding: 0 8px;
  439. border-radius: 9px;
  440. background: grey;
  441. }
  442. .message-count.message-total {
  443. position: absolute;
  444. top: 0px;
  445. right: -10px;
  446. background: #d95c5c;
  447. }
  448. span.other-icon {
  449. display: block;
  450. margin-left: 30px;
  451. }
  452. .nickname {
  453. font-size: 15px;
  454. }
  455. .vip-info {
  456. display: flex;
  457. flex-direction: column;
  458. justify-content: center;
  459. align-items: center;
  460. width: 206px;
  461. height: 120px;
  462. }
  463. .vip-info-top {
  464. display: flex;
  465. width: 142px;
  466. }
  467. .vip-title {
  468. color: #cb9d53;
  469. font-size: 16px;
  470. line-height: 36px;
  471. }
  472. .vip-icon {
  473. width: 24px;
  474. height: 24px;
  475. margin: 10px 8px 0 0;
  476. }
  477. .vip-end-date {
  478. font-size: 12px;
  479. color: #999;
  480. }
  481. .vip-arcs {
  482. display: flex;
  483. justify-content: space-between;
  484. width: 142px;
  485. margin-top: 11px;
  486. }
  487. .vip-arc {
  488. flex: 1;
  489. font-size: 13px;
  490. color: #cb9d53;
  491. text-align: center;
  492. }
  493. .vip-arc:first-child {
  494. border-right: 1px solid rgba(245, 245, 245, 1);
  495. }
  496. .vip-info-com .vip-title {
  497. color: rgb(113, 177, 253);
  498. }
  499. .vip-info-com .vip-arc {
  500. color: rgb(113, 177, 253);
  501. }
  502. .header-user {
  503. width: var(--imgWidth);
  504. height: var(--imgWidth);
  505. border-radius: 20px;
  506. }
  507. .header-vip-icon {
  508. position: absolute;
  509. top: 16px;
  510. left: 18px;
  511. width: 16px;
  512. height: 16px;
  513. }
  514. .vip-items {
  515. display: flex;
  516. flex-direction: column;
  517. }
  518. .vip-item {
  519. line-height: 32px;
  520. color: #606266;
  521. }
  522. .vip-item > i {
  523. margin: 0 10px;
  524. }
  525. .divider {
  526. border-top: 1px solid rgba(0, 0, 0, 0.05);
  527. margin-top: 10px;
  528. padding-top: 10px;
  529. cursor: pointer;
  530. }
  531. .vip-info-com .is-dev {
  532. color: #cb9d53;
  533. }
  534. .vip-info-com .is-newly{
  535. color: #308EFF;
  536. }
  537. .vip-info-com .is-premium{
  538. color: #00C469;
  539. }
  540. .workstation {
  541. color: #606266;
  542. }
  543. .account-ctrl {
  544. color: #606266;
  545. }
  546. #proginn-header a {
  547. text-decoration: none !important;
  548. }
  549. #proginn-header.transparent {
  550. background: transparent;
  551. border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  552. }
  553. #proginn-header.transparent a {
  554. color: white;
  555. }
  556. .message-box-title,
  557. .dashboard-title {
  558. color: #515151;
  559. font-size: 15px;
  560. }
  561. #proginn-header.transparent .message-box-title,
  562. #proginn-header.transparent .dashboard-title {
  563. color: white;
  564. }
  565. #proginn-header.transparent .nickname {
  566. color: white;
  567. }
  568. </style>