| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442 |
- 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<any> = new Array<any>()
- 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 = `<b><outline color=#0F00FF width=2><color=#3bf8ff>${name}</color></outline><outline color=#b57541 width=2>完成招募${peopleCount}成功提现</outline><outline color=#0F00FF width=2><color=#3bf8ff>${amount}</color></outline></b>`
- 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()
- })))
- }
- // <color=#00ff00>Rich</c><color=#0fffff>Text</color>#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)
- })
- }
- }
|