like-header.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <view class="header flex row-between">
  3. <router-link class="photo" to="/bundle_b/pages/published_works/published_works">
  4. <!-- <u-image src="/static/images/icon_photo.png" width="60" height="60" borderRadius="50%"></u-image> -->
  5. <text class="iconfont">&#xe620;</text>
  6. </router-link>
  7. <view class="mainnav flex">
  8. <view class="mainnav--item" :class="{'active': current === 0}" @click="changeNav(0)">
  9. <text>关注</text>
  10. <text v-if="hasNew" class="new"></text>
  11. </view>
  12. <view class="mainnav--item" :class="{'active': current === 1}" @click="changeNav(1)">
  13. <text>发现</text>
  14. </view>
  15. </view>
  16. <view class="user flex row-right">
  17. <router-link to="/bundle_b/pages/community_search/community_search">
  18. <u-icon v-if="current==0" name="search" size="34" class="m-r-20" ></u-icon>
  19. </router-link>
  20. <router-link to="/bundle_b/pages/community_user/community_user">
  21. <u-image :src="userInfo.avatar?userInfo.avatar:'/static/images/portrait_empty.png'" width="60" height="60" borderRadius="50%"></u-image>
  22. </router-link>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import {
  28. mapGetters
  29. } from "vuex"
  30. export default {
  31. name: 'like-header',
  32. props: {
  33. current: {
  34. type: Number,
  35. default: 1
  36. }
  37. },
  38. data() {
  39. return {
  40. hasNew: false
  41. }
  42. },
  43. created() {
  44. uni.$on('hasNew', item => {
  45. this.hasNew = item
  46. })
  47. },
  48. methods: {
  49. changeNav(index) {
  50. if(!this.isLogin) return this.$Router.push('/pages/login/login')
  51. this.$emit('change', index);
  52. }
  53. },
  54. computed: {
  55. ...mapGetters(['userInfo'])
  56. }
  57. }
  58. </script>
  59. <style lang="scss" scoped>
  60. page{
  61. background: linear-gradient(180deg, rgba(243, 244, 246, 0.98) 0%, #F4E4E4 37%, #F4ECED 69%, #F3ECED 85%, #F3F4F6 100%);
  62. }
  63. .header {
  64. padding: 16rpx 24rpx;
  65. background-color:transparent;
  66. .photo {
  67. width: 120rpx;
  68. .iconfont{
  69. font-size: 44rpx;
  70. }
  71. }
  72. .mainnav {
  73. &--item {
  74. width: 120rpx;
  75. font-size: 32rpx;
  76. font-weight: 500;
  77. text-align: center;
  78. color: #BBBBBB;
  79. transition: all .2s linear;
  80. .new {
  81. width: 10rpx;
  82. height: 10rpx;
  83. border-radius: 50%;
  84. display: inline-block;
  85. margin-bottom: 24rpx;
  86. background-color: $-color-primary;
  87. }
  88. }
  89. .active {
  90. color: #000000;
  91. }
  92. }
  93. .user {
  94. width: 120rpx;
  95. }
  96. }
  97. </style>