12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- const Api = require('../net/Api');
- cc.Class({
- extends: cc.Component,
- properties: {
- noticeItem: {
- default: null,
- type: cc.Prefab,
- tooltip: "消息内容预制资源"
- },
- noticeWrap: {
- default: null,
- type: cc.Node,
- tooltip: "消息列表容器"
- },
- tipLabel: cc.Label,
- },
- onLoad() {
- },
- init() {
- },
- start() {
- let bouncesActionArray = [];
- let space = 50;
- let upAction = cc.moveTo(0.25, cc.v2(0, space));
- let downAction = cc.moveBy(0.1, cc.v2(0, -space));
- bouncesActionArray.push(upAction);
- bouncesActionArray.push(downAction);
- this.node.runAction(cc.sequence(bouncesActionArray));
- setTimeout(() => {
- this._initNoticeList()
- }, 300)
- },
- _initNoticeList() {
- Api.httpGet({
- url: "/post/getIndexPost.do",
- data: {},
- success: (res) => {
- res.list && res.list.forEach(n => {
- let noticeItem = cc.instantiate(this.noticeItem);
- noticeItem.getComponent("NoticeItem").init(0, n.postMsg, n.createTime);
- this.noticeWrap.addChild(noticeItem)
- })
- this.tipLabel.node.active = false;
- },
- fail: () => {
- this.tipLabel.node.active = true;
- this.tipLabel.string = '网络错误';
- }
- })
- },
- close() {
- this.node.destroy();
- },
- // update (dt) {},
- });
|