import AdM from "../manager/AdM"; import GameM, { AUDIO_TYPE } from "../manager/GameM"; import UiM, { PANEL_NAME } from "../manager/UiM"; import { Utils } from "../utils/Utils"; import CashOut from "./CashOut"; /** 公众号提现 * @author kaka * @date 2020-12-11 */ const { ccclass, property } = cc._decorator; @ccclass export default class OfficialNode extends cc.Component { @property(cc.Label) labOfficial: cc.Label = null; @property(cc.Label) labRed: cc.Label = null; @property(cc.Label) labMoney: cc.Label = null; @property(cc.Label) labRedCode: cc.Label = null; @property(cc.Node) parNode: cc.Node = null; videoNode = null officialStr = "白羊游戏社" redCodeStr = "领红包" code = "" coolTime = false start() { this.coolTime = false this.labOfficial.string = `“${this.officialStr}”` this.labRed.string = `“${this.redCodeStr}”` } init(money, code) { this.labMoney.string = `${money.toFixed(2)}元` this.code = code this.labRedCode.string = `提现红包码:${this.code}` } /** 点击复制公众号 */ clickCopyOfficial() { GameM.audioM.playEffect(AUDIO_TYPE.button) AdM.setClipboard(this.officialStr) } /** 点击教程 */ async clickTeach() { GameM.audioM.playEffect(AUDIO_TYPE.button) if (this.coolTime) { return } this.coolTime = true GameM.commonData.teachVideoType = 1; console.log('clickTeach') let temp = await Utils.loadResPromise('prefabs/VideoNode') this.videoNode = cc.instantiate(temp) this.videoNode.getChildByName('video').on("completed", this.onCompleted, this) this.node.addChild(this.videoNode) } onCompleted() { this.videoNode.getChildByName('video').off("completed", this.onCompleted, this) this.videoNode.destroy() GameM.audioM.setResumeMusic() GameM.audioM.setTempEffect(true) this.coolTime = false } /** 点击复制红包码 */ clickCopyRedCode() { GameM.audioM.playEffect(AUDIO_TYPE.button) AdM.setClipboard(this.code) } /** 点击关闭 */ clickClose() { GameM.audioM.setResumeMusic() GameM.audioM.setTempEffect(true) GameM.audioM.playEffect(AUDIO_TYPE.button) this.hideEff() } hideEff() { if (UiM.Instance.cashNode) { let pos = UiM.Instance.cashNode.getComponent(CashOut).labRedCode.position let addy = (cc.winSize.height - 1334) / 2 pos.y += addy cc.tween(this.parNode).to(0.2, { scale: 0, position: pos }).call(() => { UiM.Instance.offPanel(PANEL_NAME.OfficialNode) }).start(); } else { UiM.Instance.offPanel(PANEL_NAME.OfficialNode) } } }