my.vue 3.9 KB

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