index.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <view>
  3. <view class="lt-msg ddflex" @click="jumpConversation()" :style="'bottom:'+bottom+';'">
  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. bottom: {
  25. type: String,
  26. default: '200rpx',
  27. }
  28. },
  29. watch: {},
  30. mounted() {
  31. //发起获取未读消息通知
  32. disp.fire("em.main.ready");
  33. //监听未读消息数
  34. disp.on("em.unreadspot", this.onChatPageUnreadspot);
  35. },
  36. onUnload() {
  37. disp.off("em.unreadspot", this.onChatPageUnreadspot)
  38. },
  39. methods: {
  40. onChatPageUnreadspot(message) {
  41. this.unReadSpotNum = getApp().globalData.unReadMessageNum > 99 ?
  42. "99+" : getApp().globalData.unReadMessageNum;
  43. },
  44. jumpConversation() {
  45. req.jumpConversation();
  46. },
  47. }
  48. };
  49. </script>
  50. <style>
  51. @import "./index.css";
  52. </style>