header.vue 11 KB

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