index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <template>
  2. <!-- #ifdef H5 || APP-PLUS -->
  3. <u-navbar :placeholder="true">
  4. <u-icon
  5. slot="left"
  6. size="20"
  7. name="arrow-left"
  8. @click="onArrowLeftBackClick"
  9. ></u-icon>
  10. <!-- <u-avatar
  11. slot="left"
  12. size="32"
  13. shape="square"
  14. :src="navbarAvatar"
  15. ></u-avatar> -->
  16. <view slot="left" class="chat_name">
  17. <text v-show="!chattingTypingStatus" class="chat_name_text">
  18. {{ navigatorName }}
  19. </text>
  20. <text v-show="chattingTypingStatus" class="chat_name_text"
  21. >对方正在输入...</text
  22. >
  23. <text class="presence_status_text">{{ presenceStatus }}</text>
  24. </view>
  25. <u-icon
  26. slot="right"
  27. @click="onRightIconClick"
  28. size="36"
  29. name="/static/images/new_ui/more_icon.png"
  30. ></u-icon>
  31. </u-navbar>
  32. <!-- #endif -->
  33. <!-- #ifndef H5 || APP-PLUS-->
  34. <!-- <u-navbar :placeholder="true">
  35. <view class="u-nav-slot" slot="left">
  36. <u-icon
  37. slot="left"
  38. size="20"
  39. name="arrow-left"
  40. @click="onArrowLeftBackClick"
  41. ></u-icon>
  42. <u-avatar
  43. slot="left"
  44. size="32"
  45. shape="square"
  46. :src="navbarAvatar"
  47. ></u-avatar>
  48. <view slot="center" class="chat_name">
  49. <text v-show="!chattingTypingStatus" class="chat_name_text">
  50. 客服11
  51. </text>
  52. <text v-show="chattingTypingStatus" class="chat_name_text"
  53. >对方正在输入...</text
  54. >
  55. <text class="presence_status_text">{{ presenceStatus }}</text>
  56. </view>
  57. <u-line
  58. direction="column"
  59. :hairline="false"
  60. length="12"
  61. margin="0 5px"
  62. ></u-line>
  63. <u-icon
  64. @click="onRightIconClick"
  65. size="36"
  66. name="/static/images/new_ui/more_icon.png"
  67. ></u-icon>
  68. </view>
  69. </u-navbar> -->
  70. <u-navbar :placeholder="true">
  71. <view class="u-nav-slot" slot="left">
  72. <u-icon
  73. slot="left"
  74. size="20"
  75. name="arrow-left"
  76. @click="onArrowLeftBackClick"
  77. ></u-icon>
  78. </view>
  79. <view slot="center">
  80. <view slot="center" class="chat_name">
  81. <text v-show="!chattingTypingStatus" class="chat_name_text">
  82. 客服
  83. </text>
  84. <text v-show="chattingTypingStatus" class="chat_name_text"
  85. >对方正在输入...</text
  86. >
  87. <text class="presence_status_text">{{ presenceStatus }}</text>
  88. </view>
  89. </view>
  90. </u-navbar>
  91. <!-- #endif -->
  92. </template>
  93. <script>
  94. import { CHAT_TYPE } from "@/EaseIM/constant";
  95. export default {
  96. props: {
  97. targetId: {
  98. type: String,
  99. default: "",
  100. },
  101. chatType: {
  102. type: String,
  103. default: CHAT_TYPE.SINGLE_CHAT,
  104. },
  105. },
  106. data() {
  107. return {
  108. // defaultAvatar: "/static/images/new_ui/defaultAvatar.png",
  109. nowConversationIntem:uni.getStorageSync('nowConversationIntem'),
  110. defaultAvatar: "https://app.bjtdba.com/uploads/logo.jpg",
  111. defaultGroupAvatar: "/static/images/new_ui/defaultGroupAvatar.png",
  112. };
  113. },
  114. // onHide() {
  115. // console.log('页面消失');
  116. // uni.removeStorageSync('nowConversationIntem');
  117. // },
  118. computed: {
  119. chattingId() {
  120. console.log('chattingId',this.$store.getters.chattingId);
  121. return this.$store.getters.chattingId;
  122. },
  123. loginUserPresence() {
  124. return this.$store.state.ContactsStore.subscribeStatusInfoMap;
  125. },
  126. chattingChatType() {
  127. return this.$store.getters.chattingChatType;
  128. },
  129. chattingTypingStatus() {
  130. return this.$store.getters.chattingTypingStatus;
  131. },
  132. friendUserInfoCollection() {
  133. return this.$store.getters.friendUserInfoCollection;
  134. },
  135. joinedGroupList() {
  136. return this.$store.getters.joinedGroupList;
  137. },
  138. // navbarAvatar() {
  139. // if (this.chattingChatType === CHAT_TYPE.SINGLE_CHAT) {
  140. // const userId = this.chattingId;
  141. // if (
  142. // uni.getStorageSync('nowConversationIntem')&&
  143. // uni.getStorageSync('nowConversationIntem').avatarurl
  144. // ) {
  145. // return (
  146. // uni.getStorageSync('nowConversationIntem').avatarurl
  147. // );
  148. // } else {
  149. // return this.defaultAvatar;
  150. // }
  151. // }
  152. // if (this.chattingChatType === CHAT_TYPE.GROUP_CHAT) {
  153. // return this.defaultGroupAvatar;
  154. // }
  155. // },
  156. // navigatorName() {
  157. // if (this.chattingChatType === CHAT_TYPE.SINGLE_CHAT) {
  158. // const userId = this.chattingId;
  159. // if (
  160. // uni.getStorageSync('nowConversationIntem') &&
  161. // uni.getStorageSync('nowConversationIntem').nickname
  162. // ) {
  163. // return uni.getStorageSync('nowConversationIntem').nickname;
  164. // } else {
  165. // return uni.getStorageSync('nowConversationIntem').nickname;
  166. // }
  167. // }
  168. // if (this.chattingChatType === CHAT_TYPE.GROUP_CHAT) {
  169. // const group = this.joinedGroupList.find(
  170. // (group) => group.groupId == this.chattingId
  171. // );
  172. // if (group) {
  173. // return group.groupName || group.groupId;
  174. // } else {
  175. // return this.chattingId;
  176. // }
  177. // }
  178. // },
  179. presenceStatus() {
  180. const presenceInfo = this.loginUserPresence[this.chattingId];
  181. if (presenceInfo) {
  182. const statusDetails = presenceInfo.statusDetails;
  183. let isOnline = false;
  184. for (const item of statusDetails) {
  185. if (item.status === 1) {
  186. isOnline = true;
  187. break;
  188. }
  189. }
  190. if (isOnline) {
  191. if (presenceInfo.ext) {
  192. switch (presenceInfo.ext) {
  193. case "Cloaking":
  194. return "请勿打扰";
  195. case "Online":
  196. return "在线";
  197. case "Leave":
  198. return "离开";
  199. case "Offline":
  200. return "离线";
  201. default:
  202. return presenceInfo.ext;
  203. }
  204. } else {
  205. return "在线";
  206. }
  207. } else {
  208. return "离线";
  209. }
  210. }
  211. },
  212. },
  213. methods: {
  214. onArrowLeftBackClick() {
  215. uni.navigateBack();
  216. },
  217. onRightIconClick() {
  218. if (this.chatType === CHAT_TYPE.SINGLE_CHAT) {
  219. this.entryFriendDetail();
  220. }
  221. if (this.chatType === CHAT_TYPE.GROUP_CHAT) {
  222. this.entryGroupDetail();
  223. }
  224. },
  225. //前往好友详情页面
  226. entryFriendDetail() {
  227. const friendId = this.targetId;
  228. uni.navigateTo({
  229. url: `../contactsDetail/index?userId=${friendId}`,
  230. });
  231. },
  232. //前往群组详情页面
  233. entryGroupDetail() {
  234. const groupId = this.targetId;
  235. if (groupId) {
  236. uni.navigateTo({
  237. url: "../groupDetail/index?groupId=" + groupId,
  238. });
  239. }
  240. },
  241. },
  242. };
  243. </script>
  244. <style scoped>
  245. .u-nav-slot {
  246. display: flex;
  247. align-items: center;
  248. justify-content: space-between;
  249. border-width: 0.5px;
  250. border-radius: 100px;
  251. border-color: #ccc;
  252. padding: 3px 7px;
  253. /* opacity: 0.8; */
  254. }
  255. .chat_name {
  256. display: flex;
  257. flex-direction: column;
  258. justify-content: flex-start;
  259. /* align-items: center; */
  260. width: 150px;
  261. height: 36px;
  262. margin-left: 10px;
  263. }
  264. .chat_name_text {
  265. /* Frame 28 */
  266. /* Auto layout */
  267. padding: 0px;
  268. width: 128px;
  269. height: 22px;
  270. /* 简体中文/次级标题/中 */
  271. font-family: "PingFang SC";
  272. font-style: normal;
  273. font-weight: 400;
  274. font-size: 16px;
  275. line-height: 22px;
  276. /* identical to box height, or 138% */
  277. /* Neutral/1 */
  278. color: #171a1c;
  279. /* Inside auto layout */
  280. flex: none;
  281. order: 0;
  282. flex-grow: 0;
  283. overflow: hidden;
  284. white-space: nowrap;
  285. text-overflow: ellipsis;
  286. text-align: center;
  287. }
  288. .presence_status_text {
  289. /* Subtitle */
  290. width: 100px;
  291. height: 14px;
  292. left: 40px;
  293. top: 22px;
  294. /* 简体中文/文本/超小 */
  295. font-family: "PingFang SC";
  296. font-style: normal;
  297. font-weight: 400;
  298. font-size: 11px;
  299. line-height: 14px;
  300. /* identical to box height, or 127% */
  301. /* Neutral/5 */
  302. color: #75828a;
  303. }
  304. </style>