ClubTopNode.ts 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. import GameM, { AUDIO_TYPE } from "../../manager/GameM";
  2. import UiM, { PANEL_NAME } from "../../manager/UiM";
  3. import CashRecordNode from "../CashRecordNode";
  4. import ClubMain from "../ClubMain";
  5. import ClubMemberList from "./ClubMemberList";
  6. const { ccclass, property } = cc._decorator;
  7. @ccclass
  8. export default class ClubTopNode extends cc.Component {
  9. @property(cc.Sprite)
  10. head: cc.Sprite = null;
  11. @property(cc.Label)
  12. lvLabel: cc.Label = null;
  13. @property(cc.Label)
  14. nextLevelAddition: cc.Label = null;
  15. @property(cc.Label)
  16. tixianAddition: cc.Label = null;
  17. @property(cc.Label)
  18. alreadyTixian: cc.Label = null;
  19. @property(cc.Label)
  20. totalInviteNum: cc.Label = null;
  21. @property(cc.Label)
  22. tixianProgress: cc.Label = null;
  23. @property(cc.Sprite)
  24. tixianFill: cc.Sprite = null;
  25. @property(cc.Node)
  26. animNode: cc.Node = null;
  27. @property(sp.Skeleton)
  28. lvSke: sp.Skeleton = null;
  29. // LIFE-CYCLE CALLBACKS:
  30. // onLoad () {}
  31. start() {
  32. this.initCharacter()
  33. if (GameM.ClubData.clubBaseInfo == null || GameM.ClubData.clubBaseInfo == undefined) {
  34. GameM.ClubData.requestClubGetBaseInfo()
  35. } else {
  36. this.updateView(GameM.ClubData.clubBaseInfo)
  37. }
  38. GameM.ClubData.requestClubMyRecruitMembers()
  39. }
  40. initCharacter() {
  41. if (GameM.commonData.headimgurl != '') {
  42. cc.loader.load(GameM.commonData.headimgurl + "?aaa=aa.jpg", (err, res) => {
  43. if (err) {
  44. console.log('err:', err);
  45. return;
  46. }
  47. if (cc.isValid(this.head)) {
  48. let tex: cc.Texture2D = res as cc.Texture2D;
  49. this.head.spriteFrame = new cc.SpriteFrame(tex);
  50. }
  51. })
  52. }
  53. // this.updateView()
  54. }
  55. // int level = 0;//当前等级
  56. // double currentAddition = 0;//当前提现加成
  57. // double nextAddition = 0;//下一级提现加成
  58. // long currentRevenue = 0;//当前提成
  59. // long nextRevenue = 0;//下一级需达到提成额度
  60. // long balance = 0;//已到账金额
  61. // //总邀请人数
  62. // int totalRecruitNum
  63. updateView(data) {
  64. //to do
  65. this.lvLabel.string = 'Lv.' + data.level
  66. this.nextLevelAddition.string = data.nextAddition.toFixed(1) + "%"
  67. this.tixianAddition.string = data.currentAddition.toFixed(1) + "%"
  68. if (data.balance % 10000 != 0) {
  69. this.alreadyTixian.string = (data.balance / 10000).toFixed(2) + "元"
  70. } else {
  71. this.alreadyTixian.string = (data.balance / 10000).toFixed(2) + "元"
  72. }
  73. this.totalInviteNum.string = data.totalRecruitNum + "人"
  74. this.tixianProgress.string = data.currentRevenue/10000 + "/" + data.nextRevenue/10000 + "元"
  75. this.tixianFill.fillRange = data.currentRevenue / data.nextRevenue
  76. }
  77. showLevelAward() {
  78. GameM.audioM.playEffect(AUDIO_TYPE.button)
  79. cc.loader.loadRes('prefabs/club/clubLevelAward', cc.Prefab, (err, assets) => {
  80. if (err) {
  81. cc.error(err);
  82. return;
  83. }
  84. let node: cc.Node = cc.instantiate(assets)
  85. node.parent = UiM.Instance.clubMainNode.getComponent(ClubMain).alertNode
  86. node.name = "clubLevelAward"
  87. })
  88. }
  89. showMemberList() {
  90. // GameM.audioM.playEffect(AUDIO_TYPE.button)
  91. cc.loader.loadRes('prefabs/club/clubMemberList', cc.Prefab, (err, assets) => {
  92. if (err) {
  93. cc.error(err);
  94. return;
  95. }
  96. let node: cc.Node = cc.instantiate(assets)
  97. node.parent = UiM.Instance.clubMainNode.getComponent(ClubMain).alertNode
  98. if (GameM.ClubData.memberInfo) {
  99. node.getComponent(ClubMemberList).intiViewByIndex(0)
  100. }
  101. })
  102. }
  103. clickOpenRecord() {
  104. GameM.audioM.playEffect(AUDIO_TYPE.button)
  105. // GameM.audioM.playEffect(AUDIO_TYPE.button)
  106. // cc.loader.loadRes('prefabs/club/clubCashRecordNode', cc.Prefab, (err, assets) => {
  107. // if (err) {
  108. // cc.error(err);
  109. // return;
  110. // }
  111. // let node: cc.Node = cc.instantiate(assets)
  112. // node.parent = UiM.Instance.clubMainNode.getComponent(ClubMain).alertNode
  113. // })
  114. UiM.Instance.onPanel(PANEL_NAME.CashRecordNode, true, () => {
  115. if (cc.isValid(UiM.Instance.cashRecordNode)) {
  116. UiM.Instance.cashRecordNode.getComponent(CashRecordNode).initType(1)
  117. }
  118. })
  119. }
  120. showLevelUp() {
  121. let tempNode = cc.instantiate(this.animNode)
  122. tempNode.parent = this.node
  123. tempNode.position = this.node.convertToNodeSpaceAR(this.animNode.parent.convertToWorldSpaceAR(this.animNode.position))
  124. this.animNode.opacity = 0
  125. tempNode.runAction(cc.sequence(cc.scaleTo(0.2, 1.6),cc.callFunc(() => {
  126. this.showAction(tempNode)
  127. }), cc.delayTime(1), cc.scaleTo(0.3, 1), cc.callFunc(() => {
  128. GameM.ClubData.requestClubGetBaseInfo()
  129. this.animNode.opacity= 255
  130. tempNode.destroy()
  131. })))
  132. // this.animNode.runAction(cc.sequence(cc.scaleTo(0.2, 1.6), cc.delayTime(0.5), cc.callFunc(() => {
  133. // })))
  134. }
  135. showAction(node) {
  136. this.lvSke.node.active = true
  137. this.lvSke.setAnimation(0, "animation", false)
  138. this.lvLabel.string = "lv." + (GameM.ClubData.clubBaseInfo.level+1)
  139. node.getChildByName("tixianAddition").getComponent(cc.Label).string = GameM.ClubData.clubBaseInfo.nextAddition.toFixed(1)+"%"
  140. this.tixianAddition.string = GameM.ClubData.clubBaseInfo.nextAddition.toFixed(1) + "%"
  141. }
  142. showAnimAtion(){
  143. this.lvSke.node.active = true
  144. this.lvSke.setAnimation(0, "animation", false)
  145. }
  146. // update (dt) {}
  147. }