| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- /** 常规提现数据类 */
- import Main from "../Main"
- import AdM from "../manager/AdM"
- import GameM from "../manager/GameM"
- import UiM, { PANEL_NAME } from "../manager/UiM"
- import CashOut from "../ui/CashOut"
- import EffectNode from "../ui/EffectNode"
- import OfficialNode from "../ui/OfficialNode"
- import LogUtil from "../utils/LogUtil"
- import { HTTP_TYPE } from "./CommonData"
- export default class CashOutData {
- private static instance: CashOutData = null
- static get Instance(): CashOutData {
- if (!CashOutData.instance) {
- CashOutData.instance = new CashOutData()
- }
- return CashOutData.instance
- }
- /** 提现配置 (包括每日提现金额配置)*/
- cashCft: any = null
- /** 提现状态 */
- cashStatus = []
- /** 当前可以提现index -1 为没有*/
- canCashIndex = -1
- /** 检查是否可以提现 */
- checkCanCash() {
- if (!GameM.commonData.redSwitch) {
- return
- }
- if (!cc.isValid(UiM.Instance) || !cc.isValid(UiM.Instance.hallNode)) {
- return
- }
- let main = UiM.Instance.hallNode.getComponent(Main)
- if (this.canCashIndex != -1 || main.hasHand || main.buyHand.active || GameM.commonData.maxCarLevel < this.cashCft[0].type_value) {
- return
- }
- let cfg = this.cashCft
- let num = 0
- let desIndex = -1
- for (var i = 0; i < cfg.length; i++) {
- if (cfg[i].num == 1 && this.getCashStatus(cfg[i].index) == 1) {
- }
- else {
- if (num == 3 && desIndex == -1) {
- for (var j = i; j < cfg.length; j++) {
- if (cfg[j].money == 100) {
- if (this.checkCan(cfg[j])) {
- this.canCashIndex = cfg[j].index
- main.showCashHand()
- }
- break
- }
- }
- break
- }
- else {
- if (this.checkCan(cfg[i])) {
- this.canCashIndex = cfg[i].index
- main.showCashHand()
- break
- }
- }
- num++
- if (cfg[i].money == 100) {
- desIndex = cfg[i].index
- }
- if (num == 4) {
- break
- }
- }
- }
- }
- private checkCan(data) {
- let state = false
- if (data.money_type == 1) {
- state = (data.money * 10000) <= GameM.commonData.redMoney && GameM.commonData.videoTimes >= data.type_value && Number(data.time) <= GameM.commonData.loginDays
- }
- else if (data.money_type == 2) {
- state = (data.money * 10000) <= GameM.commonData.redMoney && GameM.commonData.roleData.lv >= data.type_value && Number(data.time) <= GameM.commonData.loginDays
- }
- else if (data.money_type == 3) {
- state = (data.money * 10000) <= GameM.commonData.redMoney && GameM.commonData.maxCarLevel >= data.type_value && Number(data.time) <= GameM.commonData.loginDays
- }
- else if (data.money_type == 4) {
- state = (data.money * 10000) <= GameM.commonData.redMoney && GameM.commonData.loginDays >= data.type_value && Number(data.time) <= GameM.commonData.loginDays
- }
- return state
- }
- /** 提现返回 */
- resultCash(data, param) {
- LogUtil.logV('resultCash ', this.cashStatus)
- this.cashStatus = data.CashStatusList
- if (UiM.Instance.hallNode) {
- UiM.Instance.hallNode.getComponent(Main).checkTixianPro(true)
- }
- GameM.commonData.checkCanShowSplash()
- //获取当前提现金额
- let tmoney = 0
- for (var i = 0; i < this.cashStatus.length; i++) {
- if (this.cashStatus[i].index == param.index) {
- tmoney = this.cashStatus[i].amount * 0.01
- break
- }
- }
- //更新显示红包币
- GameM.commonData.redMoney -= (tmoney * 10000)
- let paramT = {}
- paramT['totalNumber'] = GameM.commonData.redMoney
- GameM.commonData.resultRedMoney(null, paramT)
- AdM.setTAEventUser(1, 'cashTime_total', 1)
- AdM.setTAEventUser(1, 'cashMoney_total', tmoney)
- AdM.onSendEvent(`cash_${tmoney}`, `第${tmoney}个常规提现成功`, 'cash')
- if (UiM.Instance.cashNode) {
- UiM.Instance.cashNode.getComponent(CashOut).tiXianSuccess(data.CashMode != 2, tmoney)
- }
- GameM.commonData.richbank_noSave = 1
- if (data.CashMode == 2) {
- if (UiM.Instance.cashNode) {
- UiM.Instance.cashNode.getComponent(CashOut).setRedCode(param.index, data.withdrawalCode)
- }
- UiM.Instance.onPanel(PANEL_NAME.OfficialNode, false, () => {
- UiM.Instance.officialNode.getComponent(OfficialNode).init(tmoney, data.withdrawalCode);
- AdM.onSendEvent('publicmoney_1', '公众号提现-常规', 'publicmoney')
- })
- }
- GameM.httpM.sendDatas(HTTP_TYPE.bankCashRecord, null, GameM.commonData.updateBankPacket.bind(GameM.commonData))
- }
- resultCashFail(errmsg) {
- if (errmsg) {
- let tip = ''
- if (errmsg.startsWith('errTip')) {
- tip = GameM.commonData.TxtCft[0][errmsg]
- }
- else {
- tip = errmsg
- }
- EffectNode.instance.PlayTip(tip)
- }
- if (UiM.Instance.cashNode) {
- UiM.Instance.cashNode.getComponent(CashOut).tixianFail()
- }
- }
- /** 获取取现状态 */
- getCashStatus(index: number) {
- let status = 0
- let len = this.cashStatus.length
- for (var i = 0; i < len; i++) {
- if (this.cashStatus[i].index == index) {
- status = this.cashStatus[i].status
- break
- }
- }
- return status
- }
- /** 获取提现状态对象 */
- getCashStatusByIndex(index: number) {
- let obj = null
- let len = this.cashStatus.length
- for (var i = 0; i < len; i++) {
- if (this.cashStatus[i].index == index) {
- obj = this.cashStatus[i]
- break
- }
- }
- return obj
- }
- /** 获取提现配置 */
- getCashByIndex(index) {
- for (var i = 0; i < this.cashCft.length; i++) {
- if (index == this.cashCft[i].index) {
- return this.cashCft[i]
- }
- }
- return null
- }
- curCfg = null
- /** 检查是否杀死boss */
- checkDefeatBoss(cfg) {
- this.curCfg = cfg
- let data = {
- bossCode: this.curCfg.type_value
- }
- GameM.httpM.sendDatas(HTTP_TYPE.checkDefeatBoss, data, CashOutData.Instance.checkDefeatBossBack.bind(this))
- }
- checkDefeatBossBack(data) {
- LogUtil.logV('checkDefeatBossBack ', data)
- let cfg = this.getCashByIndex(this.curCfg.index)
- if (data.result == 1) {
- UiM.Instance.cashNode.getComponent(CashOut).onTixian(cfg)
- }
- else {
- let monsterName = GameM.commonData.fightRoleCfg[this.curCfg.type_value.toString()].name;
- EffectNode.instance.PlayTip(`降服“${monsterName}”后才可提现`)
- UiM.Instance.cashNode.getComponent(CashOut).showHand()
- }
- }
- /** 点击怪物返回
- * @param cfg 怪物配置
- * @returns true 可提现 false 不可提现
- */
- checkShowTip(cfg) {
- let canCash = false
- if (GameM.commonData.maxCarLevel < cfg.type_value) {
- // let monsterName = GameM.commonData.fightRoleCfg[cfg.type_value.toString()].name;
- EffectNode.instance.PlayTip(`合成${cfg.type_value}级武将才可提现`)
- // UiM.Instance.cashNode.getComponent(CashOut).showHand()
- canCash = false
- }
- else {
- //是否已提现
- let hasCashed = false
- for (var i = 0; i < this.cashStatus.length; i++) {
- if (this.cashStatus[i].index == cfg.index) {
- hasCashed = true
- break
- }
- }
- if (hasCashed) {
- EffectNode.instance.PlayTip(`已提现`)
- canCash = false
- }
- else {
- canCash = true
- }
- }
- return canCash
- }
- }
|