index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <view class="app-container">
  3. <view class="header">
  4. <view class="avatar mr10">
  5. <uv-image width="120rpx" height="120rpx" shape="circle"
  6. :src="userInfo.avatar || '../../static/imgs/tabBar/my-active.png'" />
  7. </view>
  8. <view class="content">
  9. <view class="bold flex align-center">
  10. <text class="ellipsis flex-1">{{ `${userInfo.nickName || '未知用户'}` }}</text>
  11. <!-- <uv-icon name="setting" size="20" color="#fff" @click="onRouterPush('/pages/user/edit')" /> -->
  12. </view>
  13. <view class="info-row">
  14. <text class="ellipsis">{{ userInfo.deptName || '暂无部门' }}</text>
  15. </view>
  16. <view class="info-row">
  17. <text class="ellipsis">{{ userInfo.phone || '暂无手机号' }}</text>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="main">
  22. <!-- 占位预留 -->
  23. </view>
  24. <view class="footer">
  25. <!-- <uv-button customStyle="margin-bottom: 20rpx;" color="#1cb4fd" plain text="修改密码"
  26. @click="onRouterPush('/pages/user/password')"></uv-button> -->
  27. <uv-button type="primary" text="退出登录" @click="signOut"></uv-button>
  28. </view>
  29. </view>
  30. </template>
  31. <script lang="ts" setup>
  32. import { storeToRefs } from 'pinia';
  33. import { useUserStore } from '@/store/modules/user';
  34. const userStore = useUserStore();
  35. const { userInfo } = storeToRefs(userStore);
  36. const signOut = () => {
  37. uni.showModal({
  38. title: '提示',
  39. content: '确认退出登录?',
  40. success: async (res) => {
  41. if (res.confirm) {
  42. // 调用 store 中的注销方法,自动清理缓存
  43. await userStore.logout();
  44. // 跳转回登录页
  45. uni.reLaunch({ url: '/pages/login/index' });
  46. }
  47. }
  48. });
  49. };
  50. </script>
  51. <style lang="scss" scoped>
  52. .app-container {
  53. display: flex;
  54. flex-direction: column;
  55. min-height: calc(100vh - var(--window-top) - var(--window-bottom));
  56. background-color: #f5f7fa;
  57. padding: 20rpx;
  58. box-sizing: border-box;
  59. .header {
  60. background-color: #1c9bfd;
  61. color: #fff;
  62. padding: 30rpx 40rpx;
  63. border-radius: 16rpx;
  64. display: flex;
  65. align-items: center;
  66. box-shadow: 0 4rpx 16rpx rgba(28, 155, 253, 0.3);
  67. .avatar {
  68. margin-right: 30rpx;
  69. flex-shrink: 0;
  70. background-color: #fff;
  71. border-radius: 50%;
  72. padding: 4rpx;
  73. /* 白色边框效果 */
  74. }
  75. .content {
  76. flex: 1;
  77. display: flex;
  78. flex-direction: column;
  79. justify-content: space-around;
  80. overflow: hidden;
  81. .bold {
  82. font-weight: bold;
  83. font-size: 36rpx;
  84. margin-bottom: 10rpx;
  85. }
  86. .info-row {
  87. font-size: 26rpx;
  88. margin-top: 8rpx;
  89. opacity: 0.9;
  90. }
  91. .ellipsis {
  92. overflow: hidden;
  93. white-space: nowrap;
  94. text-overflow: ellipsis;
  95. display: block;
  96. }
  97. .flex-1 {
  98. flex: 1;
  99. }
  100. }
  101. }
  102. .main {
  103. flex: 1;
  104. overflow-y: auto;
  105. }
  106. .footer {
  107. flex: 0 0 auto;
  108. margin: 40rpx 0 10rpx;
  109. }
  110. }
  111. .mr10 {
  112. margin-right: 20rpx;
  113. }
  114. .flex {
  115. display: flex;
  116. }
  117. .align-center {
  118. align-items: center;
  119. }
  120. </style>