home_modules.ts 3.3 KB

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