chat-detail.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad: function (options) {
  17. console.info(options)
  18. let me = this
  19. let username = options && JSON.parse(options.username) || {};
  20. console.log('username *****', username)
  21. this.setData({ username: username });
  22. wx.setNavigationBarTitle({
  23. title: username.navigationTitle
  24. });
  25. disp.on('em.megList.refresh', function () {
  26. const pages = getCurrentPages();
  27. const currentPage = pages[pages.length - 1];
  28. if (currentPage.route == "pages/chatroom/chatroom") {
  29. me.onLoad()
  30. }
  31. })
  32. if (username.action == 'join') {
  33. console.log('username', username)
  34. this.selectComponent('#chat').joinConf(username.data)
  35. }
  36. disp.on('emedia.confirmRing', function (event) {
  37. console.log('event', event)
  38. me.selectComponent('#chat').joinConf()
  39. });
  40. },
  41. /**
  42. * 生命周期函数--监听页面初次渲染完成
  43. */
  44. onReady: function () {
  45. },
  46. /**
  47. * 生命周期函数--监听页面显示
  48. */
  49. onShow: function () {
  50. },
  51. /**
  52. * 生命周期函数--监听页面隐藏
  53. */
  54. onHide: function () {
  55. },
  56. /**
  57. * 生命周期函数--监听页面卸载
  58. */
  59. onUnload: function () {
  60. disp.fire("em.chatroom.leave");
  61. },
  62. /**
  63. * 页面相关事件处理函数--监听用户下拉动作
  64. */
  65. onPullDownRefresh: function () {
  66. wx.showNavigationBarLoading();
  67. this.selectComponent('#chat').getMore()
  68. // 停止下拉动作
  69. wx.hideNavigationBarLoading();
  70. wx.stopPullDownRefresh();
  71. },
  72. /**
  73. * 页面上拉触底事件的处理函数
  74. */
  75. onReachBottom: function () {
  76. },
  77. /**
  78. * 用户点击右上角分享
  79. */
  80. onShareAppMessage: function () {
  81. }
  82. })