chatroom.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <chat id="chat" :username="username" ref="chat" chatType="singleChat" @onClickInviteMsg="onClickMsg"></chat>
  3. </template>
  4. <script>
  5. let disp = require("../../hxChatSDK/utils/broadcast");
  6. import chat from "../../chat/components/chat/chat.vue";
  7. export default {
  8. data() {
  9. return {
  10. username: {
  11. your: ""
  12. }
  13. };
  14. },
  15. components: {
  16. chat
  17. },
  18. props: {},
  19. // options = 系统传入的 url 参数
  20. onLoad(options) {
  21. let username = JSON.parse(options.username);
  22. this.setData({
  23. username: username
  24. });
  25. // 生成的支付宝小程序在onLoad里获取不到,这里放到全局变量下
  26. uni.username = username;
  27. uni.setNavigationBarTitle({
  28. title: username?.yourNickName || username?.your
  29. });
  30. },
  31. onUnload(options) {
  32. disp.fire("em.chatroom.leave");
  33. },
  34. onPullDownRefresh: function () {
  35. uni.showNavigationBarLoading();
  36. this.$refs.chat.getMore();
  37. // 停止下拉动作
  38. uni.hideNavigationBarLoading();
  39. uni.stopPullDownRefresh();
  40. },
  41. methods: {
  42. onClickMsg(msg){
  43. msg.action = 'join'
  44. uni.navigateTo({
  45. url: "../emedia/index?srcData="+JSON.stringify(msg)
  46. });
  47. },
  48. onNavigationBarButtonTap(e) {
  49. uni.navigateTo({
  50. url: `/pages/moreMenu/moreMenu?username=${this.username.your}&type=singleChat`
  51. })
  52. },
  53. }
  54. };
  55. </script>
  56. <style>
  57. @import "./chatroom.css";
  58. </style>