NoticePopup.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. const Api = require('../net/Api');
  2. cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. noticeItem: {
  6. default: null,
  7. type: cc.Prefab,
  8. tooltip: "消息内容预制资源"
  9. },
  10. noticeWrap: {
  11. default: null,
  12. type: cc.Node,
  13. tooltip: "消息列表容器"
  14. }
  15. },
  16. onLoad () {
  17. },
  18. init () {
  19. },
  20. start () {
  21. let bouncesActionArray = [];
  22. let space = 50;
  23. let upAction = cc.moveTo(0.25, cc.v2(0, space));
  24. let downAction = cc.moveBy(0.1, cc.v2(0, -space));
  25. bouncesActionArray.push(upAction);
  26. bouncesActionArray.push(downAction);
  27. this.node.runAction(cc.sequence(bouncesActionArray));
  28. setTimeout(() => {
  29. this._initNoticeList()
  30. }, 300)
  31. },
  32. _initNoticeList () {
  33. Api.httpGet({
  34. url: "/post/getIndexPost.do",
  35. data: {},
  36. success: (res) => {
  37. res.list && res.list.forEach(n => {
  38. let noticeItem = cc.instantiate(this.noticeItem);
  39. noticeItem.getComponent("NoticeItem").init(0, n.postMsg, n.createTime);
  40. this.noticeWrap.addChild(noticeItem)
  41. })
  42. },
  43. fail: () => {}
  44. })
  45. },
  46. close() {
  47. this.node.destroy();
  48. },
  49. // update (dt) {},
  50. });