conversation.vue 20 KB

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