index.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <view class="personal-center">
  3. <!-- 用户信息卡片 -->
  4. <view class="user-card">
  5. <image class="avatar" src="/static/tabbar/personal.png" mode="aspectFill" />
  6. </view>
  7. <view class="user-info">
  8. <text class="username">用户名</text>
  9. <text class="phone">138****8888</text>
  10. </view>
  11. <button class="logout-btn" @click="logout">退出登录</button>
  12. </view>
  13. </template>
  14. <script>
  15. export default {
  16. methods: {
  17. navigateTo(url) {
  18. uni.navigateTo({ url });
  19. },
  20. logout() {
  21. uni.showModal({
  22. title: '提示',
  23. content: '确定要退出登录吗?',
  24. success: (res) => {
  25. if (res.confirm) {
  26. uni.removeStorageSync('token');
  27. uni.reLaunch({ url: '/pages/auth/login' });
  28. }
  29. }
  30. });
  31. }
  32. }
  33. };
  34. </script>
  35. <style scoped>
  36. .personal-center {
  37. padding: 0px;
  38. background-color: #f7f7f7;
  39. min-height: 150vh;
  40. }
  41. .user-card {
  42. display: flex;
  43. justify-content: center; /* 水平居中 */
  44. align-items: center; /* 垂直居中 */
  45. padding: 20px;
  46. height: 9.5rem;
  47. background-color: #2164cb;
  48. /* border-radius: 10px;
  49. margin-bottom: 20px; */
  50. }
  51. .avatar {
  52. background-color:#f7f7f7;
  53. width: 80px;
  54. height: 80px;
  55. border-radius: 50%;
  56. /* margin-right: 15px; */
  57. }
  58. .user-info {
  59. margin-top: -20px;
  60. margin-left: 20px; /* 左右留白 */
  61. margin-right: 20px;
  62. border-radius: 10px;
  63. background-color: #fff;
  64. height: 200px;
  65. position: relative;
  66. z-index: 1
  67. }
  68. .username {
  69. font-size: 18px;
  70. font-weight: bold;
  71. margin-bottom: 5px;
  72. }
  73. .phone {
  74. font-size: 14px;
  75. color: #999;
  76. }
  77. </style>