header.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  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"></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. this.updateUserinfo({
  193. userinfo: res.data
  194. })
  195. },
  196. clickInputEnter() {
  197. this.$router.push({
  198. path: '/search',
  199. query: {
  200. keyword: this.keywork
  201. }
  202. })
  203. },
  204. async getMessageCount() {
  205. let res = await this.$get('/api/message/getUnreadCount', { neverLogout: true })
  206. this.messageCount = res.data
  207. }
  208. }
  209. }
  210. </script>
  211. <style scoped>
  212. #proginn-header {
  213. display: flex;
  214. justify-content: center;
  215. width: 100%;
  216. background: white;
  217. }
  218. .list {
  219. display: flex;
  220. justify-content: space-between;
  221. align-items: center;
  222. width: 1000px;
  223. }
  224. .nav-item {
  225. display: flex;
  226. height: 80px;
  227. align-items: center;
  228. font-size: 15px;
  229. color: #515151;
  230. }
  231. .nav-dropdown,
  232. .nav-popover {
  233. --imgWidth: 28px;
  234. height: 40px;
  235. }
  236. .nav-popover > .ref {
  237. display: flex;
  238. align-items: center;
  239. }
  240. .nav-header {
  241. position: relative;
  242. width: var(--imgWidth);
  243. height: var(--imgWidth);
  244. margin-right: 10px;
  245. }
  246. .logo {
  247. width: 120px;
  248. height: auto;
  249. }
  250. .input {
  251. width: 234px;
  252. height: 40px;
  253. border-radius: 20px;
  254. background: #f6f6f6;
  255. padding: 0 40px;
  256. }
  257. .el-icon-search {
  258. position: absolute;
  259. top: 12px;
  260. right: 20px;
  261. transform: scale(1.5);
  262. color: grey;
  263. }
  264. i {
  265. margin-right: 4px;
  266. }
  267. i.circle {
  268. display: inline-block;
  269. --width: 12px;
  270. width: var(--width);
  271. height: var(--width);
  272. border-radius: calc(var(--width) / 2);
  273. }
  274. i.blue {
  275. background: #3b83c0;
  276. }
  277. i.orange {
  278. background: #e07b53;
  279. }
  280. i.red {
  281. background: #d95c5c;
  282. }
  283. i.green {
  284. background: #5bbd72;
  285. }
  286. i.pink {
  287. background: #d9499a;
  288. }
  289. i.yellow {
  290. background: #f2c61f;
  291. }
  292. .message-box {
  293. position: relative;
  294. display: flex;
  295. align-items: center;
  296. }
  297. .message-count {
  298. color: white;
  299. margin-left: 4px;
  300. display: block;
  301. line-height: 18px;
  302. padding: 0 8px;
  303. border-radius: 9px;
  304. background: grey;
  305. }
  306. .message-count.message-total {
  307. position: absolute;
  308. top: 0px;
  309. right: -10px;
  310. background: #d95c5c;
  311. }
  312. span.other-icon {
  313. display: block;
  314. margin-left: 30px;
  315. }
  316. .vip-info {
  317. display: flex;
  318. flex-direction: column;
  319. justify-content: center;
  320. align-items: center;
  321. width: 206px;
  322. height: 120px;
  323. }
  324. .vip-info-top {
  325. display: flex;
  326. width: 142px;
  327. }
  328. .vip-title {
  329. color: #cb9d53;
  330. font-size: 16px;
  331. line-height: 36px;
  332. }
  333. .vip-icon {
  334. width: 24px;
  335. height: 24px;
  336. margin: 10px 8px 0 0;
  337. }
  338. .vip-end-date {
  339. font-size: 12px;
  340. color: #999;
  341. }
  342. .vip-arcs {
  343. display: flex;
  344. justify-content: space-between;
  345. width: 142px;
  346. margin-top: 11px;
  347. }
  348. .vip-arc {
  349. flex: 1;
  350. font-size: 13px;
  351. color: #cb9d53;
  352. text-align: center;
  353. }
  354. .vip-arc:first-child {
  355. border-right: 1px solid rgba(245, 245, 245, 1);
  356. }
  357. .vip-info-com .vip-title {
  358. color: rgb(113, 177, 253);
  359. }
  360. .vip-info-com .vip-arc {
  361. color: rgb(113, 177, 253);
  362. }
  363. .header-user {
  364. width: var(--imgWidth);
  365. height: var(--imgWidth);
  366. border-radius: 20px;
  367. }
  368. .header-vip-icon {
  369. position: absolute;
  370. top: 16px;
  371. left: 18px;
  372. width: 16px;
  373. height: 16px;
  374. }
  375. .vip-items {
  376. display: flex;
  377. flex-direction: column;
  378. }
  379. .vip-item {
  380. line-height: 32px;
  381. color: #606266;
  382. }
  383. .vip-item > i {
  384. margin: 0 10px;
  385. }
  386. .divider {
  387. border-top: 1px solid rgba(0, 0, 0, 0.05);
  388. margin-top: 10px;
  389. padding-top: 10px;
  390. cursor: pointer;
  391. }
  392. .vip-info-com .is-dev {
  393. color: #cb9d53;
  394. }
  395. .workstation {
  396. color: #606266;
  397. }
  398. .account-ctrl {
  399. color: #606266;
  400. }
  401. </style>