index.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <template>
  2. <view>
  3. <view class="lt-msg ddflex" @click="jumpConversation()">
  4. <view class="ddflex" style="position: relative;width: 100%;height: 100%;">
  5. <image src="../../static/pages/images/lt.png"></image>
  6. <view class="lt-msg-num" v-if="unReadSpotNum>0">{{unReadSpotNum}}</view>
  7. </view>
  8. </view>
  9. </view>
  10. </template>
  11. <script>
  12. const app = getApp();
  13. const req = require("../../utils/request.js");
  14. let disp = require("../../hxChatSDK/utils/broadcast");
  15. export default {
  16. data() {
  17. return {
  18. picUrlss: req.public.picUrls,
  19. unReadSpotNum: 0
  20. };
  21. },
  22. components: {},
  23. props: {},
  24. watch: {},
  25. mounted() {
  26. //发起获取未读消息通知
  27. disp.fire("em.main.ready");
  28. //监听未读消息数
  29. disp.on("em.unreadspot", this.onChatPageUnreadspot);
  30. },
  31. onUnload() {
  32. disp.off("em.unreadspot", this.onChatPageUnreadspot)
  33. },
  34. methods: {
  35. onChatPageUnreadspot(message) {
  36. this.unReadSpotNum = getApp().globalData.unReadMessageNum > 99 ?
  37. "99+" : getApp().globalData.unReadMessageNum;
  38. },
  39. jumpConversation() {
  40. req.jumpConversation();
  41. },
  42. }
  43. };
  44. </script>
  45. <style>
  46. @import "./index.css";
  47. </style>