personal_message.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <view class="container">
  3. <!-- 用户头像 -->
  4. <image :src="headImg" class="avatar"></image>
  5. <!-- 用户名及职位 -->
  6. <text class="username">{{ userInfo.name }}</text>
  7. <view class="position" v-for="(item,index) in userInfo.department" :key="index">
  8. {{ item.departmentName }}--{{item.position}}
  9. </view>
  10. <!-- 联系方式 -->
  11. <view class="contact-info">
  12. <view class="info-item">
  13. <view>
  14. <uni-icons type="phone" size="20"></uni-icons>
  15. <text>手机</text>
  16. </view>
  17. <text class="lastText">{{ userInfo.desktop_phone || '暂无' }}</text>
  18. </view>
  19. <view class="info-item">
  20. <view>
  21. <uni-icons type="email" size="20"></uni-icons>
  22. <text>邮箱</text>
  23. </view>
  24. <text class="lastText">{{ userInfo.email || '暂无' }}</text>
  25. </view>
  26. </view>
  27. <!-- 个人信息 -->
  28. <view class="personal-info">
  29. <view class="info-item">
  30. <view>
  31. <uni-icons type="person" size="20"></uni-icons>
  32. <text>性别</text>
  33. </view>
  34. <text class="lastText">{{ userInfo.sex || '暂无' }}</text>
  35. </view>
  36. <view class="info-item">
  37. <view>
  38. <uni-icons type="star" size="20"></uni-icons>
  39. <text>生日</text>
  40. </view>
  41. <text class="lastText">{{ userInfo.birthday || '暂无' }}</text>
  42. </view>
  43. </view>
  44. </view>
  45. </template>
  46. <script setup>
  47. import { ref } from 'vue';
  48. import headImg from "@/static/images/mine/headImg.jpg";
  49. import { onLoad } from '@dcloudio/uni-app'
  50. import { getUserInfo } from '@/api/mine.js'
  51. import { useUserStore } from '@/store/user.js'
  52. const userStore = useUserStore()
  53. const userInfo = ref({})
  54. // 监听页面加载
  55. onLoad((options) => {
  56. console.log('options.useId', options.useId);
  57. console.log('options', !options.useId);
  58. if (!options.useId) {
  59. // 获取传入的标题参数
  60. userInfo.value = userStore.user
  61. } else {
  62. getUserInfo(options.useId).then((res) => {
  63. userInfo.value = res.returnParams[0]
  64. })
  65. }
  66. const name = userInfo.value.name;
  67. if (name) {
  68. // 设置导航栏标题
  69. uni.setNavigationBarTitle({
  70. title: name + "的信息"
  71. });
  72. }
  73. })
  74. </script>
  75. <style lang="scss" scoped>
  76. .container {
  77. padding: 20px;
  78. background-color: #f8f8f8;
  79. height: 100vh;
  80. box-sizing: border-box;
  81. }
  82. .avatar {
  83. width: 80px;
  84. height: 80px;
  85. border-radius: 50%;
  86. margin-bottom: 15px;
  87. display: block;
  88. margin-left: auto;
  89. margin-right: auto;
  90. }
  91. .username {
  92. font-size: 18px;
  93. }
  94. .position {
  95. font-size: 14px;
  96. color: #666;
  97. margin: 10px auto;
  98. }
  99. .contact-info,
  100. .personal-info {
  101. background-color: #fff;
  102. border-radius: 8px;
  103. overflow: hidden;
  104. margin-bottom: 15px;
  105. }
  106. .info-item {
  107. padding: 12px 16px;
  108. border-top: 1px solid #eee;
  109. font-size: 16px;
  110. display: flex;
  111. justify-content: space-between;
  112. align-items: center;
  113. }
  114. .lastText {
  115. color: #999;
  116. }
  117. </style>