| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- import GameM, { AUDIO_TYPE } from "../../manager/GameM";
- import UiM, { PANEL_NAME } from "../../manager/UiM";
- import CashRecordNode from "../CashRecordNode";
- import ClubMain from "../ClubMain";
- import ClubMemberList from "./ClubMemberList";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class ClubTopNode extends cc.Component {
- @property(cc.Sprite)
- head: cc.Sprite = null;
- @property(cc.Label)
- lvLabel: cc.Label = null;
- @property(cc.Label)
- nextLevelAddition: cc.Label = null;
- @property(cc.Label)
- tixianAddition: cc.Label = null;
- @property(cc.Label)
- alreadyTixian: cc.Label = null;
- @property(cc.Label)
- totalInviteNum: cc.Label = null;
- @property(cc.Label)
- tixianProgress: cc.Label = null;
- @property(cc.Sprite)
- tixianFill: cc.Sprite = null;
- @property(cc.Node)
- animNode: cc.Node = null;
- @property(sp.Skeleton)
- lvSke: sp.Skeleton = null;
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {}
- start() {
- this.initCharacter()
- if (GameM.ClubData.clubBaseInfo == null || GameM.ClubData.clubBaseInfo == undefined) {
- GameM.ClubData.requestClubGetBaseInfo()
- } else {
- this.updateView(GameM.ClubData.clubBaseInfo)
- }
- GameM.ClubData.requestClubMyRecruitMembers()
- }
- initCharacter() {
- if (GameM.commonData.headimgurl != '') {
- cc.loader.load(GameM.commonData.headimgurl + "?aaa=aa.jpg", (err, res) => {
- if (err) {
- console.log('err:', err);
- return;
- }
- if (cc.isValid(this.head)) {
- let tex: cc.Texture2D = res as cc.Texture2D;
- this.head.spriteFrame = new cc.SpriteFrame(tex);
- }
- })
- }
- // this.updateView()
- }
- // int level = 0;//当前等级
- // double currentAddition = 0;//当前提现加成
- // double nextAddition = 0;//下一级提现加成
- // long currentRevenue = 0;//当前提成
- // long nextRevenue = 0;//下一级需达到提成额度
- // long balance = 0;//已到账金额
- // //总邀请人数
- // int totalRecruitNum
- updateView(data) {
- //to do
- this.lvLabel.string = 'Lv.' + data.level
- this.nextLevelAddition.string = data.nextAddition.toFixed(1) + "%"
- this.tixianAddition.string = data.currentAddition.toFixed(1) + "%"
- if (data.balance % 10000 != 0) {
- this.alreadyTixian.string = (data.balance / 10000).toFixed(2) + "元"
- } else {
- this.alreadyTixian.string = (data.balance / 10000).toFixed(2) + "元"
- }
- this.totalInviteNum.string = data.totalRecruitNum + "人"
- this.tixianProgress.string = data.currentRevenue/10000 + "/" + data.nextRevenue/10000 + "元"
- this.tixianFill.fillRange = data.currentRevenue / data.nextRevenue
- }
- showLevelAward() {
- GameM.audioM.playEffect(AUDIO_TYPE.button)
- cc.loader.loadRes('prefabs/club/clubLevelAward', cc.Prefab, (err, assets) => {
- if (err) {
- cc.error(err);
- return;
- }
- let node: cc.Node = cc.instantiate(assets)
- node.parent = UiM.Instance.clubMainNode.getComponent(ClubMain).alertNode
- node.name = "clubLevelAward"
- })
- }
- showMemberList() {
- // GameM.audioM.playEffect(AUDIO_TYPE.button)
- cc.loader.loadRes('prefabs/club/clubMemberList', cc.Prefab, (err, assets) => {
- if (err) {
- cc.error(err);
- return;
- }
- let node: cc.Node = cc.instantiate(assets)
- node.parent = UiM.Instance.clubMainNode.getComponent(ClubMain).alertNode
- if (GameM.ClubData.memberInfo) {
- node.getComponent(ClubMemberList).intiViewByIndex(0)
- }
- })
- }
- clickOpenRecord() {
- GameM.audioM.playEffect(AUDIO_TYPE.button)
- // GameM.audioM.playEffect(AUDIO_TYPE.button)
- // cc.loader.loadRes('prefabs/club/clubCashRecordNode', cc.Prefab, (err, assets) => {
- // if (err) {
- // cc.error(err);
- // return;
- // }
- // let node: cc.Node = cc.instantiate(assets)
- // node.parent = UiM.Instance.clubMainNode.getComponent(ClubMain).alertNode
- // })
- UiM.Instance.onPanel(PANEL_NAME.CashRecordNode, true, () => {
- if (cc.isValid(UiM.Instance.cashRecordNode)) {
- UiM.Instance.cashRecordNode.getComponent(CashRecordNode).initType(1)
- }
- })
- }
- showLevelUp() {
- let tempNode = cc.instantiate(this.animNode)
- tempNode.parent = this.node
- tempNode.position = this.node.convertToNodeSpaceAR(this.animNode.parent.convertToWorldSpaceAR(this.animNode.position))
- this.animNode.opacity = 0
- tempNode.runAction(cc.sequence(cc.scaleTo(0.2, 1.6),cc.callFunc(() => {
- this.showAction(tempNode)
- }), cc.delayTime(1), cc.scaleTo(0.3, 1), cc.callFunc(() => {
- GameM.ClubData.requestClubGetBaseInfo()
- this.animNode.opacity= 255
- tempNode.destroy()
- })))
- // this.animNode.runAction(cc.sequence(cc.scaleTo(0.2, 1.6), cc.delayTime(0.5), cc.callFunc(() => {
-
- // })))
- }
- showAction(node) {
- this.lvSke.node.active = true
- this.lvSke.setAnimation(0, "animation", false)
- this.lvLabel.string = "lv." + (GameM.ClubData.clubBaseInfo.level+1)
- node.getChildByName("tixianAddition").getComponent(cc.Label).string = GameM.ClubData.clubBaseInfo.nextAddition.toFixed(1)+"%"
- this.tixianAddition.string = GameM.ClubData.clubBaseInfo.nextAddition.toFixed(1) + "%"
- }
- showAnimAtion(){
- this.lvSke.node.active = true
- this.lvSke.setAnimation(0, "animation", false)
- }
- // update (dt) {}
- }
|