my.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <view class="my-box">
  3. <view class="my-content">
  4. <view class="my-top"></view>
  5. <image class="my-avatar" @tap="$navigateTo('/subPages/myPage/myDetail/myDetail')" :src="user.portrait" mode="aspectFill"></image>
  6. <view class="name" @tap="$navigateTo('/subPages/myPage/myDetail/myDetail')">{{user.userName || '登录/注册'}}</view>
  7. <view class="organization" v-if="user.organizedName">{{user.organizedName}}</view>
  8. <view class="my-list">
  9. <view class="my-list-box">
  10. <view class="my-item" @tap="$navigateTo('/subPages/myPage/organization/organization')">
  11. <view class="my-icon bg3">
  12. <uv-icon name="home-fill" color="#fff" size="56"></uv-icon>
  13. </view>
  14. <view class="item-content">
  15. 我的公司
  16. </view>
  17. <view class="my-forward">
  18. <uv-icon name="arrow-right" color="#c1c0c8" size="32"></uv-icon>
  19. </view>
  20. </view>
  21. <view class="my-item" @tap="$navigateTo('/subPages/myPage/download/download')">
  22. <view class="my-icon bg5">
  23. <uv-icon name="grid-fill" color="#fff" size="56"></uv-icon>
  24. </view>
  25. <view class="item-content">
  26. 我的下载
  27. </view>
  28. <view class="my-forward">
  29. <uv-icon name="arrow-right" color="#c1c0c8" size="32"></uv-icon>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. export default {
  39. data() {
  40. return {
  41. fansCount: {
  42. attentionCount: 0,
  43. fansCount: 0,
  44. roomCount: 0
  45. },
  46. user: {}
  47. }
  48. },
  49. onShow() {
  50. if (!uni.getStorageSync('token')) {
  51. this.user = {};
  52. this.fansCount = {
  53. attentionCount: 0,
  54. fansCount: 0,
  55. roomCount: 0
  56. }
  57. } else {
  58. this.user = this.$store.getters.user;
  59. this.user.organizedName = this.$store.getters.organization && this.$store.getters.organization.name;
  60. }
  61. },
  62. methods: {
  63. init() {
  64. getMyCount().then(res => {
  65. if (res.code === 200) {
  66. this.fansCount = res.data;
  67. }
  68. })
  69. getUserInfoById(this.user.userId).then(res => {
  70. if (res.code === 200) {
  71. this.user = res.data;
  72. this.user['userName'] = res.data.name;
  73. this.user['userId'] = res.data.id;
  74. this.user.organizedName = res.data.mgrOrganization && res.data.mgrOrganization.name;
  75. this.$store.dispatch('app/changeUser', res.data);
  76. }
  77. })
  78. }
  79. }
  80. }
  81. </script>
  82. <style lang="scss">
  83. .my-box {
  84. height: 100vh;
  85. background: #fff;
  86. overflow-y: auto;
  87. .my-content {
  88. display: flex;
  89. flex-direction: column;
  90. align-items: center;
  91. padding-bottom: 80rpx;
  92. }
  93. .my-top {
  94. height: 260rpx;
  95. background-image: url('https://images.unsplash.com/photo-1558591710-4b4a1ae0f04d?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwyMDUzMDJ8MHwxfHNlYXJjaHw1fHxhYnN0cmFjdHxlbnwxfHx8fDE2NTI4OTYzNTU&ixlib=rb-1.2.1&q=80&w=1080');
  96. background-position: center center;
  97. background-size: cover;
  98. background-repeat: no-repeat;
  99. width: 100%;
  100. }
  101. .my-avatar {
  102. width: 200rpx;
  103. height: 200rpx;
  104. border-radius: 50%;
  105. margin-top: -100rpx;
  106. border: 6rpx solid #fff;
  107. background: #eee;
  108. }
  109. .name {
  110. font-size: 20px;
  111. font-weight: 700;
  112. margin: 10rpx 0;
  113. }
  114. .organization {
  115. font-weight: 300;
  116. }
  117. .my-list {
  118. width: 100%;
  119. padding: 60rpx 30rpx 30rpx 30rpx;
  120. box-sizing: border-box;
  121. .my-list-box {
  122. border-radius: 24rpx;
  123. box-shadow: 1px 1px 12px rgba(164, 164, 164, 0.25);
  124. overflow: hidden;
  125. }
  126. .my-item {
  127. display: flex;
  128. align-items: center;
  129. padding: 20rpx 30rpx;
  130. }
  131. .my-icon {
  132. width: 80rpx;
  133. height: 80rpx;
  134. border-radius: 16rpx;
  135. display: flex;
  136. align-items: center;
  137. justify-content: center;
  138. margin-right: 20rpx;
  139. background: #c1c0c8;
  140. &.bg1 {
  141. background: #88d498;
  142. }
  143. &.bg2 {
  144. background: #ffb997;
  145. }
  146. &.bg3 {
  147. background: #7ad9ff;
  148. }
  149. &.bg4 {
  150. background: #9ac0cd;
  151. }
  152. &.bg5 {
  153. background: #40e0d0;
  154. }
  155. }
  156. .item-content {
  157. flex: 1;
  158. width: 0;
  159. overflow: hidden;
  160. font-weight: 700;
  161. }
  162. }
  163. }
  164. </style>