personal_message.vue 3.1 KB

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