import GameM, { AUDIO_TYPE } from "../../manager/GameM"; import UiM, { PANEL_NAME } from "../../manager/UiM"; import LogUtil from "../../utils/LogUtil"; import ClubMain from "../ClubMain"; import EffectNode from "../EffectNode"; import RedCodeNode from "../RedCodeNode"; import ClubInviteItem from "./ClubInviteItem"; import ClubInviteItem2 from "./ClubInviteItem2"; import ClubMemberUnCheck from "./ClubMemberUnCheck"; import ClubTixianNode from "./ClubTixianNode"; const { ccclass, property } = cc._decorator; @ccclass export default class ClubInviteNode extends cc.Component { @property(cc.RichText) gongGaoRT: cc.RichText = null; @property(cc.Node) contentNode: cc.Node = null; @property(cc.Label) totalInvite: cc.Label = null @property(cc.Label) unChecking: cc.Label = null @property(cc.Node) firstNode: cc.Node = null @property(cc.Node) gonggaoNode: cc.Node = null @property(cc.Node) zhaomuBtn: cc.Node = null @property(cc.Node) mainNode: cc.Node = null @property(cc.Node) dragArea: cc.Node = null @property(cc.Node) item1: cc.Node = null @property(cc.Node) item2: cc.Node = null @property(cc.Node) item1Click: cc.Node = null @property(cc.Node) item2Click: cc.Node = null @property(cc.Node) pageIndexNode: cc.Node = null @property(cc.Node) pageIndexShowNode: cc.Node = null @property(cc.SpriteFrame) pointSf: cc.SpriteFrame = null @property(cc.Node) content: cc.Node = null; @property(cc.Node) clubInviteItem2: cc.Node = null; // @property(cc.PageView) // @property() onLoad() { let addY = cc.winSize.height - 1334 // this.zhaomuBtn.height += addY/3 // this.mainNode.height += addY/3 if (addY > 0) { // this.gongGaoRT.node.parent.parent.y += addY/3 this.mainNode.y -= addY / 4 this.zhaomuBtn.y -= addY / 3 } } private gonggaoIndex = 0 private gonggaoList: Array = new Array() private index = 0 start() { this.initView() } initView() { GameM.ClubData.requestClubRecruitProgress() GameM.ClubData.requestClubRecruitBroadcast() GameM.ClubData.requestClubMyRecruitMembers() } updateGonggao(data) { if (data == null || data == undefined || data.length == 0) { this.gongGaoRT.node.parent.parent.active = false return } this.gongGaoRT.node.parent.parent.active = true this.gonggaoList = data this.gongGaoRT.node.stopAllActions() this.showGonggao() } showGonggao() { // this.gongGaoRT.string = str this.gonggaoIndex++ if (this.gonggaoIndex > this.gonggaoList.length - 1) { this.gonggaoIndex = 0 } let gonggaoData = this.gonggaoList[this.gonggaoIndex] let name = gonggaoData.name let peopleCount = "(" + gonggaoData.peopleCount + "/" + gonggaoData.peopleCount + ")" let amount = gonggaoData.amount / 10000 + "元" this.gongGaoRT.string = `${name}完成招募${peopleCount}成功提现${amount}` this.gongGaoRT.node.position = cc.v3(0, -50) this.gongGaoRT.node.runAction(cc.sequence(cc.moveTo(0.6, cc.v2(0, 0)), cc.delayTime(3.5), cc.moveTo(0.6, cc.v2(0, 50)), cc.callFunc(() => { this.showGonggao() }))) } // RichText#D75B1C updateFirstChildInfo() { if (GameM.ClubData.memberInfo == null || GameM.ClubData.memberInfo == undefined) { this.firstNode.active = false return } this.firstNode.active = true let child1List = GameM.ClubData.memberInfo.g1Members let child1Num = GameM.ClubData.memberInfo.g1Num let uncheckNum = 0 for (let i = 0; i < child1List.length; i++) { if (child1List[i].validStatus == 0) { uncheckNum++ } } this.totalInvite.string = child1Num + "" this.unChecking.string = uncheckNum + "" } showUncheckList() { GameM.audioM.playEffect(AUDIO_TYPE.button) if (GameM.ClubData.memberInfo == null || GameM.ClubData.memberInfo == null) { EffectNode.instance.PlayTip("当前没有徒弟") return } cc.loader.loadRes('prefabs/club/clubMemberUnCheck', 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.getComponent(ClubMemberUnCheck).getChildInfo() }) } sharePic() { GameM.audioM.playEffect(AUDIO_TYPE.button) GameM.ClubData.inviteOtherPlayer() } private coolTime = false private curSelDownItem = null private startX = 0 private preDownItem = null private progressRecord = null _n = 0 _dis = 5 //1.1.6优化内容 updateList() { if (GameM.ClubData.clubInviteInfo == null || GameM.ClubData.clubInviteInfo == undefined) { return } // let finishCount = GameM.ClubData.clubInviteInfo.finishCount // let progressRecord = GameM.ClubData.clubInviteInfo.progressRecord this.progressRecord = GameM.ClubData.clubInviteInfo.progressRecord let count = 0 console.log("------->ProgressRecord: ", this.progressRecord); this.content.removeAllChildren(); for (let i = 0; i < this.progressRecord.length; i++) { let item: cc.Node = cc.instantiate(this.clubInviteItem2) item.active = true let s = item.getComponent(ClubInviteItem2) s.initItem(this.progressRecord[i], count) this.content.addChild(item) count++ } //for (let entry of this.progressRecord) { // console.log("Count: " + count + " Status: " + entry.status); // if (entry.status != 1) { // // this.index = count // this.item1.getChildByName("clubInviteItem").getComponent(ClubInviteItem).initItem(entry, count) // this.index = count // console.log("---->Index: " + this.index); // // this.firstNode.parent = this.item1 // break // } // count++ //} //this.pageIndexNode.destroyAllChildren() //for (let i = 0; i <= this.progressRecord.length; i++) { // let node = new cc.Node() // let sprite = node.addComponent(cc.Sprite) // sprite.spriteFrame = this.pointSf // node.anchorX = 0 // node.parent = this.pageIndexNode //} //this.scheduleOnce(() => { // this.showPagePosition() //}, 0) // //this.dragArea.on(cc.Node.EventType.TOUCH_START, this.onDragStart, this) //this.dragArea.on(cc.Node.EventType.TOUCH_END, this.onDragEnd, this) } updateList2() { if (GameM.ClubData.clubInviteInfo == null || GameM.ClubData.clubInviteInfo == undefined) { return } // let finishCount = GameM.ClubData.clubInviteInfo.finishCount // let progressRecord = GameM.ClubData.clubInviteInfo.progressRecord this.progressRecord = GameM.ClubData.clubInviteInfo.progressRecord let count = 0 console.log("------->ProgressRecord: ", this.progressRecord); for (let entry of this.progressRecord) { console.log("Count: " + count + " Status: " + entry.status); if (entry.status != 1) { // this.index = count this.item1.getChildByName("clubInviteItem").getComponent(ClubInviteItem).initItem(entry, count) this.index = count console.log("---->Index: " + this.index); // this.firstNode.parent = this.item1 break } count++ } this.pageIndexNode.destroyAllChildren() for (let i = 0; i <= this.progressRecord.length; i++) { let node = new cc.Node() let sprite = node.addComponent(cc.Sprite) sprite.spriteFrame = this.pointSf node.anchorX = 0 node.parent = this.pageIndexNode } this.scheduleOnce(() => { this.showPagePosition() }, 0) this.dragArea.on(cc.Node.EventType.TOUCH_START, this.onDragStart, this) this.dragArea.on(cc.Node.EventType.TOUCH_END, this.onDragEnd, this) } showPagePosition() { let childrenNode = this.pageIndexNode.children if (cc.isValid(childrenNode[this.index])) { let worldPos = this.pageIndexNode.convertToWorldSpaceAR(childrenNode[this.index].position) this.pageIndexShowNode.position = this.pageIndexShowNode.parent.convertToNodeSpaceAR(worldPos) } } onDragStart(evt) { this.startX = evt.touch._point.x } onDragEnd(evt) { console.log("evt.touch._point.x " + evt.touch._point.x) console.log("evt.touch._point.y " + evt.touch._point.y) let end = evt.touch._point.x - this.startX if (Math.abs(end) > 20) { if (end > 0) { this.onSelDown(2, true) } else { this.onSelDown(1, true) } } else { if (Math.abs(end) < 5) { this.checkClickLingqu(evt.touch._point) } } } /** * 滑动选择 * @param state 1 向左 2 向右 */ onSelDown(state, slide = false) { if (this.coolTime) { return } if (this.progressRecord == null || this.progressRecord.length == 0) { return } let preTo = -750 let data = null if (state == 1) { if (this.index >= this.progressRecord.length - 1) { // if (slide) { // EffectNode.instance.PlayTip('已到最后一项') // } // return data = this.progressRecord[0] this.index = 0 } else { data = this.progressRecord[this.index + 1] this.index++ } if (this.curSelDownItem == this.item1) { this.curSelDownItem = this.item2 this.preDownItem = this.item1 } else { this.curSelDownItem = this.item1 this.preDownItem = this.item2 } this.curSelDownItem.getChildByName("clubInviteItem").getComponent(ClubInviteItem).initItem(data, this.index) this.curSelDownItem.x = 750 preTo = -750 } else if (state == 2) { if (this.index <= 0) { // if (slide) { // EffectNode.instance.PlayTip('已到第一项') // } // return data = this.progressRecord[this.progressRecord.length - 1] this.index = this.progressRecord.length - 1 } else { data = this.progressRecord[this.index - 1] this.index-- } if (this.curSelDownItem == this.item1) { this.curSelDownItem = this.item2 this.preDownItem = this.item1 } else { this.curSelDownItem = this.item1 this.preDownItem = this.item2 } this.curSelDownItem.getChildByName("clubInviteItem").getComponent(ClubInviteItem).initItem(data, this.index) this.curSelDownItem.x = -750 preTo = 750 } this.coolTime = true cc.tween(this.preDownItem).to(0.3, { x: preTo }, cc.easeInOut(1)).start() cc.tween(this.curSelDownItem).to(0.3, { x: 0 }, cc.easeInOut(1)).call(() => { this.coolTime = false this.showPagePosition() }).start() } onLeft() { GameM.audioM.playEffect(AUDIO_TYPE.button) this.onSelDown(2) } onRight() { GameM.audioM.playEffect(AUDIO_TYPE.button) this.onSelDown(1) } checkClickLingqu(pos: cc.Vec2) { if (this.item1Click.getBoundingBoxToWorld().contains(pos)) { this.clicktixian() return } if (this.item2Click.getBoundingBoxToWorld().contains(pos)) { this.clicktixian() return } if (this.firstNode.getBoundingBoxToWorld().contains(pos)) { this.showUncheckList() return } } clicktixian() { // to do LogUtil.logV('club>> clicktixian this.index', this.index) let curData = this.progressRecord[this.index] LogUtil.logV('club>> clicktixian curData', curData) if (GameM.ClubData.clubInviteInfo.finishCount < curData.peopleNum) { EffectNode.instance.PlayTip("招募人数不足") return } if (curData.status != 0) { this.clickRedCode() return } // GameM.ClubData.requestClubDoWithdraw(GameM.commonData.version,3+"", this.data.peopleNum, (this.data.rewardAmount)/10000) GameM.audioM.playEffect(AUDIO_TYPE.button) this.readyToLingqu(3 + "", (curData.rewardAmount / 10000), curData.peopleNum) } readyToLingqu(type, money, peopleNum) { GameM.audioM.playEffect(AUDIO_TYPE.button) // this.tixianNode.active = true cc.loader.loadRes('prefabs/club/ClubTixianNode', 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.openPanel(node) node.getComponent(ClubTixianNode).initView(type, money, peopleNum, this.index) }) } clickRedCode() { GameM.audioM.playEffect(AUDIO_TYPE.button) UiM.Instance.onPanel(PANEL_NAME.RedCodeNode, false, () => { UiM.Instance.redCodeNode.getComponent(RedCodeNode).init(50) }) } }