manage-profile.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <div
  3. v-if="!isUniFrameWork"
  4. class="memeber-profile"
  5. >
  6. <div class="memeber-profile-main">
  7. <img
  8. class="avatar"
  9. :src="
  10. userInfoManager.avatar ||
  11. 'https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_21.png'
  12. "
  13. onerror="this.onerror=null;this.src='https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_21.png'"
  14. >
  15. <ul class="list">
  16. <h2>{{ userInfoManager.nick || userInfoManager.userID }}</h2>
  17. <li>
  18. <label>ID:</label>
  19. <span>{{ userInfoManager.userID }}</span>
  20. </li>
  21. <li>
  22. <label>{{ TUITranslateService.t("TUIContact.个性签名") }}:</label>
  23. <span>{{ userInfoManager.selfSignature }}</span>
  24. </li>
  25. </ul>
  26. </div>
  27. <div class="memeber-profile-footer">
  28. <div
  29. v-if="showEnter()"
  30. class="button"
  31. @click="enter(userInfoManager.userID, 'C2C')"
  32. >
  33. {{ TUITranslateService.t("TUIContact.发送消息") }}
  34. </div>
  35. </div>
  36. </div>
  37. <div
  38. v-else
  39. class="edit-h5"
  40. >
  41. <main class="main">
  42. <header class="edit-h5-header">
  43. <aside class="left">
  44. <h1>{{ TUITranslateService.t(`TUIGroup.群成员`) }}</h1>
  45. </aside>
  46. <span
  47. class="close"
  48. @click="close('profile')"
  49. >{{
  50. TUITranslateService.t(`关闭`)
  51. }}</span>
  52. </header>
  53. <div class="edit-h5-profile">
  54. <div class="memeber-profile-main">
  55. <Avatar
  56. class="avatar"
  57. :url="userInfoManager.avatar"
  58. size="60px"
  59. />
  60. <ul class="list">
  61. <h1>{{ userInfoManager.nick || userInfoManager.userID }}</h1>
  62. <li>
  63. <label>ID:</label>
  64. <span>{{ userInfoManager.userID }}</span>
  65. </li>
  66. <li>
  67. <label>{{ TUITranslateService.t("TUIContact.个性签名") }}:</label>
  68. <span>{{ userInfoManager.selfSignature }}</span>
  69. </li>
  70. </ul>
  71. </div>
  72. <div class="memeber-profile-footer">
  73. <div
  74. v-if="showEnter()"
  75. class="button"
  76. @click="enter(userInfoManager.userID, 'C2C')"
  77. >
  78. {{ TUITranslateService.t("TUIContact.发送消息") }}
  79. </div>
  80. </div>
  81. </div>
  82. </main>
  83. </div>
  84. </template>
  85. <script lang="ts" setup>
  86. import { ref, watch, watchEffect } from '../../../adapter-vue';
  87. import TUIChatEngine, {
  88. TUITranslateService,
  89. TUIUserService,
  90. TUIConversationService,
  91. TUIFriendService,
  92. TUIStore,
  93. StoreName,
  94. } from '@tencentcloud/chat-uikit-engine';
  95. import { TUIGlobal } from '@tencentcloud/universal-api';
  96. import Avatar from '../../common/Avatar/index.vue';
  97. import { IUserProfile } from '../../../interface';
  98. import { isUniFrameWork } from '../../../utils/env';
  99. const props = defineProps({
  100. userInfo: {
  101. type: Object,
  102. default: () => ({}),
  103. },
  104. });
  105. const isFriendShip = ref(false);
  106. const userInfoManager = ref<IUserProfile>({});
  107. watchEffect(() => {
  108. userInfoManager.value = props.userInfo;
  109. });
  110. const emits = defineEmits([
  111. 'handleSwitchConversation',
  112. 'close',
  113. 'openConversation',
  114. ]);
  115. watch(
  116. () => props.userInfo,
  117. async (newVal: any, oldVal: any) => {
  118. if (newVal === oldVal) return;
  119. const res = await TUIUserService.getUserProfile({
  120. userIDList: [props.userInfo.userID],
  121. });
  122. userInfoManager.value = res?.data[0];
  123. checkFriend();
  124. },
  125. {
  126. deep: true,
  127. immediate: true,
  128. },
  129. );
  130. const enter = async (ID: any, type: string) => {
  131. const name = `${type}${ID}`;
  132. TUIConversationService.getConversationProfile(name)
  133. .then((res: any) => {
  134. TUIConversationService.switchConversation(res.data.conversation.conversationID).then(() => {
  135. TUIStore.update(StoreName.GRP, 'isShowManageComponent', false);
  136. if (isUniFrameWork) {
  137. TUIGlobal?.navigateBack();
  138. }
  139. });
  140. })
  141. .catch((err: any) => {
  142. console.warn('获取会话资料失败', err.code, err.msg);
  143. });
  144. };
  145. const checkFriend = async () => {
  146. if (!(userInfoManager.value as any).userID) return;
  147. TUIFriendService.checkFriend({
  148. userIDList: [userInfoManager.value.userID],
  149. type: TUIChatEngine.TYPES.SNS_CHECK_TYPE_BOTH,
  150. }).then((res: any) => {
  151. const relation = res?.data?.successUserIDList?.[0]?.relation;
  152. isFriendShip.value = (relation === TUIChatEngine.TYPES.SNS_TYPE_BOTH_WAY);
  153. });
  154. };
  155. const showEnter = () => {
  156. return isFriendShip.value || !TUIStore.getData(StoreName.APP, 'isOfficial');
  157. };
  158. const close = (tabName: string) => {
  159. emits('close', tabName);
  160. };
  161. </script>
  162. <style lang="scss" scoped>
  163. @import "../../../assets/styles/common";
  164. .memeber-profile {
  165. flex: 1;
  166. display: flex;
  167. flex-direction: column;
  168. &-main {
  169. display: flex;
  170. flex-direction: row;
  171. width: 100%;
  172. overflow: hidden;
  173. .avatar {
  174. width: 60px;
  175. height: 60px;
  176. border-radius: 8px;
  177. margin: 20px 10px 20px 20px;
  178. }
  179. .list {
  180. flex: 1;
  181. overflow: hidden;
  182. margin: 20px 10px;
  183. font-weight: 400;
  184. li {
  185. color: #999;
  186. }
  187. h1,
  188. li {
  189. overflow: hidden;
  190. white-space: nowrap;
  191. text-overflow: ellipsis;
  192. }
  193. }
  194. }
  195. &-footer {
  196. border-top: 1px solid #f4f5f9;
  197. padding: 14px;
  198. display: flex;
  199. flex-direction: column;
  200. align-items: center;
  201. justify-content: center;
  202. .button {
  203. width: 100px;
  204. cursor: pointer;
  205. background-color: #006eff;
  206. color: #fff;
  207. padding: 8px 20px;
  208. border-radius: 4px;
  209. border: none;
  210. font-size: 14px;
  211. text-align: center;
  212. line-height: 20px;
  213. }
  214. }
  215. }
  216. .edit-h5 {
  217. position: fixed;
  218. width: 100%;
  219. height: 100%;
  220. top: 0;
  221. left: 0;
  222. background: rgba(0, 0, 0, 0.5);
  223. display: flex;
  224. align-items: flex-end;
  225. z-index: 1;
  226. .main {
  227. background: #fff;
  228. flex: 1;
  229. padding: 18px;
  230. border-radius: 12px 12px 0 0;
  231. width: 80vw;
  232. .edit-h5-header {
  233. display: flex;
  234. align-items: center;
  235. justify-content: space-between;
  236. .close {
  237. font-family: PingFangSC-Regular;
  238. font-weight: 400;
  239. font-size: 18px;
  240. color: #3370ff;
  241. letter-spacing: 0;
  242. line-height: 27px;
  243. }
  244. }
  245. .edit-h5-profile {
  246. .memeber-profile-main {
  247. .avatar {
  248. margin: 20px;
  249. }
  250. }
  251. }
  252. }
  253. }
  254. </style>