personal_message.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <page-meta root-font-size="system" />
  3. <view class="container">
  4. <!-- 用户头像 -->
  5. <image :src="headImg" class="avatar"></image>
  6. <!-- 用户名及职位 -->
  7. <text class="username">{{ userInfo.name }}</text>
  8. <view class="position" v-for="(item,index) in userInfo.groupXUsers" :key="index">
  9. {{ item.groupName }}--{{item.posName||'暂无'}}
  10. </view>
  11. <!-- <view class="position" >
  12. {{ userInfo.deptName }}--{{userInfo.positionName}}
  13. </view> -->
  14. <!-- 联系方式 -->
  15. <view class="contact-info">
  16. <view class="info-item">
  17. <view>
  18. <uni-icons type="phone" size="20"></uni-icons>
  19. <text>手机</text>
  20. </view>
  21. <text v-if="userInfo.desktop_phone==null" class="lastText">{{ '暂无' }}</text>
  22. <text v-else class="copyText" @click="copyPhone">{{ userInfo.desktop_phone }}</text>
  23. </view>
  24. <view class="info-item">
  25. <view>
  26. <uni-icons type="email" size="20"></uni-icons>
  27. <text>邮箱</text>
  28. </view>
  29. <text class="lastText">{{ userInfo.email || '暂无' }}</text>
  30. </view>
  31. </view>
  32. <!-- 个人信息 -->
  33. <view class="personal-info">
  34. <view class="info-item">
  35. <view>
  36. <uni-icons type="person" size="20"></uni-icons>
  37. <text>性别</text>
  38. </view>
  39. <text class="lastText">{{ sexDict[userInfo.sex] || '暂无' }}</text>
  40. </view>
  41. <view class="info-item">
  42. <view>
  43. <uni-icons type="star" size="20"></uni-icons>
  44. <text>生日</text>
  45. </view>
  46. <text class="lastText">{{ userInfo.birthday || '暂无' }}</text>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script setup>
  52. import { onMounted, ref } from 'vue';
  53. import { onLoad } from '@dcloudio/uni-app'
  54. import { getUserInfo } from '@/api/mine.js'
  55. import { useUserStore } from '@/store/user.js'
  56. import $modal from '@/plugins/modal.js'
  57. import config from '@/config';
  58. const sexDict = {
  59. 'F': '女',
  60. 'M': '男'
  61. }
  62. const userStore = useUserStore()
  63. const userInfo = ref({})
  64. // 监听页面加载
  65. onLoad((options) => {
  66. console.log('options.useId', options.useId);
  67. console.log('options', !options.useId);
  68. if (!options.useId) {
  69. // 获取传入的标题参数
  70. userInfo.value = userStore.user
  71. setHeadImg()
  72. } else {
  73. getUserInfo(options.useId).then((res) => {
  74. userInfo.value = res.returnParams[0]
  75. setHeadImg()
  76. })
  77. }
  78. const name = userInfo.value.name;
  79. if (name) {
  80. // 设置导航栏标题
  81. uni.setNavigationBarTitle({
  82. title: name + "的信息"
  83. });
  84. }
  85. })
  86. const headImg=ref()
  87. function setHeadImg() { // TODO 直接返回 不创建变量
  88. headImg.value=config.baseUrlPre + (userInfo.value.photo==""?config.defaultAvatarPath:userInfo.value.photo)
  89. }
  90. function copyPhone() {
  91. uni.showModal({
  92. title: '是否跳转拨号',
  93. cancelText: '复制',
  94. confirmText: '跳转',
  95. success: function(res) {
  96. if (res.confirm) {
  97. uni.makePhoneCall({
  98. phoneNumber: userInfo.value.desktop_phone,
  99. fail: (err) => {
  100. $modal.msgError('跳转失败,请重试')
  101. }
  102. })
  103. } else {
  104. wx.setClipboardData({
  105. data: userInfo.value.desktop_phone,
  106. success: (res)=> {
  107. $modal.msgSuccess('复制成功')
  108. },
  109. fail: (err) => {
  110. $modal.msgError('复制失败,请重试')
  111. }
  112. });
  113. }
  114. }
  115. })
  116. }
  117. </script>
  118. <style lang="scss" scoped>
  119. .container {
  120. padding: 20px;
  121. background-color: #f8f8f8;
  122. height: 100vh;
  123. box-sizing: border-box;
  124. }
  125. .avatar {
  126. width: calc(6.25rem + 0px);
  127. height: calc(6.25rem + 0px);
  128. border-radius: 50%;
  129. margin-bottom: 15px;
  130. display: block;
  131. margin-left: auto;
  132. margin-right: auto;
  133. }
  134. .username {
  135. font-size: calc(1.125rem + 0px);
  136. }
  137. .position {
  138. font-size: calc(0.875rem + 0px);
  139. color: #666;
  140. margin: 10px auto;
  141. }
  142. .contact-info,
  143. .personal-info {
  144. background-color: #fff;
  145. border-radius: 8px;
  146. overflow: hidden;
  147. margin-bottom: 15px;
  148. }
  149. .info-item {
  150. padding: 12px 16px;
  151. border-top: 1px solid #eee;
  152. font-size: calc(1rem + 0px);
  153. display: flex;
  154. justify-content: space-between;
  155. align-items: center;
  156. ::v-deep .uni-icons {
  157. font-size: calc(1.25rem + 0px);
  158. }
  159. }
  160. .copyText {
  161. color: #2196f3;
  162. text-decoration: #2196f3;
  163. }
  164. .lastText {
  165. color: #999;
  166. }
  167. </style>