import AdM from "../manager/AdM"; import GameM from "../manager/GameM"; import UiM, { PANEL_NAME } from "../manager/UiM"; import CashRecordNode from "../ui/CashRecordNode"; import ClubActiveNode from "../ui/club/ClubActiveNode"; import ClubInviteNode from "../ui/club/ClubInviteNode"; import ClubLevelAward from "../ui/club/ClubLevelAward"; import ClubMemberList from "../ui/club/ClubMemberList"; import ClubMineNode from "../ui/club/ClubMineNode"; import ClubShouquShanggong from "../ui/club/ClubShouquShanggong"; import ClubShouyiInfo from "../ui/club/ClubShouyiInfo"; import ClubTixianNode from "../ui/club/ClubTixianNode"; import ClubTopNode from "../ui/club/ClubTopNode"; import ClubMain from "../ui/ClubMain"; import EffectNode from "../ui/EffectNode"; import OfficialNode from "../ui/OfficialNode"; import RedCodeNode from "../ui/RedCodeNode"; import LogUtil from "../utils/LogUtil"; // import CaiDanData from "./CaiDanData"; import { HTTP_TYPE } from "./CommonData"; // import FissionCaidanData from "./FissionCaidanData"; const { ccclass, property } = cc._decorator; export default class ClubData { private static instance: ClubData = null static get Instance(): ClubData { if (!this.instance) { this.instance = new ClubData() } return this.instance } localTest = false inviteUin: string = ""; /**基础信息 */ clubBaseInfo = null /**活跃信息 */ clubActiveInfo = null /**提现档位信息 */ activeTixianInfo = null /**已到账金额 */ currentGetMoney: number = 0 /**提现加成 */ invitePersons: number = 0 /**总邀请 */ getMoneyAddition: number = 0 /**成员列表 */ memberInfo: any = null /**俱乐部提现记录 */ clubCashRecord: any = null /**招募进度信息 */ clubInviteInfo = null /**是否授权之后上报inviteCode */ clubAuthPushInviteIn = false /** 分享链接信息 */ clubShowShareInfo: any = null shareUrlWeixin = "https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/haocheyijia/west/JourneyToTheWest/index.html" shareUrlBrowser = "https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/haocheyijia/west/JourneyToTheWest/index.html" // shareUrlRedPocket = "https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/haocheyijia/club/web_mobile/carClubPlay3/index.html" clubRecordAwardTypeArr = ['每日提现', '累计提现', '招募提现'] /**招募进度 */ requestClubRecruitProgress() { if (this.localTest) { let data = [{}, {}, {}] this.getClubRecruitProgress(data) } else { GameM.httpM.sendDatas(HTTP_TYPE.clubRecruitProgress, null, GameM.ClubData.getClubRecruitProgress.bind(this)); } } getClubRecruitProgress(data) { LogUtil.logV("getClubRecruitProgress", "start"); LogUtil.logV("getClubRecruitProgress", data) this.clubInviteInfo = data if (UiM.Instance.clubMainNode) UiM.Instance.clubMainNode.getComponent(ClubMain).inviteNode.getComponent(ClubInviteNode).updateList() } /**获取短地址 */ requestClubShorturl(data: string) { if (this.localTest) { this.getClubShorturl(null) } else { GameM.httpM.sendDatas(HTTP_TYPE.clubShorturl, { url: data }, GameM.ClubData.getClubShorturl.bind(this)); } } getClubShorturl(data) { if (data == null || data == undefined || data == "") { return } this.shortUrl = data this.sendInviteInfo() // AdM.shareClubInstallUrl(data) // GameM.httpM.sendDatas(HTTP_TYPE.clubRecruitProgress,{}); //to do } /**招募完成提现广播 */ requestClubRecruitBroadcast() { if (this.localTest) { let data = [{}, {}, {}] this.getClubRecruitBroadcast(data) } else { GameM.httpM.sendDatas(HTTP_TYPE.clubRecruitBroadcast, null, GameM.ClubData.getClubRecruitBroadcast.bind(this)); } } getClubRecruitBroadcast(data) { LogUtil.logV("getClubRecruitBroadcast", "start"); // data = [{ // "name": "张三", // "peopleCount": "12", // "amount": 100 // }, { // "name": "张四", // "peopleCount": "9", // "amount": 1000 // }, { // "name": "张五", // "peopleCount": "6", // "amount": 10000 // }] // data = [] // data.push({"name":"张三","peopleCount":12,}) if (UiM.Instance.clubMainNode) UiM.Instance.clubMainNode.getComponent(ClubMain).inviteNode.getComponent(ClubInviteNode).updateGonggao(data) } /**会员个人基础信息 */ requestClubGetBaseInfo() { if (this.localTest) { let data = [{}, {}, {}] this.getClubGetBaseInfo(data) } else { GameM.httpM.sendDatas(HTTP_TYPE.clubGetBaseInfo, null, GameM.ClubData.getClubGetBaseInfo.bind(this)); } } getClubGetBaseInfo(data) { LogUtil.logV("getClubGetBaseInfo", "start"); this.clubBaseInfo = data if (UiM.Instance.clubMainNode && cc.isValid(UiM.Instance.clubMainNode.getComponent(ClubMain).topNode)) { UiM.Instance.clubMainNode.getComponent(ClubMain).topNode.getComponent(ClubTopNode).updateView(data) } if (UiM.Instance.clubMainNode && cc.isValid(UiM.Instance.clubMainNode.getComponent(ClubMain).activeNode)) { UiM.Instance.clubMainNode.getComponent(ClubMain).activeNode.getComponent(ClubActiveNode).updateMoney() } } /**活跃奖励气泡 */ requestClubMyBubbleData() { if (this.localTest) { let data = [{}, {}, {}] this.getClubMyBubbleData(data) } else { GameM.httpM.sendDatas(HTTP_TYPE.clubMyBubbleData, null, GameM.ClubData.getClubMyBubbleData.bind(this)); } } getClubMyBubbleData(data) { LogUtil.logV("getClubMyBubbleData", "start"); this.clubActiveInfo = data if (UiM.Instance.clubMainNode) UiM.Instance.clubMainNode.getComponent(ClubMain).activeNode.getComponent(ClubActiveNode).updateView(this.clubActiveInfo) } /**等级奖励规则 */ requestClubLevelRewardRule() { if (this.localTest) { let data = [{}, {}, {}] this.getClubMyBubbleData(data) } else { GameM.httpM.sendDatas(HTTP_TYPE.clubLevelRewardRule, null, GameM.ClubData.getClubLevelRewardRule.bind(this)); } } getClubLevelRewardRule(data) { LogUtil.logV("getClubLevelRewardRule", "start"); if (UiM.Instance.clubMainNode) UiM.Instance.clubMainNode.getComponent(ClubMain).alertNode.getChildByName("clubLevelAward").getComponent(ClubLevelAward).updateView(data) } /**我招募的后代成员 */ requestClubMyRecruitMembers() { if (this.localTest) { let data = [{}, {}, {}] this.getClubMyRecruitMembers(data) } else { GameM.httpM.sendDatas(HTTP_TYPE.clubMyRecruitMembers, null, GameM.ClubData.getClubMyRecruitMembers.bind(this)); } } getClubMyRecruitMembers(data) { LogUtil.logV("getClubMyRecruitMembers", "start"); this.memberInfo = data // LogUtil.logV('caidan ', this.memberInfo) if (this.memberInfo) { let num = 0 if (this.memberInfo.g1Members) { num = this.memberInfo.g1Members.length } // CaiDanData.Instance.addProgress(1, false, num) // FissionCaidanData.Instance.addFissionProgress(1, false, num, 0) let valid = 0 for (const member of this.memberInfo.g1Members) { if (member.validStatus == 1) { valid++ } } GameM.commonData.roleData.inviteTotal++ GameM.commonData.updateRoleData() // FissionCaidanData.Instance.addFissionProgress(1, false, valid, 1) } if (UiM.Instance.clubMainNode && cc.isValid(UiM.Instance.clubMainNode.getComponent(ClubMain).mineNode)) { UiM.Instance.clubMainNode.getComponent(ClubMain).mineNode.getComponent(ClubMineNode).updateView(data) } if (UiM.Instance.clubMainNode && cc.isValid(UiM.Instance.clubMainNode.getComponent(ClubMain).alertNode.getChildByName("clubMemberList"))) { if (GameM.ClubData.memberInfo) { let node = UiM.Instance.clubMainNode.getComponent(ClubMain).alertNode.getChildByName("clubMemberList") node.getComponent(ClubMemberList).intiViewByIndex(0) } } if (UiM.Instance.clubMainNode && cc.isValid(UiM.Instance.clubMainNode.getComponent(ClubMain).inviteNode)) { UiM.Instance.clubMainNode.getComponent(ClubMain).inviteNode.getComponent(ClubInviteNode).updateFirstChildInfo() } } /**收取泡泡/确定过期泡泡 */ requestClubCollectBubbles(date: string, generation = 0) { if (this.localTest) { let data = [{}, {}, {}] this.getClubCollectBubbles(data) } else { let data = {} data["date"] = date if (generation != 0) { data["generation"] = generation } GameM.httpM.sendDatas(HTTP_TYPE.clubCollectBubbles, data, GameM.ClubData.getClubCollectBubbles.bind(this)); } } getClubCollectBubbles(data) { LogUtil.logV("getClubCollectBubbles", "start"); if (UiM.Instance.clubMainNode && cc.isValid(UiM.Instance.clubMainNode.getComponent(ClubMain).alertNode.getChildByName("clubShouquShanggong"))) { UiM.Instance.clubMainNode.getComponent(ClubMain).alertNode.getChildByName("clubShouquShanggong").getComponent(ClubShouquShanggong).sendSuccess() } } /**预估收益 */ requestClubPredictRevenue() { if (this.localTest) { let data = [{}, {}, {}] this.getClubPredictRevenue(data) } else { GameM.httpM.sendDatas(HTTP_TYPE.clubPredictRevenue, null, GameM.ClubData.getClubPredictRevenue.bind(this)); } } getClubPredictRevenue(data) { LogUtil.logV("getClubPredictRevenue", "start"); if (UiM.Instance.clubMainNode && cc.isValid(UiM.Instance.clubMainNode.getComponent(ClubMain).alertNode.getChildByName("clubShouyiInfo"))) { UiM.Instance.clubMainNode.getComponent(ClubMain).alertNode.getChildByName("clubShouyiInfo").getComponent(ClubShouyiInfo).updateView(data) } } /**活跃奖励提现档位 */ requestClubWithdrawDenominations() { if (this.localTest) { let data = [{}, {}, {}] this.getClubWithdrawDenominations(data) } else { GameM.httpM.sendDatas(HTTP_TYPE.clubWithdrawDenominations, null, GameM.ClubData.getClubWithdrawDenominations.bind(this)); } } getClubWithdrawDenominations(data) { LogUtil.logV("getClubWithdrawDenominations", "start"); this.activeTixianInfo = data if (UiM.Instance.clubMainNode && cc.isValid(UiM.Instance.clubMainNode.getComponent(ClubMain).activeNode)) { UiM.Instance.clubMainNode.getComponent(ClubMain).activeNode.getComponent(ClubActiveNode).initTixianBtn(data) } } //提现金额 private clubCashMoney = 0 private peopleNum = 0 private clubCashIndex = -1 /**提现 * appVersion 应用版本号 * applyType 1每日提现,2累计提现,3招募提现 * peopleNum 招募进度(3人,6人,12人,20人) * index 档位,取招募和累计提现档位下标,每日为-1 */ requestClubDoWithdraw(appVersion: string, applyType: string, peopleNum: number, cashMoney: number, index: number) { this.clubCashMoney = cashMoney this.peopleNum = peopleNum this.clubCashIndex = index if (this.localTest) { let data = Number(applyType) this.getClubDoWithdraw({ "isCashSuccess": 1 }, data) } else { if (applyType == "1" || applyType == "2") { GameM.httpM.sendDatas(HTTP_TYPE.clubDoWithdraw, { "appVersion": appVersion, "applyType": applyType }, GameM.ClubData.getClubDoWithdraw.bind(this)); } else { GameM.httpM.sendDatas(HTTP_TYPE.clubDoWithdraw, { "appVersion": appVersion, "applyType": applyType, "peopleNum": peopleNum }, GameM.ClubData.getClubDoWithdraw.bind(this)); } } } getClubDoWithdraw(data, applyType) { LogUtil.logV("getClubDoWithdraw", "start"); if (data.isCashSuccess == 0) { EffectNode.instance.PlayTip(data.message) if (UiM.Instance.clubMainNode && cc.isValid(UiM.Instance.clubMainNode.getComponent(ClubMain).alertNode.getChildByName("ClubTixianNode"))) { UiM.Instance.clubMainNode.getComponent(ClubMain).alertNode.getChildByName("ClubTixianNode").getComponent(ClubTixianNode).tixianFail() } return } if (Number(applyType) == 1 || Number(applyType) == 2) { if (Number(applyType) == 1) { AdM.onSendEvent('club_DailyCashSuccess', '每日提现-成功', 'club') } else { AdM.onSendEvent('club_LeijiCashSuccess' + this.clubCashIndex, '累计提现-成功', 'club') } if (UiM.Instance.clubMainNode && cc.isValid(UiM.Instance.clubMainNode.getComponent(ClubMain).activeNode)) { this.clubBaseInfo.balance = this.clubBaseInfo.balance + (this.clubCashMoney) this.clubBaseInfo.pool = this.clubBaseInfo.pool - this.clubCashMoney * 10000 // if (Number(applyType) == 2) { // GameM.commonData.roleData.clubLeijiTixian++ // GameM.commonData.updateRoleData() // } this.requestClubWithdrawDenominations() } } else if (Number(applyType) == 3) { AdM.onSendEvent('club_InviteCashSuccess' + this.clubCashIndex, '招募提现-成功', 'club') for (let i = 0; i < this.clubInviteInfo.progressRecord.length; i++) { if (this.clubInviteInfo.progressRecord[i].peopleNum == this.peopleNum) { this.clubInviteInfo.progressRecord[i].status = 1 if (this.clubBaseInfo) { this.clubBaseInfo.balance = this.clubBaseInfo.balance + (this.clubInviteInfo.progressRecord[i].rewardAmount / 10000) this.clubBaseInfo.pool = this.clubBaseInfo.pool - this.clubInviteInfo.progressRecord[i].rewardAmount } break } } } this.requestClubGetBaseInfo() if (UiM.Instance.clubMainNode && cc.isValid(UiM.Instance.clubMainNode.getComponent(ClubMain).alertNode.getChildByName("ClubTixianNode"))) { UiM.Instance.clubMainNode.getComponent(ClubMain).alertNode.getChildByName("ClubTixianNode").getComponent(ClubTixianNode).tixianSuccess(data.withdrawalCode == null || data.withdrawalCode == undefined) } if (UiM.Instance.clubMainNode && cc.isValid(UiM.Instance.clubMainNode.getComponent(ClubMain).inviteNode)) { UiM.Instance.clubMainNode.getComponent(ClubMain).inviteNode.getComponent(ClubInviteNode).updateList() } // if (UiM.Instance.clubMainNode && cc.isValid(UiM.Instance.clubMainNode.getComponent(ClubMain).topNode)) { // UiM.Instance.clubMainNode.getComponent(ClubMain).topNode.getComponent(ClubTopNode).updateView(this.clubBaseInfo) // } if (UiM.Instance.clubMainNode && cc.isValid(UiM.Instance.clubMainNode.getComponent(ClubMain).activeNode)) { UiM.Instance.clubMainNode.getComponent(ClubMain).activeNode.getComponent(ClubActiveNode).updateView(this.clubActiveInfo) } if (data.withdrawalCode) { UiM.Instance.onPanel(PANEL_NAME.OfficialNode, false, () => { UiM.Instance.officialNode.getComponent(OfficialNode).init(this.clubCashMoney, data.withdrawalCode); AdM.onSendEvent('publicmoney_4', '公众号提现-裂变', 'publicmoney') }) } } /**提现记录*/ requestClubWithDrawRecords() { if (this.localTest) { this.getRequestClubWithDrawRecords(null) } else { GameM.httpM.sendDatas(HTTP_TYPE.clubWithDrawRecords, null, GameM.ClubData.getRequestClubWithDrawRecords.bind(this)); } } getRequestClubWithDrawRecords(data) { LogUtil.logV("getRequestClubWithDrawRecords", "start"); this.clubCashRecord = data if (cc.isValid(UiM.Instance.cashRecordNode)) { UiM.Instance.cashRecordNode.getComponent(CashRecordNode).freshRecord() } if (UiM.Instance.redCodeNode) { UiM.Instance.redCodeNode.getComponent(RedCodeNode).freshRecord() } } //获取裂变红包码 getRedCodeByClubCashType() { let arr = [] for (var i = 0; i < this.clubCashRecord.length; i++) { if (this.clubCashRecord[i].withdrawCode) { arr.push(this.clubCashRecord[i]) } } return arr } shortUrl: string = "" cashRecord: Array = null inviteOtherPlayer() { AdM.onSendEvent('club_ShareInvite', '俱乐部邀请微信分享', 'club') this.shortUrl = "" this.cashRecord = null let uin = GameM.commonData.uin let url = this.shareUrlWeixin if (GameM.commonData.clubSharePageMode == 1) { url = this.shareUrlBrowser } url = url + "?inviteuin=" + uin + "&stu=" + GameM.commonData.headimgurl + "&sn=" + GameM.commonData.nickname GameM.ClubData.requestClubShorturl(url) GameM.httpM.sendDatas(HTTP_TYPE.getCashRecord, null, GameM.commonData.resultCashRecord.bind(GameM.commonData)) } sendInviteInfo() { if (this.cashRecord == null || this.shortUrl == null || this.shortUrl == "") { LogUtil.logV("sendInviteInfo ", "有一个请求还没到") return } let totalMoney = 0 let readConfig = null let title = "" let describe = "" let imgUrl = "" let showCfgPool = new Array() let noMoneyInfoPool = new Array() for (let entry of this.cashRecord) { totalMoney += entry.amount } for (let entry of this.clubShowShareInfo) { if (entry.limitMoney == 0) { noMoneyInfoPool.push(entry) } else { showCfgPool.push(entry) } } if (showCfgPool.length > 0 && showCfgPool[0].limitMoney <= totalMoney * 0.0001) { readConfig = showCfgPool } else { readConfig = noMoneyInfoPool } let index = Math.floor(Math.random() * readConfig.length) title = readConfig[index].title describe = readConfig[index].describe imgUrl = readConfig[index].imgUrl if (describe.indexOf("$") >= 0) { describe = describe.replace("$", (totalMoney * 0.0001).toFixed(2)) } LogUtil.logV("sendInviteInfo title", title) LogUtil.logV("sendInviteInfo describe", describe) LogUtil.logV("sendInviteInfo imgUrl", imgUrl) let tempStr = this.shortUrl + "" this.cashRecord = null this.shortUrl = "" AdM.shareClubInstallUrl(tempStr, title, describe, imgUrl) LogUtil.logV("sendInviteInfo", "end") } autoCollectBubbles() { GameM.httpM.sendDatas(HTTP_TYPE.autoCollectBubbles, null, GameM.ClubData.autoCollectBubblesBack.bind(this)) } autoCollectBubblesBack(data) { LogUtil.logV('autoCollectBubblesBack ', data) } }