header.vue 9.5 KB

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