home_modules.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import { _decorator, Component, Node, Animation, Widget, tween } from 'cc';
  2. import { base_ui } from '../../fw/base_ui';
  3. import { uiManager } from '../../manager/uiManager';
  4. import { config } from '../../config';
  5. import { home_modules_more } from './home_modules_more';
  6. import { tools } from '../../tools';
  7. import { userDataManager } from '../../manager/userDataManager';
  8. import { ClientEvent } from '../../lib/clientEvent';
  9. const { ccclass, property } = _decorator;
  10. @ccclass('home_modules')
  11. export class home_modules extends base_ui {
  12. @property(Node) btn_qiandao:Node = null
  13. @property(Node) btn_gengduo:Node = null
  14. @property(Node) btn_cheku:Node = null
  15. @property(Node) btn_beibao:Node = null
  16. @property(Node) node_gengduo:Node = null
  17. @property(Node) img_dot_qiandao:Node = null
  18. @property(Node) img_dot_gengduo:Node = null
  19. start() {
  20. this.onButtonListen(this.btn_qiandao, ()=>{
  21. uiManager.Instance().showUi(config.UI.ui_sign_view)
  22. })
  23. this.onButtonListen(this.btn_gengduo, ()=>{
  24. this.node_gengduo.active = !this.node_gengduo.active
  25. if(this.node_gengduo.active) {
  26. this.node_gengduo.getComponent(Animation).play()
  27. }
  28. })
  29. this.onButtonListen(this.btn_cheku, ()=>{
  30. this.node.parent.active = false
  31. uiManager.Instance().showUi(config.UI.car_lib, null, ()=>{
  32. this.node.parent.active = true
  33. this.hideGengduoView()
  34. ClientEvent.dispatchEvent(config.UI_EVENT.HOME_DID_BECOME_INACTIVE)
  35. })
  36. })
  37. this.onButtonListen(this.btn_beibao, ()=>{
  38. this.node.parent.active = false
  39. uiManager.Instance().showUi(config.UI.bag, null, ()=>{
  40. this.node.parent.active = true
  41. this.hideGengduoView()
  42. ClientEvent.dispatchEvent(config.UI_EVENT.HOME_DID_BECOME_INACTIVE)
  43. })
  44. })
  45. this.node_gengduo.active = false
  46. this.startAnimation()
  47. }
  48. public init() {
  49. let data = userDataManager.user_red_dot_data
  50. this.showRedDotQiandao(data.sign_red_dot==1?true:false)
  51. this.showRedDotGonggao(data.bulletin_red_dot==1?true:false)
  52. let is_mail_read = userDataManager.user_red_dot_data.mail_unread_number>0?true:false
  53. this.showRedDotYoujian(is_mail_read)
  54. }
  55. private startAnimation() {
  56. let number = -115
  57. this.btn_qiandao.getComponent(Widget).left = number
  58. this.btn_gengduo.getComponent(Widget).left = number
  59. this.btn_cheku.getComponent(Widget).right = number
  60. this.btn_beibao.getComponent(Widget).right = number
  61. setTimeout(()=>{
  62. this.btn_qiandao.getComponent(Animation).play()
  63. this.btn_gengduo.getComponent(Animation).play()
  64. this.btn_cheku.getComponent(Animation).play()
  65. this.btn_beibao.getComponent(Animation).play()
  66. },200)
  67. }
  68. public showRedDotQiandao(is_show:boolean) {
  69. this.img_dot_qiandao.active = is_show
  70. }
  71. public showRedDotYoujian(is_show:boolean) {
  72. this.node_gengduo.getComponent(home_modules_more).showRedDotYoujian(is_show)
  73. this.checkRedDotMore()
  74. }
  75. public showRedDotGonggao(is_show:boolean) {
  76. this.node_gengduo.getComponent(home_modules_more).showRedDotGonggao(is_show)
  77. this.checkRedDotMore()
  78. }
  79. private checkRedDotMore() {
  80. let is_show = this.node_gengduo.getComponent(home_modules_more).getDotAllShow()
  81. this.img_dot_gengduo.active = is_show
  82. }
  83. public hideGengduoView() {
  84. if(this.node_gengduo.active==true) {
  85. this.node_gengduo.active = false
  86. }
  87. }
  88. }