chat-detail.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // pages/chat-detail/chat-detail.js
  2. let disp = require("../../utils/broadcast");
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. username: {
  9. your: "",
  10. },
  11. list: [{
  12. id: 1,
  13. photo: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fup.enterdesk.com%2Fedpic_source%2Fc0%2F8e%2F28%2Fc08e28eb52da5a2b5b451ad6272a8197.jpg&refer=http%3A%2F%2Fup.enterdesk.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1652429449&t=63437c824c18680ecb5e5f27d06f941b',
  14. content: '你到了吗?'
  15. }, {
  16. id: 2,
  17. photo: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fnimg.ws.126.net%2F%3Furl%3Dhttp%253A%252F%252Fdingyue.ws.126.net%252F2021%252F0314%252F94ad46dbj00qpy1do0021d200rs00rsg008t008t.jpg%26thumbnail%3D650x2147483647%26quality%3D80%26type%3Djpg&refer=http%3A%2F%2Fnimg.ws.126.net&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1652429449&t=3fd0174f597633f23248e79587f76513',
  18. content: '刚刚到达,已找到位置,谢谢!'
  19. }]
  20. },
  21. /**
  22. * 生命周期函数--监听页面加载
  23. */
  24. onLoad: function (options) {
  25. console.info(options)
  26. let me = this
  27. let username = options && JSON.parse(options.username) || {};
  28. console.log('username *****', username)
  29. this.setData({ username: username });
  30. wx.setNavigationBarTitle({
  31. title: username.your
  32. });
  33. disp.on('em.megList.refresh', function () {
  34. const pages = getCurrentPages();
  35. const currentPage = pages[pages.length - 1];
  36. if (currentPage.route == "pages/chatroom/chatroom") {
  37. me.onLoad()
  38. }
  39. })
  40. if (username.action == 'join') {
  41. console.log('username', username)
  42. this.selectComponent('#chat').joinConf(username.data)
  43. }
  44. disp.on('emedia.confirmRing', function (event) {
  45. console.log('event', event)
  46. me.selectComponent('#chat').joinConf()
  47. });
  48. },
  49. /**
  50. * 生命周期函数--监听页面初次渲染完成
  51. */
  52. onReady: function () {
  53. },
  54. /**
  55. * 生命周期函数--监听页面显示
  56. */
  57. onShow: function () {
  58. },
  59. /**
  60. * 生命周期函数--监听页面隐藏
  61. */
  62. onHide: function () {
  63. },
  64. /**
  65. * 生命周期函数--监听页面卸载
  66. */
  67. onUnload: function () {
  68. disp.fire("em.chatroom.leave");
  69. },
  70. /**
  71. * 页面相关事件处理函数--监听用户下拉动作
  72. */
  73. onPullDownRefresh: function () {
  74. wx.showNavigationBarLoading();
  75. this.selectComponent('#chat').getMore()
  76. // 停止下拉动作
  77. wx.hideNavigationBarLoading();
  78. wx.stopPullDownRefresh();
  79. },
  80. /**
  81. * 页面上拉触底事件的处理函数
  82. */
  83. onReachBottom: function () {
  84. },
  85. /**
  86. * 用户点击右上角分享
  87. */
  88. onShareAppMessage: function () {
  89. }
  90. })