ClubMain.ts 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. // Learn TypeScript:
  2. // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
  7. import GameM, { AUDIO_TYPE } from "../manager/GameM";
  8. import LogUtil from "../utils/LogUtil";
  9. import { Utils } from "../utils/Utils";
  10. const { ccclass, property } = cc._decorator;
  11. @ccclass
  12. export default class ClubMain extends cc.Component {
  13. // LIFE-CYCLE CALLBACKS:
  14. private clubActivePrefab: cc.Prefab = null
  15. private clubInvitePrefab: cc.Prefab = null
  16. private clubMinePrefab: cc.Prefab = null
  17. @property(cc.Toggle)
  18. activeToggle: cc.Toggle = null
  19. @property(cc.Toggle)
  20. inviteToggle: cc.Toggle = null
  21. @property(cc.Toggle)
  22. mineToggle: cc.Toggle = null
  23. @property(cc.Node)
  24. topNode: cc.Node = null
  25. @property(cc.Node)
  26. bottomNode: cc.Node = null
  27. @property(cc.Node)
  28. centerNode: cc.Node = null
  29. @property(cc.Node)
  30. alertNode: cc.Node = null
  31. private addY = 0
  32. async onLoad() {
  33. LogUtil.logV("ClubMain", "start")
  34. this.node.height = cc.winSize.height
  35. this.addY = cc.winSize.height - 1334
  36. // this.topNode.y += this.addY
  37. // this.bottomNode.y -= this.addY
  38. this.clubActivePrefab = await Utils.loadResPromise("prefabs/club/clubActiveNode")
  39. this.clubInvitePrefab = await Utils.loadResPromise("prefabs/club/clubInviteNode")
  40. this.clubMinePrefab = await Utils.loadResPromise("prefabs/club/clubMineNode")
  41. // this.scheduleOnce(()=>{
  42. GameM.ClubData.requestClubGetBaseInfo()
  43. //暂时不用
  44. // GameM.ClubData.autoCollectBubbles()
  45. // },1)
  46. this.checkPage(null, 1)
  47. }
  48. /**招募 */
  49. inviteNode: cc.Node = null
  50. /**我的 */
  51. mineNode: cc.Node = null
  52. /**活跃 */
  53. activeNode: cc.Node = null
  54. // }
  55. /**
  56. *
  57. * @param index 显示页签
  58. */
  59. checkPage(event, type) {
  60. GameM.audioM.playEffect(AUDIO_TYPE.button)
  61. let index: number = Number(type)
  62. if (index == 1) {
  63. this.topNode.active = false
  64. this.centerNode.active = true
  65. if (cc.isValid(this.inviteNode)) {
  66. this.inviteNode.active = true
  67. } else {
  68. this.inviteNode = cc.instantiate(this.clubInvitePrefab)
  69. this.inviteNode.parent = this.centerNode
  70. // this.inviteNode.position = cc.v3(0, 752, 0)
  71. }
  72. if (cc.isValid(this.mineNode)) {
  73. this.mineNode.active = false
  74. }
  75. if (cc.isValid(this.activeNode)) {
  76. this.activeNode.active = false
  77. }
  78. } else if (index == 2) {
  79. this.topNode.active = true
  80. this.centerNode.active = true
  81. if (cc.isValid(this.mineNode)) {
  82. this.mineNode.active = false
  83. }
  84. if (cc.isValid(this.activeNode)) {
  85. this.activeNode.active = true
  86. } else {
  87. this.activeNode = cc.instantiate(this.clubActivePrefab)
  88. this.activeNode.parent = this.centerNode
  89. // this.activeNode.position = cc.v3(0, -40, 0)
  90. }
  91. if (cc.isValid(this.inviteNode)) {
  92. this.inviteNode.active = false
  93. }
  94. } else if (index == 3) {
  95. this.topNode.active = true
  96. this.centerNode.active = true
  97. if (cc.isValid(this.mineNode)) {
  98. this.mineNode.active = true
  99. } else {
  100. this.mineNode = cc.instantiate(this.clubMinePrefab)
  101. this.mineNode.parent = this.centerNode
  102. // this.mineNode.position = cc.v3(0, -40, 0)
  103. }
  104. if (cc.isValid(this.activeNode)) {
  105. this.activeNode.active = false
  106. }
  107. if (cc.isValid(this.inviteNode)) {
  108. this.inviteNode.active = false
  109. }
  110. }
  111. }
  112. clickBack() {
  113. GameM.audioM.playEffect(AUDIO_TYPE.button)
  114. this.node.destroy()
  115. }
  116. // update (dt) {}
  117. }