index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <view class="user">
  3. <view class="user-top">
  4. <view class="user-top-title">个人中心</view>
  5. <view class="user-info">
  6. <image :src="avatorUrl" mode="aspectFill" class="user-avator" @error="onAvatorError"></image>
  7. <text class="user-username">{{ userName }}</text>
  8. </view>
  9. </view>
  10. <uni-list>
  11. <uni-list-item title="设置" thumb="/static/images/user/settings.svg" thumbSize="sm" link
  12. to="/pages/user/settings/settings"></uni-list-item>
  13. <uni-list-item title="关于系统" thumb="/static/images/user/info.svg" thumbSize="sm"
  14. :rightText="versionNumber"></uni-list-item>
  15. </uni-list>
  16. <button class="user-logout" @click="logout">退出登录</button>
  17. </view>
  18. </template>
  19. <script setup>
  20. import { ref,reactive } from 'vue';
  21. import { useUserStore, useAppStore } from '@/store/index.js';
  22. const userStore = useUserStore();
  23. const appStore = useAppStore()
  24. const userInfo = userStore.userInfo || uni.getStorageSync('userInfo')
  25. const version = appStore.sysVersion || uni.getStorageSync('version')
  26. console.log(userInfo)
  27. const avatorDefault = '/static/images/user/avator_default.svg'
  28. const avatorUrl = ref(userInfo.avatar || avatorDefault)
  29. const userName = ref(userInfo.realName)
  30. const versionNumber = ref(`v${version}`)
  31. const onAvatorError= () => {
  32. console.log(111)
  33. avatorUrl.value = '/static/images/user/avator_default.svg'
  34. }
  35. const logout = ()=>{
  36. userStore.logoutAction()
  37. }
  38. </script>
  39. <style lang="scss" scoped>
  40. .user {
  41. height: calc(100vh - var(--window-top) - var(--window-bottom));
  42. position: relative;
  43. background-color: #efefef;
  44. &-top {
  45. height: 400rpx;
  46. background-image: url('@/static/images/user/user_bg.png');
  47. background-repeat: no-repeat;
  48. background-size: 100% 100%;
  49. display: flex;
  50. align-items: flex-end;
  51. &-title {
  52. color: #ffffff;
  53. font-size: 36rpx;
  54. position: absolute;
  55. top: calc(var(--status-bar-height) + 30rpx);
  56. text-align: center;
  57. display: block;
  58. width: 100%;
  59. }
  60. }
  61. &-info {
  62. margin-bottom: 80rpx;
  63. padding-left: 40rpx;
  64. display: flex;
  65. align-items: center;
  66. }
  67. &-avator {
  68. width: 128rpx;
  69. height: 128rpx;
  70. margin-right: 30rpx;
  71. border-radius: 50%;
  72. }
  73. &-username {
  74. font-family: 思源黑体;
  75. font-size: 40rpx;
  76. font-weight: bold;
  77. color: #ffffff;
  78. }
  79. &-logout {
  80. margin-top: 60rpx;
  81. border-radius: 0%;
  82. background-color: #ffffff;
  83. color: $uni-color-primary;
  84. font-size: 30rpx;
  85. font-family: 思源黑体;
  86. height: 110rpx;
  87. display: flex;
  88. align-items: center;
  89. justify-content: center;
  90. &:focus,
  91. &:active {
  92. opacity: 0.8;
  93. }
  94. }
  95. }
  96. </style>