header.vue 11 KB

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