top-box.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <view>
  3. <view class="no-login" v-if="!userinfo.token" @click="goLogin">
  4. <view class="avatar"><image src="../../static/no-login.png"></image></view>
  5. <view class="context">您好,请授权登录</view>
  6. </view>
  7. <view class="login" @click="getnickName" v-else>
  8. <view class="avatar">
  9. <image :src="userinfo.avatar ? userinfo.avatar : defaultimg"></image>
  10. </view>
  11. <image src="../../static/edit.png" v-if="keys==2" class="edit"></image>
  12. <view class="info">
  13. <view class="top">
  14. <view class="name">{{userinfo.nickName || '小狸'}}</view>
  15. <view class="join">
  16. <image src="../../static/ucenter/icon1.png"></image>
  17. <view class="days">已加入{{days}}天</view>
  18. </view>
  19. </view>
  20. <view class="phone">
  21. <view><image src="../../static/ucenter/icon2.png"></image></view>
  22. <view>{{userinfo.telephone}}</view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. name:"top-box",
  31. props:['userinfo','days','keys'],
  32. data(){
  33. return{
  34. defaultimg:'../../static/no-login.png',
  35. editLogo:'../../static/edit-logo.png'
  36. }
  37. },
  38. methods:{
  39. getnickName(){
  40. // this.$store.state.users.avatar == null &&
  41. if(this.keys ==2){
  42. uni.navigateTo({
  43. url:'/pages/ucenter/set_avatar'
  44. })
  45. }
  46. },
  47. goLogin(){
  48. uni.navigateTo({
  49. url:'/pages/public/login'
  50. })
  51. }
  52. }
  53. }
  54. </script>
  55. <style lang="scss" scoped>
  56. .no-login{
  57. margin-top: 15rpx;
  58. display: flex;
  59. .avatar image{
  60. width: 70rpx;
  61. height: 70rpx;
  62. margin: 0 20rpx;
  63. }
  64. .context{
  65. color: #58be6b;
  66. font-size: 32rpx;
  67. font-weight: bold;
  68. line-height: 70rpx;
  69. }
  70. }
  71. .login{
  72. margin-top: 15rpx;
  73. display: flex;
  74. position: relative;
  75. .avatar{
  76. image:first-child{
  77. width: 110rpx;
  78. height: 110rpx;
  79. margin-left: 30rpx;
  80. margin-right: 10rpx;
  81. border-radius: 50%;
  82. }
  83. }
  84. .edit{
  85. width: 36rpx;
  86. height: 36rpx;
  87. position:absolute;
  88. left: 100rpx;
  89. bottom: 5rpx;
  90. }
  91. .info{
  92. display: flex;
  93. flex-direction: column;
  94. height: 100rpx;
  95. justify-content:space-between;
  96. padding-top: 10rpx;
  97. margin-left: 5rpx;
  98. .top{
  99. display: flex;
  100. .join{
  101. display: flex;
  102. margin-left: 12rpx;
  103. position: relative;
  104. image{
  105. width: 42rpx;
  106. height: 48rpx;
  107. position: absolute;
  108. }
  109. .days{
  110. background-color: #f5f5f5;
  111. height: 44rpx;
  112. padding: 0 20rpx;
  113. margin-left: 20rpx;
  114. margin-top: 5rpx;
  115. border-top-right-radius:20rpx;
  116. border-bottom-right-radius:20rpx;
  117. font-size: 24rpx;
  118. color: #86909c;
  119. line-height: 44rpx;
  120. }
  121. }
  122. .name{
  123. color: #1d2129;
  124. font-size: 36rpx;
  125. font-weight: bold;
  126. }
  127. }
  128. .phone{
  129. display: flex;
  130. font-size: 24rpx;
  131. color: #86909c;
  132. line-height: 36rpx;
  133. image{
  134. width: 36rpx;
  135. height: 36rpx;
  136. }
  137. }
  138. }
  139. }
  140. </style>