NoticePopup.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. tipLabel: cc.Label,
  16. },
  17. onLoad() {
  18. },
  19. init() {
  20. },
  21. start() {
  22. // let bouncesActionArray = [];
  23. // let space = 50;
  24. // let upAction = cc.moveTo(0.25, cc.v2(0, space));
  25. // let downAction = cc.moveBy(0.1, cc.v2(0, -space));
  26. // bouncesActionArray.push(upAction);
  27. // bouncesActionArray.push(downAction);
  28. // this.node.runAction(cc.sequence(bouncesActionArray));
  29. setTimeout(() => {
  30. this._initNoticeList()
  31. }, 300)
  32. },
  33. _initNoticeList() {
  34. Api.httpGet({
  35. url: "/post/getIndexPost.do",
  36. data: {},
  37. success: (res) => {
  38. res.list && res.list.forEach(n => {
  39. let noticeItem = cc.instantiate(this.noticeItem);
  40. noticeItem.getComponent("NoticeItem").init(0, n.postMsg, n.createTime);
  41. this.noticeWrap.addChild(noticeItem)
  42. })
  43. this.tipLabel.node.active = false;
  44. },
  45. fail: () => {
  46. this.tipLabel.node.active = true;
  47. this.tipLabel.string = '网络错误';
  48. }
  49. })
  50. },
  51. close() {
  52. this.node.destroy();
  53. },
  54. // update (dt) {},
  55. });