conversation.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. <template>
  2. <view>
  3. <view>
  4. <view class="search" v-if="search_btn">
  5. <view @tap="openSearch">
  6. <icon type="search" size="12"></icon>
  7. <text>搜索</text>
  8. </view>
  9. </view>
  10. </view>
  11. <!-- <view class="chat_list_wraper" > -->
  12. <scroll-view scroll-y="true" :class="
  13. 'chat_list_wraper ' + (gotop ? (isIPX ? 'goTopX' : 'goTop') : 'goback')
  14. " :style="'padding-bottom: ' + (isIPX ? '270rpx' : '226rpx')">
  15. <view class="search_input" v-if="search_chats">
  16. <view>
  17. <icon type="search" size="12"></icon>
  18. <input placeholder="搜索" placeholder-style="color:#9B9B9B;line-height:21px;font-size:15px;"
  19. auto-focus confirm-type="search" type="text" @confirm="onSearch" @input="onInput"
  20. v-model="input_code" />
  21. <icon type="clear" size="12" @tap.stop="clearInput" v-if="show_clear"></icon>
  22. </view>
  23. <text @tap="cancel">取消</text>
  24. </view>
  25. <view v-for="(item, index) in conversationList" :key="index" class="chat_list" :data-item="item"
  26. @tap.stop="del_chat" @longpress="longpress">
  27. <swipe-delete>
  28. <!-- 通知模块 -->
  29. <!-- <view class="tap_mask" @tap.stop="into_inform" :data-item="item" v-if="item.chatType == 'INFORM'">
  30. <view class="list_box">
  31. <view class="list_left">
  32. <view class="list_pic">
  33. <view v-if="unReadTotalNotNum > 0" class="em-unread-spot2">
  34. {{ unReadTotalNotNum}}
  35. </view>
  36. <image :class="unReadTotalNotNum > 0 ? 'haveSpot' : ''" src="../static/inform.png">
  37. </image>
  38. </view>
  39. <view class="list_text">
  40. <text class="list_user"> 系统通知 </text>
  41. <text class="list_word"
  42. v-if="item.chatType == 'INFORM'">申请通知来自:{{ item.info.from }}</text>
  43. </view>
  44. </view>
  45. <view class="list_right">
  46. <text :data-username="item.username">{{ handleTime(item) }}</text>
  47. </view>
  48. </view>
  49. </view> -->
  50. <view class="tap_mask" @tap.stop="into_chatRoom" :data-item="JSON.stringify(item)">
  51. <!-- 消息列表 -->
  52. <view class="list_box">
  53. <view class="list_left" :data-username="item.username">
  54. <view class="list_pic">
  55. <view class="em-msgNum"
  56. v-if="item.unReadCount > 0 && !pushConfigData.includes(item.chatType === 'chat' ? item.username : item.info.to)">
  57. {{ item.unReadCount > 99 ? '99+':item.unReadCount}}
  58. </view>
  59. <image :src="showConversationAvatar(item)"></image>
  60. </view>
  61. <view class="list_text">
  62. <text class="list_user">{{ showConversationName(item) }}</text>
  63. <text class="list_word" v-if="item.msg.data[0].data">
  64. {{item.msg.data[0].data}}
  65. </text>
  66. <text class="list_word" v-if="item.msg.type == 'img'">[图片]</text>
  67. <text class="list_word" v-if="item.msg.type == 'audio'">[语音]</text>
  68. <text class="list_word" v-if="item.msg.type == 'file'">[附件]</text>
  69. <text class="list_word" v-if="item.msg.type == 'video'">[视频]</text>
  70. </view>
  71. </view>
  72. <view class="list_right">
  73. <text :data-username="item.username">{{ handleTime(item) }}</text>
  74. </view>
  75. </view>
  76. </view>
  77. </swipe-delete>
  78. </view>
  79. <long-press-modal :winSize="winSize" :popButton="popButton" @change="pickerMenuChange" :showPop="showPop"
  80. @hidePop="hidePop" :popStyle="popStyle" />
  81. <view v-if="conversationList && conversationList.length == 0" class="chat_noChat">
  82. <image class="ctbg" src="../static/ctbg.png"></image>
  83. 暂无聊天消息
  84. </view>
  85. <!-- </view> -->
  86. </scroll-view>
  87. <!-- bug: margin-bottom 不生效 需要加一个空标签-->
  88. <view style="height: 1px"></view>
  89. <view class="mask" @tap="close_mask" v-if="show_mask"></view>
  90. </view>
  91. </template>
  92. <script>
  93. let disp = require("../../hxChatSDK/utils/broadcast");
  94. var WebIM = require("../../hxChatSDK/utils/WebIM")["default"];
  95. let isfirstTime = true;
  96. import swipeDelete from "../../chat/components/chat/swipedelete/swipedelete";
  97. import longPressModal from "../../chat/components/chat/longPressModal/index";
  98. export default {
  99. data() {
  100. return {
  101. search_btn: true,
  102. search_chats: false,
  103. show_mask: false,
  104. yourname: "",
  105. unReadSpotNum: 0,
  106. unReadNoticeNum: 0,
  107. messageNum: 0,
  108. unReadTotalNotNum: 0,
  109. conversationList: [],
  110. show_clear: false,
  111. member: "",
  112. isIPX: false,
  113. gotop: false,
  114. input_code: "",
  115. groupName: {},
  116. winSize: {},
  117. popButton: ["删除该聊天"],
  118. showPop: false,
  119. popStyle: "",
  120. currentVal: '',
  121. pushConfigData: [],
  122. defaultAvatar: "../static/theme2x.png",
  123. defaultGroupAvatar: "../static/groupTheme.png"
  124. };
  125. },
  126. components: {
  127. swipeDelete,
  128. longPressModal,
  129. },
  130. props: {},
  131. onLoad() {
  132. this.getWindowSize();
  133. //监听加好友申请
  134. disp.on("em.subscribe", this.onChatPageSubscribe);
  135. //监听解散群
  136. disp.on("em.invite.deleteGroup", this.onChatPageDeleteGroup);
  137. //监听未读消息数
  138. disp.on("em.unreadspot", this.onChatPageUnreadspot);
  139. //监听未读加群“通知”
  140. disp.on("em.invite.joingroup", this.onChatPageJoingroup);
  141. //监听好友删除
  142. disp.on("em.contacts.remove", this.onChatPageRemoveContacts);
  143. //监听好友关系解除
  144. disp.on("em.unsubscribed", this.onChatPageUnsubscribed)
  145. if (!uni.getStorageSync('listGroup')) {
  146. this.listGroups()
  147. }
  148. if (!uni.getStorageSync('member')) {
  149. this.getRoster()
  150. }
  151. this.readJoinedGroupName()
  152. },
  153. onShow: function() {
  154. uni.hideHomeButton && uni.hideHomeButton();
  155. setTimeout(() => {
  156. this.getLocalConversationlist();
  157. }, 100)
  158. this.setData({
  159. unReadSpotNum: getApp().globalData.unReadMessageNum > 99 ?
  160. "99+" : getApp().globalData.unReadMessageNum,
  161. messageNum: getApp().globalData.saveFriendList.length,
  162. unReadNoticeNum: getApp().globalData.saveGroupInvitedList.length,
  163. unReadTotalNotNum: getApp().globalData.saveFriendList.length +
  164. getApp().globalData.saveGroupInvitedList.length,
  165. });
  166. if (getApp().globalData.isIPX) {
  167. this.setData({
  168. isIPX: true,
  169. });
  170. }
  171. },
  172. onUnload() {
  173. //页面卸载同步取消onload中的订阅,防止重复订阅事件。
  174. disp.off('em.subscribe', this.onChatPageSubscribe)
  175. disp.off("em.invite.deleteGroup", this.onChatPageDeleteGroup)
  176. disp.off("em.unreadspot", this.onChatPageUnreadspot)
  177. disp.off("em.invite.joingroup", this.onChatPageJoingroup)
  178. disp.off("em.contacts.remove", this.onChatPageRemoveContacts)
  179. disp.off("em.unsubscribed", this.onChatPageUnsubscribed)
  180. },
  181. computed: {
  182. //会话头像展示
  183. showConversationAvatar() {
  184. const friendUserInfoMap = getApp().globalData.friendUserInfoMap;
  185. return (item) => {
  186. if (item.chatType === 'singleChat' || item.chatType === 'chat') {
  187. if (friendUserInfoMap.has(item.username) && friendUserInfoMap.get(item.username)?.avatarurl) {
  188. return friendUserInfoMap.get(item.username).avatarurl
  189. } else {
  190. return this.defaultAvatar
  191. }
  192. } else if (item.chatType === 'groupchat' || item.chatType === 'chatRoom') {
  193. return this.defaultGroupAvatar
  194. }
  195. }
  196. },
  197. //会话name展示
  198. showConversationName() {
  199. const friendUserInfoMap = getApp().globalData.friendUserInfoMap;
  200. return (item) => {
  201. if (item.chatType === 'singleChat' || item.chatType === 'chat') {
  202. if (friendUserInfoMap.has(item.username) && friendUserInfoMap.get(item.username)?.nickname) {
  203. return friendUserInfoMap.get(item.username).nickname
  204. } else {
  205. return item.username
  206. }
  207. } else if (item.chatType === 'groupchat' || item.chatType === 'chatRoom') {
  208. return item.groupName
  209. }
  210. }
  211. },
  212. //处理时间显示
  213. handleTime() {
  214. return (item) => {
  215. return this.$u.timeFormat(item.time, 'mm/dd/hh:MM')
  216. }
  217. }
  218. },
  219. methods: {
  220. listGroups() {
  221. var me = this;
  222. return WebIM.conn.getGroup({
  223. limit: 50,
  224. success: function(res) {
  225. uni.setStorage({
  226. key: "listGroup",
  227. data: res.data,
  228. });
  229. me.readJoinedGroupName()
  230. me.getLocalConversationlist();
  231. },
  232. error: function(err) {
  233. console.log(err);
  234. },
  235. });
  236. },
  237. getRoster() {
  238. let me = this;
  239. let rosters = {
  240. success(roster) {
  241. console.log('roster', roster)
  242. var member = [];
  243. for (let i = 0; i < roster.length; i++) {
  244. if (roster[i].subscription == "both") {
  245. member.push(roster[i]);
  246. }
  247. }
  248. uni.setStorage({
  249. key: "member",
  250. data: member,
  251. });
  252. me.setData({
  253. member: member
  254. });
  255. //if(!systemReady){
  256. disp.fire("em.main.ready");
  257. //systemReady = true;
  258. //}
  259. me.getLocalConversationlist()
  260. me.setData({
  261. unReadSpotNum: getApp().globalData.unReadMessageNum > 99 ?
  262. "99+" : getApp().globalData.unReadMessageNum,
  263. });
  264. },
  265. error(err) {
  266. console.log(err);
  267. },
  268. };
  269. WebIM.conn.getContacts(rosters);
  270. },
  271. readJoinedGroupName() {
  272. const joinedGroupList = uni.getStorageSync('listGroup')
  273. const groupList = joinedGroupList?.data || joinedGroupList || []
  274. let groupName = {};
  275. groupList.forEach((item) => {
  276. groupName[item.groupid] = item.groupname;
  277. });
  278. this.setData({
  279. groupName: groupName,
  280. });
  281. },
  282. // 包含陌生人版本
  283. getLocalConversationlist() {
  284. const myName = uni.getStorageSync("myUsername");
  285. const me = this;
  286. uni.getStorageInfo({
  287. success: function(res) {
  288. let storageKeys = res.keys;
  289. let newChatMsgKeys = [];
  290. let historyChatMsgKeys = [];
  291. let len = myName.length;
  292. storageKeys.forEach((item) => {
  293. if (item.slice(-len) == myName && item.indexOf("rendered_") == -1) {
  294. newChatMsgKeys.push(item);
  295. } else if (
  296. item.slice(-len) == myName &&
  297. item.indexOf("rendered_") > -1
  298. ) {
  299. historyChatMsgKeys.push(item);
  300. } else if (item === "INFORM") {
  301. newChatMsgKeys.push(item);
  302. }
  303. });
  304. me.packageConversation(newChatMsgKeys, historyChatMsgKeys);
  305. },
  306. });
  307. },
  308. //组件会话列表方法
  309. packageConversation(newChatMsgKeys, historyChatMsgKeys) {
  310. const me = this;
  311. const myName = uni.getStorageSync("myUsername");
  312. let conversationList = [];
  313. let lastChatMsg; //最后一条消息
  314. for (let i = historyChatMsgKeys.length; i > 0, i--;) {
  315. let index = newChatMsgKeys.indexOf(historyChatMsgKeys[i].slice(9));
  316. if (index > -1) {
  317. let newChatMsgs = uni.getStorageSync(newChatMsgKeys[index]) || [];
  318. if (newChatMsgs.length) {
  319. lastChatMsg = newChatMsgs[newChatMsgs.length - 1];
  320. lastChatMsg.unReadCount = newChatMsgs.length;
  321. newChatMsgKeys.splice(index, 1);
  322. } else {
  323. let historyChatMsgs = uni.getStorageSync(historyChatMsgKeys[i]);
  324. if (historyChatMsgs.length) {
  325. lastChatMsg = historyChatMsgs[historyChatMsgs.length - 1];
  326. }
  327. }
  328. } else {
  329. let historyChatMsgs = uni.getStorageSync(historyChatMsgKeys[i]);
  330. if (historyChatMsgs.length) {
  331. lastChatMsg = historyChatMsgs[historyChatMsgs.length - 1];
  332. }
  333. }
  334. if (
  335. lastChatMsg &&
  336. (lastChatMsg.chatType == "groupchat" ||
  337. lastChatMsg.chatType == "chatRoom")
  338. ) {
  339. lastChatMsg.groupName = me.groupName[lastChatMsg.info.to];
  340. }
  341. lastChatMsg && lastChatMsg.username != myName &&
  342. conversationList.push(lastChatMsg);
  343. }
  344. for (let i = newChatMsgKeys.length; i > 0, i--;) {
  345. let newChatMsgs = uni.getStorageSync(newChatMsgKeys[i]) || [];
  346. if (newChatMsgs.length) {
  347. lastChatMsg = newChatMsgs[newChatMsgs.length - 1];
  348. lastChatMsg.unReadCount = newChatMsgs.length;
  349. if (
  350. lastChatMsg.chatType == "groupchat" ||
  351. lastChatMsg.chatType == "chatRoom"
  352. ) {
  353. lastChatMsg.groupName = me.groupName[lastChatMsg.info.to];
  354. }
  355. lastChatMsg.username != myName && conversationList.push(lastChatMsg);
  356. }
  357. }
  358. conversationList.sort((a, b) => {
  359. return b.time - a.time;
  360. });
  361. this.setData({
  362. conversationList: conversationList,
  363. });
  364. },
  365. openSearch: function() {
  366. this.setData({
  367. search_btn: false,
  368. search_chats: true,
  369. gotop: true,
  370. });
  371. },
  372. onSearch: function(val) {
  373. let searchValue = val.detail.value;
  374. var myName = uni.getStorageSync("myUsername");
  375. const me = this;
  376. let serchList = [];
  377. let conversationList = [];
  378. uni.getStorageInfo({
  379. success: function(res) {
  380. let storageKeys = res.keys;
  381. let chatKeys = [];
  382. let len = myName.length;
  383. storageKeys.forEach((item) => {
  384. if (item.slice(-len) == myName) {
  385. chatKeys.push(item);
  386. }
  387. });
  388. chatKeys.forEach((item, index) => {
  389. if (item.indexOf(searchValue) != -1) {
  390. serchList.push(item);
  391. }
  392. });
  393. let lastChatMsg = "";
  394. serchList.forEach((item, index) => {
  395. let chatMsgs = uni.getStorageSync(item) || [];
  396. if (chatMsgs.length) {
  397. lastChatMsg = chatMsgs[chatMsgs.length - 1];
  398. conversationList.push(lastChatMsg);
  399. }
  400. });
  401. me.setData({
  402. conversationList: conversationList
  403. });
  404. },
  405. });
  406. },
  407. cancel: function() {
  408. this.getLocalConversationlist();
  409. this.setData({
  410. search_btn: true,
  411. search_chats: false,
  412. unReadSpotNum: getApp().globalData.unReadMessageNum > 99 ?
  413. "99+" : getApp().globalData.unReadMessageNum,
  414. gotop: false,
  415. });
  416. },
  417. clearInput: function() {
  418. this.setData({
  419. input_code: "",
  420. show_clear: false,
  421. });
  422. },
  423. onInput: function(e) {
  424. let inputValue = e.detail.value;
  425. if (inputValue) {
  426. this.setData({
  427. show_clear: true,
  428. });
  429. } else {
  430. this.setData({
  431. show_clear: false,
  432. });
  433. }
  434. },
  435. close_mask: function() {
  436. this.setData({
  437. search_btn: true,
  438. search_chats: false,
  439. show_mask: false,
  440. });
  441. },
  442. into_chatRoom: function(event) {
  443. let detail = JSON.parse(event.currentTarget.dataset.item);
  444. if (
  445. detail.chatType == "groupchat" ||
  446. detail.chatType == "chatRoom" ||
  447. detail.groupName
  448. ) {
  449. this.into_groupChatRoom(detail);
  450. } else {
  451. this.into_singleChatRoom(detail);
  452. }
  453. },
  454. // 单聊
  455. into_singleChatRoom: function(detail) {
  456. var my = uni.getStorageSync("myUsername");
  457. var nameList = {
  458. myName: my,
  459. your: detail.username,
  460. };
  461. const friendUserInfoMap = getApp().globalData.friendUserInfoMap;
  462. if (friendUserInfoMap.has(nameList.your) && friendUserInfoMap.get(nameList.your)?.nickname) {
  463. nameList.yourNickName = friendUserInfoMap.get(nameList.your).nickname;
  464. }
  465. uni.navigateTo({
  466. url: "../chatroom/chatroom?username=" + JSON.stringify(nameList),
  467. });
  468. },
  469. // 群聊 和 聊天室 (两个概念)
  470. into_groupChatRoom: function(detail) {
  471. var my = uni.getStorageSync("myUsername");
  472. var nameList = {
  473. myName: my,
  474. your: detail.groupName,
  475. groupId: detail.info.to,
  476. };
  477. uni.navigateTo({
  478. url: "../groupChatRoom/groupChatRoom?username=" + JSON.stringify(nameList),
  479. });
  480. },
  481. // into_inform: function() {
  482. // uni.redirectTo({
  483. // url: "../notification/notification",
  484. // });
  485. // },
  486. removeAndRefresh: function(event) {
  487. let removeId = event.currentTarget.dataset.item.info.from
  488. let ary = getApp().globalData.saveFriendList
  489. let idx
  490. if (ary.length > 0) {
  491. ary.forEach((v, k) => {
  492. if (v.from == removeId) {
  493. idx = k
  494. }
  495. })
  496. getApp().globalData.saveFriendList.splice(idx, 1);
  497. }
  498. uni.removeStorageSync('INFORM')
  499. },
  500. del_chat: function(event) {
  501. let detail = event.currentTarget.dataset.item;
  502. let nameList = {};
  503. let me = this;
  504. // 删除当前选中群组聊天列表
  505. if (detail.chatType == "groupchat" || detail.chatType == "chatRoom") {
  506. nameList = {
  507. your: detail.info.to,
  508. };
  509. //删除当前选中通知列表
  510. } else if (detail.chatType === "INFORM") {
  511. nameList = {
  512. your: "INFORM",
  513. };
  514. }
  515. //删除当前选中好友聊天列表
  516. else {
  517. nameList = {
  518. your: detail.username,
  519. };
  520. }
  521. var myName = uni.getStorageSync("myUsername");
  522. var currentPage = getCurrentPages();
  523. uni.showModal({
  524. title: "确认删除?",
  525. confirmText: "删除",
  526. success: function(res) {
  527. if (res.confirm) {
  528. uni.removeStorageSync(nameList.your + myName);
  529. uni.removeStorageSync("rendered_" + nameList.your + myName);
  530. nameList.your === 'INFORM' && me.removeAndRefresh(event);
  531. // if (Object.keys(currentPage[0]).length>0) {
  532. // currentPage[0].onShow();
  533. // }
  534. disp.fire("em.chat.session.remove");
  535. me.getLocalConversationlist();
  536. }
  537. },
  538. fail: function(err) {
  539. console.log('删除列表', err);
  540. },
  541. });
  542. },
  543. removeLocalStorage: function(yourname) {
  544. var myName = uni.getStorageSync("myUsername");
  545. uni.removeStorageSync(yourname + myName);
  546. uni.removeStorageSync("rendered_" + yourname + myName);
  547. },
  548. longpress: function(e) {
  549. //将当前选中的值存在data中方便后续操作
  550. this.currentVal = e
  551. let [touches, style, index] = [e.touches[0], "", e.currentTarget.dataset.index, ];
  552. /* 因 非H5端不兼容 style 属性绑定 Object ,所以拼接字符 */
  553. if (touches.clientY > this.winSize.height / 2) {
  554. style = `bottom:${this.winSize.height - touches.clientY}px;`;
  555. } else {
  556. style = `top:${touches.clientY}px;`;
  557. }
  558. if (touches.clientX > this.winSize.witdh / 2) {
  559. style += `right:${this.winSize.witdh - touches.clientX}px`;
  560. } else {
  561. style += `left:${touches.clientX}px`;
  562. }
  563. this.popStyle = style;
  564. // this.pickerUserIndex = Number(index);
  565. this.showShade = true;
  566. this.$nextTick(() => {
  567. setTimeout(() => {
  568. this.showPop = true;
  569. }, 10);
  570. });
  571. },
  572. /* 获取窗口尺寸 */
  573. getWindowSize() {
  574. uni.getSystemInfo({
  575. success: (res) => {
  576. this.winSize = {
  577. witdh: res.windowWidth,
  578. height: res.windowHeight,
  579. };
  580. },
  581. });
  582. },
  583. hidePop() {
  584. this.showPop = false;
  585. },
  586. pickerMenuChange() {
  587. this.del_chat(this.currentVal)
  588. },
  589. /* disp event callback function */
  590. onChatPageSubscribe() {
  591. this.getLocalConversationlist();
  592. this.setData({
  593. messageNum: getApp().globalData.saveFriendList.length,
  594. unReadTotalNotNum: getApp().globalData.saveFriendList.length +
  595. getApp().globalData.saveGroupInvitedList.length,
  596. });
  597. },
  598. onChatPageDeleteGroup(infos) {
  599. this.listGroups();
  600. this.getRoster();
  601. this.getLocalConversationlist();
  602. this.setData({
  603. messageNum: getApp().globalData.saveFriendList.length,
  604. });
  605. //如果会话存在则执行删除会话
  606. this.removeLocalStorage(infos.gid)
  607. },
  608. onChatPageUnreadspot(message) {
  609. this.getLocalConversationlist();
  610. let currentLoginUser = WebIM.conn.context.userId;
  611. let id = message && message.chatType === 'groupchat' ? message?.to : message?.from;
  612. let pushObj = uni.getStorageSync("pushStorageData");
  613. let pushAry = pushObj[currentLoginUser] || []
  614. this.setData({
  615. pushConfigData: pushAry,
  616. });
  617. // if (message && pushValue.includes(id)) return
  618. this.setData({
  619. unReadSpotNum: getApp().globalData.unReadMessageNum > 99 ?
  620. "99+" : getApp().globalData.unReadMessageNum,
  621. });
  622. },
  623. onChatPageJoingroup() {
  624. this.setData({
  625. unReadNoticeNum: getApp().globalData.saveGroupInvitedList.length,
  626. unReadTotalNotNum: getApp().globalData.saveFriendList.length +
  627. getApp().globalData.saveGroupInvitedList.length,
  628. });
  629. this.getLocalConversationlist();
  630. },
  631. onChatPageRemoveContacts() {
  632. this.getLocalConversationlist();
  633. this.getRoster();
  634. },
  635. onChatPageUnsubscribed(message) {
  636. uni.showToast({
  637. title: `与${message.from}好友关系解除`,
  638. icon: "none",
  639. });
  640. }
  641. },
  642. };
  643. </script>
  644. <style>
  645. @import "./chat.css";
  646. </style>