home_modules.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import { _decorator, Component, Node, Animation } 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. })
  32. })
  33. this.onButtonListen(this.btn_beibao, ()=>{
  34. uiManager.Instance().showUi(config.UI.bag)
  35. })
  36. this.node_gengduo.active = false
  37. this.startAnimation()
  38. }
  39. public init() {
  40. let data = tools.user_red_dot_data
  41. this.showRedDotQiandao(data.sign_red_dot==1?true:false)
  42. this.showRedDotGonggao(data.bulletin_red_dot==1?true:false)
  43. let is_mail_read = tools.user_red_dot_data.mail_unread_number>0?true:false
  44. this.showRedDotYoujian(is_mail_read)
  45. }
  46. private startAnimation() {
  47. setTimeout(()=>{
  48. this.btn_qiandao.getComponent(Animation).play()
  49. this.btn_gengduo.getComponent(Animation).play()
  50. this.btn_cheku.getComponent(Animation).play()
  51. this.btn_beibao.getComponent(Animation).play()
  52. },200)
  53. }
  54. public showRedDotQiandao(is_show:boolean) {
  55. this.img_dot_qiandao.active = is_show
  56. }
  57. public showRedDotYoujian(is_show:boolean) {
  58. this.node_gengduo.getComponent(home_modules_more).showRedDotYoujian(is_show)
  59. this.checkRedDotMore()
  60. }
  61. public showRedDotGonggao(is_show:boolean) {
  62. this.node_gengduo.getComponent(home_modules_more).showRedDotGonggao(is_show)
  63. this.checkRedDotMore()
  64. }
  65. private checkRedDotMore() {
  66. let is_show = this.node_gengduo.getComponent(home_modules_more).getDotAllShow()
  67. this.img_dot_gengduo.active = is_show
  68. }
  69. }