Bulletin.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import { _decorator, Label, Node, RichText, Sprite, SpriteFrame, tween, UIOpacity } from 'cc';
  2. import { BaseView } from '../../../framework/layer/BaseView';
  3. import { Framework } from '../../../framework/Framework';
  4. import { StringUtil } from '../../../framework/util/StringUtil';
  5. import { BulletinEnum } from '../../common/InterfaceAddEnum';
  6. const { ccclass, property } = _decorator;
  7. @ccclass('Bulletin')
  8. export class Bulletin extends BaseView {
  9. @property({ type: Label, tooltip: "关闭提示" })
  10. closeTips: Label = null;
  11. @property({ type: Label, tooltip: "标题" })
  12. titleTx: Label = null;
  13. @property({ type: Sprite, tooltip: "公告图" })
  14. msgImg: Sprite = null;
  15. @property({ type: RichText, tooltip: "公告内容" })
  16. msgTx: RichText = null;
  17. private data:BulletinEnum = null;
  18. protected onLoad() {
  19. super.onLoad();
  20. this.closeTips.string = StringUtil.getLanguageData('点击空白关闭');
  21. this.titleTx.string = StringUtil.getLanguageData('公告');
  22. tween(this.closeTips.node.getComponent(UIOpacity))
  23. .to(1.2, { opacity: 10 })
  24. .to(1, { opacity: 255 })
  25. .union()
  26. .repeatForever()
  27. .start()
  28. }
  29. protected onDestroy() {
  30. }
  31. //UI开打时会调用,如果有初始化代码应该放到此函数
  32. onOpen(data:BulletinEnum) {
  33. this.data = data;
  34. this.msgTx.string = data.content;
  35. if (this.data.img){
  36. this.load('package', 'texture/login/bulletin_img/spriteFrame', SpriteFrame, (res: SpriteFrame) => {
  37. this.msgImg.spriteFrame = res;
  38. })
  39. }
  40. }
  41. //UI关闭时会调用,该函数在onDestroy前调用
  42. onClose() {
  43. }
  44. //框架管理UI层级时会调用,可根据UI情况修改
  45. onShow() {
  46. super.onShow();
  47. }
  48. //框架管理UI层级时会调用,可根据UI情况修改
  49. onHide() {
  50. super.onHide();
  51. }
  52. //UI事件处理
  53. private onTouchButton(event: Event) {
  54. let target: any = event.target;
  55. if (target.name == 'mask') {
  56. Framework.layer.close(this);
  57. }
  58. }
  59. }