header.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. <template>
  2. <section id="proginn-header">
  3. <section class="list">
  4. <a href="/" class="nav-item">
  5. <img class="logo" src="https://stacdn.proginn.com/image/common/logo3@2x.png">
  6. </a>
  7. <a href="/" class="nav-item">首页</a>
  8. <a href="/cloud?from=top_nav" class="nav-item">云端工作</a>
  9. <a href="/users" class="nav-item">程序员</a>
  10. <a href="/community" class="nav-item">技术圈</a>
  11. <section>
  12. <section style="position: relative;">
  13. <input
  14. class="input"
  15. autocomplete="off"
  16. placeholder="搜索您感兴趣的程序员"
  17. v-model="keywork"
  18. @keyup.enter="clickInputEnter"
  19. >
  20. <i class="el-icon-search" @click="clickInputEnter"></i>
  21. </section>
  22. <div class="dropdown" style="display:none;"></div>
  23. <div class="dropdown" style="display:none;"></div>
  24. </section>
  25. <template v-if="userinfo.icon_url">
  26. <el-dropdown class="nav-dropdown">
  27. <el-button type="text" style="color: #515151;font-size: 15px;">
  28. <i class="el-icon-tickets"></i>工作台
  29. </el-button>
  30. <el-dropdown-menu slot="dropdown">
  31. <el-dropdown-item>
  32. <a class="workstation" href="/wo/work_todo">
  33. <i class="el-icon-edit"></i>我的待办
  34. </a>
  35. </el-dropdown-item>
  36. <el-dropdown-item>
  37. <a class="workstation" href="/wo/work_platform">
  38. <i class="el-icon-date"></i>我的项目
  39. </a>
  40. </el-dropdown-item>
  41. <el-dropdown-item>
  42. <a class="workstation" href="/wo/work_hire">
  43. <i class="el-icon-news"></i>我的雇佣
  44. </a>
  45. </el-dropdown-item>
  46. <el-dropdown-item>
  47. <a class="workstation" href="/wo/work_cloud">
  48. <i class="el-icon-service"></i>我的云端
  49. </a>
  50. </el-dropdown-item>
  51. </el-dropdown-menu>
  52. </el-dropdown>
  53. <el-dropdown class="nav-dropdown">
  54. <el-button type="text" class="message-box" style="color: #515151;font-size: 15px;">
  55. <i class="el-icon-message"></i>消息
  56. <span
  57. v-if="messageCount.total > 0"
  58. class="message-count message-total"
  59. >{{messageCount.total}}</span>
  60. </el-button>
  61. <el-dropdown-menu slot="dropdown">
  62. <el-dropdown-item class="message-box" @click.native="clickMessages('/message/system')">
  63. <i class="circle blue"></i>系统消息
  64. <span v-if="messageCount.system" class="message-count">{{messageCount.system}}</span>
  65. </el-dropdown-item>
  66. <el-dropdown-item class="message-box" @click.native="clickMessages('/message/project')">
  67. <i class="circle orange"></i>工作通知
  68. <span v-if="messageCount.work" class="message-count">{{messageCount.work}}</span>
  69. </el-dropdown-item>
  70. <el-dropdown-item class="message-box" @click.native="clickMessages('/message/comment')">
  71. <i class="circle red"></i>评论回复
  72. <span v-if="messageCount.reply" class="message-count">{{messageCount.reply}}</span>
  73. </el-dropdown-item>
  74. <el-dropdown-item class="message-box" @click.native="clickMessages('/message/at')">
  75. <i class="circle green"></i>@我的
  76. <span v-if="messageCount.at" class="message-count">{{messageCount.at}}</span>
  77. </el-dropdown-item>
  78. <el-dropdown-item class="message-box" @click.native="clickMessages('/message/plus')">
  79. <i class="circle pink"></i>赞及其它
  80. <span
  81. v-if="messageCount.community_other"
  82. class="message-count"
  83. >{{messageCount.community_other}}</span>
  84. </el-dropdown-item>
  85. <el-dropdown-item class="message-box" @click.native="clickMessages('/message/coin')">
  86. <i class="circle yellow"></i>收支信息
  87. <span v-if="messageCount.balance" class="message-count">{{messageCount.balance}}</span>
  88. </el-dropdown-item>
  89. </el-dropdown-menu>
  90. </el-dropdown>
  91. <el-popover class="nav-popover" placement="bottom" width="226" trigger="hover">
  92. <section class="ref" slot="reference">
  93. <a class="nav-header" href="/wo/work_todo">
  94. <img class="header-user" :src="userinfo.icon_url" alt="header">
  95. <img
  96. v-if="userinfo.is_vip"
  97. class="header-vip-icon"
  98. :src="`https://dev.test.proginn.com/Public/image/h5/vip_icon${isCom ? '_com' : ''}.png`"
  99. alt="vip-icon"
  100. >
  101. </a>
  102. <span class="nickname">{{userinfo.nickname}}</span>
  103. </section>
  104. <section class="menu">
  105. <section v-if="userinfo.is_vip" class="vip-info vip-info-com">
  106. <section class="vip-info-top">
  107. <img
  108. class="vip-icon"
  109. :src="`https://dev.test.proginn.com/Public/image/h5/vip_icon${isCom ? '_com' : ''}.png`"
  110. alt="vip-icon"
  111. >
  112. <span class="vip-content">
  113. <span class="vip-title" :class="{'is-dev': !isCom}">{{isCom ? '企业会员' : '开发者会员'}}</span>
  114. <br>
  115. <span class="vip-end-date">{{vipInfo.endDate}}到期</span>
  116. </span>
  117. </section>
  118. <section class="vip-arcs">
  119. <a class="vip-arc" :class="{'is-dev': !isCom}" href="/type/vip">查看权益</a>
  120. <a
  121. class="vip-arc"
  122. :class="{'is-dev': !isCom}"
  123. href="/vip/pay?number=3&amp;product_id=1&amp;next=/type/vip"
  124. >立即续费</a>
  125. </section>
  126. </section>
  127. <section class="vip-items">
  128. <a class="vip-item divider" href="/wo/work_platform">
  129. <i class="el-icon-date"></i>我的项目
  130. </a>
  131. <a class="vip-item" href="/wo/work_hire">
  132. <i class="el-icon-news"></i>我的雇佣
  133. </a>
  134. <a class="vip-item" href="/wo/work_cloud">
  135. <i class="el-icon-service"></i>我的云端
  136. </a>
  137. <a class="vip-item divider" :href="`/wo/${userinfo.uid}`">
  138. <i class="el-icon-document"></i>我的主页
  139. </a>
  140. <a class="vip-item" href="/index/app">
  141. <i class="el-icon-view"></i>关注微信
  142. </a>
  143. <a class="vip-item divider" @click="clickQuit">
  144. <i class="el-icon-back"></i>退出
  145. </a>
  146. </section>
  147. </section>
  148. </el-popover>
  149. </template>
  150. <section v-else>
  151. <a class="account-ctrl" href="/?loginbox=show">登录</a>
  152. <a class="account-ctrl" style="margin-left: 40px;" href="/user/register">注册</a>
  153. </section>
  154. </section>
  155. </section>
  156. </template>
  157. <script>
  158. export default {
  159. data() {
  160. return {
  161. // 搜索的关键词
  162. keywork: '',
  163. // 消息数量
  164. messageCount: {},
  165. }
  166. },
  167. computed: {
  168. vipInfo() {
  169. let userinfo = this.userinfo
  170. return {
  171. id: userinfo.vip_type_id,
  172. endDate: userinfo.vip_end_date,
  173. }
  174. },
  175. isCom() {
  176. return this.userinfo.vip_type_id === '1'
  177. }
  178. },
  179. mounted() {
  180. this.getMessageCount()
  181. },
  182. methods: {
  183. async clickQuit() {
  184. location.href = '/user/quit'
  185. },
  186. clickMessages(url) {
  187. location.href = url
  188. },
  189. clickInputEnter() {
  190. window.location.href = '/search/?keyword=' + this.keywork;
  191. },
  192. async getMessageCount() {
  193. let res = await this.$get('/api/message/getUnreadCount', {}, { neverLogout: true })
  194. if(res) {
  195. this.messageCount = res.data
  196. }
  197. }
  198. }
  199. }
  200. </script>
  201. <style scoped>
  202. #proginn-header {
  203. display: flex;
  204. justify-content: center;
  205. width: 100%;
  206. background: white;
  207. }
  208. .list {
  209. display: flex;
  210. justify-content: space-between;
  211. align-items: center;
  212. width: 1000px;
  213. }
  214. .nav-item {
  215. display: flex;
  216. height: 83px;
  217. align-items: center;
  218. font-size: 15px;
  219. color: #515151;
  220. /* padding: 0 15px; */
  221. box-sizing: border-box;
  222. }
  223. .nav-item:first-child {
  224. padding: 0;
  225. }
  226. .nav-item:nth-child(n + 2):hover {
  227. color: #1782d9;
  228. border-top: 5px solid transparent;
  229. border-bottom: 5px solid #1782d9;
  230. }
  231. .nav-dropdown,
  232. .nav-popover {
  233. --imgWidth: 28px;
  234. height: 40px;
  235. display: flex;
  236. align-items: center;
  237. }
  238. .nav-popover > .ref {
  239. display: flex;
  240. align-items: center;
  241. }
  242. .nav-header {
  243. position: relative;
  244. width: var(--imgWidth);
  245. height: var(--imgWidth);
  246. margin-right: 5px;
  247. }
  248. .logo {
  249. width: 140px;
  250. height: auto;
  251. }
  252. .input {
  253. width: 234px;
  254. height: 40px;
  255. border-radius: 20px;
  256. background: #f6f6f6;
  257. padding: 0 40px;
  258. border: 1px solid #ebebeb;
  259. font-size: 13px;
  260. }
  261. .el-icon-search {
  262. position: absolute;
  263. top: 12px;
  264. right: 20px;
  265. color: grey;
  266. cursor: pointer;
  267. }
  268. .el-icon-search::before {
  269. font-size: 14px;
  270. font-weight: 800;
  271. }
  272. i {
  273. margin-right: 4px;
  274. }
  275. i.circle {
  276. display: inline-block;
  277. --width: 12px;
  278. width: var(--width);
  279. height: var(--width);
  280. border-radius: calc(var(--width) / 2);
  281. }
  282. i.blue {
  283. background: #3b83c0;
  284. }
  285. i.orange {
  286. background: #e07b53;
  287. }
  288. i.red {
  289. background: #d95c5c;
  290. }
  291. i.green {
  292. background: #5bbd72;
  293. }
  294. i.pink {
  295. background: #d9499a;
  296. }
  297. i.yellow {
  298. background: #f2c61f;
  299. }
  300. .message-box {
  301. position: relative;
  302. display: flex;
  303. align-items: center;
  304. }
  305. .message-count {
  306. color: white;
  307. margin-left: 4px;
  308. display: block;
  309. line-height: 18px;
  310. padding: 0 8px;
  311. border-radius: 9px;
  312. background: grey;
  313. }
  314. .message-count.message-total {
  315. position: absolute;
  316. top: 0px;
  317. right: -10px;
  318. background: #d95c5c;
  319. }
  320. span.other-icon {
  321. display: block;
  322. margin-left: 30px;
  323. }
  324. .nickname {
  325. font-size: 15px;
  326. }
  327. .vip-info {
  328. display: flex;
  329. flex-direction: column;
  330. justify-content: center;
  331. align-items: center;
  332. width: 206px;
  333. height: 120px;
  334. }
  335. .vip-info-top {
  336. display: flex;
  337. width: 142px;
  338. }
  339. .vip-title {
  340. color: #cb9d53;
  341. font-size: 16px;
  342. line-height: 36px;
  343. }
  344. .vip-icon {
  345. width: 24px;
  346. height: 24px;
  347. margin: 10px 8px 0 0;
  348. }
  349. .vip-end-date {
  350. font-size: 12px;
  351. color: #999;
  352. }
  353. .vip-arcs {
  354. display: flex;
  355. justify-content: space-between;
  356. width: 142px;
  357. margin-top: 11px;
  358. }
  359. .vip-arc {
  360. flex: 1;
  361. font-size: 13px;
  362. color: #cb9d53;
  363. text-align: center;
  364. }
  365. .vip-arc:first-child {
  366. border-right: 1px solid rgba(245, 245, 245, 1);
  367. }
  368. .vip-info-com .vip-title {
  369. color: rgb(113, 177, 253);
  370. }
  371. .vip-info-com .vip-arc {
  372. color: rgb(113, 177, 253);
  373. }
  374. .header-user {
  375. width: var(--imgWidth);
  376. height: var(--imgWidth);
  377. border-radius: 20px;
  378. }
  379. .header-vip-icon {
  380. position: absolute;
  381. top: 16px;
  382. left: 18px;
  383. width: 16px;
  384. height: 16px;
  385. }
  386. .vip-items {
  387. display: flex;
  388. flex-direction: column;
  389. }
  390. .vip-item {
  391. line-height: 32px;
  392. color: #606266;
  393. }
  394. .vip-item > i {
  395. margin: 0 10px;
  396. }
  397. .divider {
  398. border-top: 1px solid rgba(0, 0, 0, 0.05);
  399. margin-top: 10px;
  400. padding-top: 10px;
  401. cursor: pointer;
  402. }
  403. .vip-info-com .is-dev {
  404. color: #cb9d53;
  405. }
  406. .workstation {
  407. color: #606266;
  408. }
  409. .account-ctrl {
  410. color: #606266;
  411. }
  412. #proginn-header a {
  413. text-decoration: none !important;
  414. }
  415. </style>