systemSet.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <view class="my-container">
  3. <!-- 用户信息卡片 -->
  4. <view class="user-card">
  5. <view class="avatar">
  6. <image
  7. :src="userInfo.avatar || '/static/default-avatar.png'"
  8. mode="aspectFill"
  9. ></image>
  10. </view>
  11. <view class="user-info">
  12. <view class="info-item">
  13. <text class="label">姓名:</text>
  14. <text class="value">{{ userInfo.nickname || "未设置" }}</text>
  15. </view>
  16. <view class="info-item">
  17. <text class="label">手机号:</text>
  18. <text class="value">{{ userInfo.phone || "-" }}</text>
  19. </view>
  20. </view>
  21. </view>
  22. <!-- 退出按钮 -->
  23. <view class="logout-section">
  24. <button class="logout-btn" @click="handleLogout">退出账号</button>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. data() {
  31. return {
  32. userInfo: uni.getStorageSync("userInfo").user || {},
  33. };
  34. },
  35. methods: {
  36. handleLogout() {
  37. uni.showModal({
  38. title: "提示",
  39. content: "确定要退出账号吗?",
  40. success: (res) => {
  41. if (res.confirm) {
  42. // 清除token和用户信息
  43. uni.removeStorageSync("token");
  44. uni.removeStorageSync("userInfo");
  45. // 跳转到登录页
  46. uni.reLaunch({
  47. url: "/pages/login/login",
  48. });
  49. }
  50. },
  51. });
  52. },
  53. },
  54. };
  55. </script>
  56. <style lang="scss" scoped>
  57. .my-container {
  58. min-height: 100vh;
  59. background: linear-gradient(#cfddfc 0%, #e6eeff 10%, #fff 100%);
  60. padding: 30rpx;
  61. }
  62. .user-card {
  63. background-color: #fff;
  64. border-radius: 16rpx;
  65. padding: 40rpx;
  66. margin-bottom: 30rpx;
  67. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
  68. .avatar {
  69. text-align: center;
  70. margin-bottom: 30rpx;
  71. image {
  72. width: 150rpx;
  73. height: 150rpx;
  74. border-radius: 75rpx;
  75. border: 4rpx solid #e6eeff;
  76. }
  77. }
  78. .user-info {
  79. .info-item {
  80. display: flex;
  81. padding: 20rpx 0;
  82. border-bottom: 1rpx solid #eee;
  83. &:last-child {
  84. border-bottom: none;
  85. }
  86. .label {
  87. width: 160rpx;
  88. color: #666;
  89. font-size: 28rpx;
  90. }
  91. .value {
  92. flex: 1;
  93. color: #333;
  94. font-size: 28rpx;
  95. }
  96. }
  97. }
  98. }
  99. .logout-section {
  100. margin-top: 60rpx;
  101. padding: 0 40rpx;
  102. .logout-btn {
  103. width: 100%;
  104. height: 88rpx;
  105. line-height: 88rpx;
  106. background-color: #f44336;
  107. color: #fff;
  108. font-size: 32rpx;
  109. border-radius: 44rpx;
  110. &:active {
  111. opacity: 0.8;
  112. }
  113. }
  114. }
  115. </style>