header.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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;">
  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;">
  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.vip_type_id"
  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.vip_type_id" 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. userinfo() {
  169. return this.$store.state.userinfo
  170. },
  171. vipInfo() {
  172. let userinfo = this.userinfo
  173. return {
  174. id: userinfo.vip_type_id,
  175. endDate: userinfo.vip_end_date,
  176. }
  177. },
  178. isCom() {
  179. return this.userinfo.vip_type_id === '1'
  180. }
  181. },
  182. mounted() {
  183. this.getMessageCount()
  184. },
  185. methods: {
  186. async clickQuit() {
  187. location.href = '/user/quit'
  188. },
  189. clickMessages(url) {
  190. location.href = url
  191. },
  192. clickInputEnter() {
  193. window.location.href = '/search/?keyword=' + this.keywork;
  194. },
  195. async getMessageCount() {
  196. let res = await this.$get('/api/message/getUnreadCount', {}, { neverLogout: true })
  197. if(res) {
  198. this.messageCount = res.data
  199. }
  200. }
  201. }
  202. }
  203. </script>
  204. <style scoped>
  205. #proginn-header {
  206. display: flex;
  207. justify-content: center;
  208. width: 100%;
  209. background: white;
  210. }
  211. .list {
  212. display: flex;
  213. justify-content: space-between;
  214. align-items: center;
  215. width: 1000px;
  216. }
  217. .nav-item {
  218. display: flex;
  219. height: 75px;
  220. align-items: center;
  221. font-size: 15px;
  222. color: #515151;
  223. padding: 0 15px;
  224. box-sizing: border-box;
  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. }
  260. .el-icon-search {
  261. position: absolute;
  262. top: 12px;
  263. right: 20px;
  264. color: grey;
  265. cursor: pointer;
  266. }
  267. .el-icon-search::before {
  268. font-size: 14px;
  269. font-weight: 800;
  270. }
  271. i {
  272. margin-right: 4px;
  273. }
  274. i.circle {
  275. display: inline-block;
  276. --width: 12px;
  277. width: var(--width);
  278. height: var(--width);
  279. border-radius: calc(var(--width) / 2);
  280. }
  281. i.blue {
  282. background: #3b83c0;
  283. }
  284. i.orange {
  285. background: #e07b53;
  286. }
  287. i.red {
  288. background: #d95c5c;
  289. }
  290. i.green {
  291. background: #5bbd72;
  292. }
  293. i.pink {
  294. background: #d9499a;
  295. }
  296. i.yellow {
  297. background: #f2c61f;
  298. }
  299. .message-box {
  300. position: relative;
  301. display: flex;
  302. align-items: center;
  303. }
  304. .message-count {
  305. color: white;
  306. margin-left: 4px;
  307. display: block;
  308. line-height: 18px;
  309. padding: 0 8px;
  310. border-radius: 9px;
  311. background: grey;
  312. }
  313. .message-count.message-total {
  314. position: absolute;
  315. top: 0px;
  316. right: -10px;
  317. background: #d95c5c;
  318. }
  319. span.other-icon {
  320. display: block;
  321. margin-left: 30px;
  322. }
  323. .nickname {
  324. font-size: 15px;
  325. }
  326. .vip-info {
  327. display: flex;
  328. flex-direction: column;
  329. justify-content: center;
  330. align-items: center;
  331. width: 206px;
  332. height: 120px;
  333. }
  334. .vip-info-top {
  335. display: flex;
  336. width: 142px;
  337. }
  338. .vip-title {
  339. color: #cb9d53;
  340. font-size: 16px;
  341. line-height: 36px;
  342. }
  343. .vip-icon {
  344. width: 24px;
  345. height: 24px;
  346. margin: 10px 8px 0 0;
  347. }
  348. .vip-end-date {
  349. font-size: 12px;
  350. color: #999;
  351. }
  352. .vip-arcs {
  353. display: flex;
  354. justify-content: space-between;
  355. width: 142px;
  356. margin-top: 11px;
  357. }
  358. .vip-arc {
  359. flex: 1;
  360. font-size: 13px;
  361. color: #cb9d53;
  362. text-align: center;
  363. }
  364. .vip-arc:first-child {
  365. border-right: 1px solid rgba(245, 245, 245, 1);
  366. }
  367. .vip-info-com .vip-title {
  368. color: rgb(113, 177, 253);
  369. }
  370. .vip-info-com .vip-arc {
  371. color: rgb(113, 177, 253);
  372. }
  373. .header-user {
  374. width: var(--imgWidth);
  375. height: var(--imgWidth);
  376. border-radius: 20px;
  377. }
  378. .header-vip-icon {
  379. position: absolute;
  380. top: 16px;
  381. left: 18px;
  382. width: 16px;
  383. height: 16px;
  384. }
  385. .vip-items {
  386. display: flex;
  387. flex-direction: column;
  388. }
  389. .vip-item {
  390. line-height: 32px;
  391. color: #606266;
  392. }
  393. .vip-item > i {
  394. margin: 0 10px;
  395. }
  396. .divider {
  397. border-top: 1px solid rgba(0, 0, 0, 0.05);
  398. margin-top: 10px;
  399. padding-top: 10px;
  400. cursor: pointer;
  401. }
  402. .vip-info-com .is-dev {
  403. color: #cb9d53;
  404. }
  405. .workstation {
  406. color: #606266;
  407. }
  408. .account-ctrl {
  409. color: #606266;
  410. }
  411. #proginn-header a {
  412. text-decoration: none !important;
  413. }
  414. </style>