header-message.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // 消息列表获取未读消息
  2. function Message() {
  3. // 初始化
  4. this.init = function () {
  5. if (!loginflag) return
  6. $('#noticed').show()
  7. this.getMessageList()
  8. }
  9. // 悬浮窗列表数据请求
  10. this.getMessageList = function () {
  11. var params = {
  12. isColumn: false, // 是否需要栏目(消息中心需要)
  13. isColumnNewMsg: false,
  14. isMsgList: false, // 是否需要列表数据
  15. isContainLetter: false, // 是否包含私信数
  16. msgType: -1, // 消息类型,-1为全部
  17. isRead: 0, // 是否已读
  18. offset: 1,
  19. size: 0
  20. }
  21. $.ajax({
  22. url: '/jyapi/messageCenter/MessageList',
  23. type: 'POST',
  24. data: JSON.stringify(params),
  25. dataType: 'json',
  26. headers: {'Content-Type': 'application/json'},
  27. success:function (res) {
  28. if (res.unread) {
  29. var unreadNum = res.unread;
  30. $('#tips').show();
  31. $('#tips').html(unreadNum > 99 ? '99+' : unreadNum);
  32. } else {
  33. $('#tips').hide();
  34. }
  35. },
  36. error:function () {}
  37. })
  38. }
  39. this.init()
  40. }