personal_message.vue 4.5 KB

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