Bulletin.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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.getComponent(UIOpacity))
  23. .to(1.2, { opacity: 10 })
  24. .to(1, { opacity: 255 })
  25. .repeatForever()
  26. .start()
  27. }
  28. protected onDestroy() {
  29. }
  30. //UI开打时会调用,如果有初始化代码应该放到此函数
  31. onOpen(data:BulletinEnum) {
  32. this.data = data;
  33. this.msgTx.string = data.content;
  34. if (this.data.img){
  35. this.load('package', 'texture/login/bulletin_img/spriteFrame', SpriteFrame, (res: SpriteFrame) => {
  36. this.msgImg.spriteFrame = res;
  37. })
  38. }
  39. }
  40. //UI关闭时会调用,该函数在onDestroy前调用
  41. onClose() {
  42. }
  43. //框架管理UI层级时会调用,可根据UI情况修改
  44. onShow() {
  45. super.onShow();
  46. }
  47. //框架管理UI层级时会调用,可根据UI情况修改
  48. onHide() {
  49. super.onHide();
  50. }
  51. //UI事件处理
  52. private onTouchButton(event: Event) {
  53. let target: any = event.target;
  54. if (target.name == 'mask') {
  55. Framework.layer.close(this);
  56. }
  57. }
  58. }