manage-profile.vue 6.2 KB

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