message.vue 21 KB

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