header.vue 11 KB

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