| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- import { HTTP_TYPE } from "../datas/CommonData";
- import { MateData } from "../datas/MateData";
- import { RichData } from "../datas/RichData";
- import Main from "../Main";
- import AdM from "../manager/AdM";
- import { GameController } from "../manager/GameController";
- import GameM, { AUDIO_TYPE } from "../manager/GameM";
- import HttpM from "../manager/HttpM";
- import UiM, { PANEL_NAME } from "../manager/UiM";
- import BasePanel from "../uiFrames/BasePanel";
- import Sciencen_M from "../utils/Sciencen_M";
- import { Utils } from "../utils/Utils";
- import EffectNode from "./EffectNode";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class RichHelpPanel extends cc.Component {
- @property(cc.Label)
- txtTitle: cc.Label = null;
- @property(cc.Label)
- txtGiftName: cc.Label = null;
- @property(cc.Node)
- rds: cc.Node[] = [];
- @property(cc.Sprite)
- rd_imgs: cc.Sprite[] = [];
- @property(cc.Label)
- rd_txts: cc.Label[] = [];
- @property(cc.EditBox)
- inputBox: cc.EditBox = null;
- @property(cc.Node)
- suc_node: cc.Node = null;
- @property(cc.Node)
- suc_node_panel: cc.Node = null;
- @property(cc.Node)
- suc_rds: cc.Node[] = [];
- @property(cc.Sprite)
- suc_rd_imgs: cc.Sprite[] = [];
- @property(cc.Label)
- suc_rd_txts: cc.Label[] = [];
- videoNode = null;
- isInited: boolean = false;
- rewardData: any = null;
- onEnable() {
- if (!this.isInited) {
- this.isInited = true;
- this.InitData();
- }
- }
- InitData() {
- let data = GameM.commonData.redeemData.redemption;
- this.txtTitle.string = data.title;
- this.txtGiftName.string = data.title;
- this.rewardData = data.content;
- for (let n of this.rds) {
- n.active = false;
- }
- for (let m of this.suc_rds) {
- m.active = false;
- }
- for (let i = 0; i < this.rewardData.length; i++) {
- this.rds[i].active = true;
- this.suc_rds[i].active = true;
- cc.loader.loadRes("xiyou/icon/reward" + this.rewardData[i].type, cc.SpriteFrame, (err, res) => {
- if (err) { console.log("img load err:" + JSON.stringify(err)); }
- this.rd_imgs[i].spriteFrame = res;
- this.suc_rd_imgs[i].spriteFrame = res;
- });
- if (this.rewardData[i].type == "10001") {
- this.rd_txts[i].string = Sciencen_M.instance.format(this.rewardData[i].count) + "分钟";
- this.suc_rd_txts[i].string = Sciencen_M.instance.format(this.rewardData[i].count) + "分钟";
- } else {
- this.rd_txts[i].string = Sciencen_M.instance.format(this.rewardData[i].count);
- this.suc_rd_txts[i].string = Sciencen_M.instance.format(this.rewardData[i].count);
- }
- }
- }
- Click_RedeemBtn() {
- console.log("---RedeemCode: " + this.inputBox.string);
- if (this.inputBox.string != "") {
- HttpM.Instance.SendData(HTTP_TYPE.redeemExchange, { code: this.inputBox.string }, (res) => {
- console.log("--->RedeemCode GetGift:", res);
- if (res.data != null) {
- if (res.data.code == 1) {
- console.log("兑换成功");
- this.suc_node_panel.scale = 0;
- this.suc_node.active = true;
- cc.tween(this.suc_node_panel).to(0.2, { scale: 1 }, { easing: "backOut" }).start();
- } else {
- EffectNode.instance.PlayTip(res.data.msg);
- }
- }
- })
- } else {
- EffectNode.instance.PlayTip("请输入兑换码");
- }
- }
- coolTime = false
- /** 点击教程 */
- async Click_TeachBtn() {
- GameM.audioM.playEffect(AUDIO_TYPE.button)
- if (this.coolTime) {
- return
- }
- this.coolTime = true
- console.log('clickTeach')
- GameM.commonData.teachVideoType = 2;
- 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.setTempEffect(true)
- GameController.Ins.SwitchAudio(1)
- //GameM.audioM.setResumeMusic()
- this.coolTime = false
- }
- /** 点击复制公众号 */
- clickCopyOfficial() {
- GameM.audioM.playEffect(AUDIO_TYPE.button)
- AdM.setClipboard("白羊游戏社")
- }
- /** 点击复制礼包名 */
- clickCopyInfo() {
- GameM.audioM.playEffect(AUDIO_TYPE.button)
- AdM.setClipboard(this.txtTitle.string)
- }
- Click_CloseBtn() {
- UiM.Instance.offPanel(PANEL_NAME.RedeemNode);
- //let classnew: any = cc.js.getClassByName("CashOut");
- //console.log("-->: " + classnew);
- }
- Click_GetBtn() {
- this.suc_node.active = false;
- let richDice: any = null;
- for (let i = 0; i < this.rewardData.length; i++) {
- if (this.rewardData[i].type == "10001") {
- let coinNum = Sciencen_M.instance.accMul(GameM.commonData.goldSecond.toString(), (Number(this.rewardData[i].count) * 60).toString());
- GameM.commonData.updateGold(coinNum);
- GameM.audioM.playEffect(AUDIO_TYPE.getGold, false);
- EffectNode.instance.PlayCoinAnim(0, 5, cc.v2(0, -300));
- } else if (this.rewardData[i].type == "10002") {
- GameM.commonData.updateRedMoney(Number(this.rewardData[i].count))
- EffectNode.instance.PlayCoinAnim(1, 5, cc.v2(0, -300));
- } else if (this.rewardData[i].type == "20002") {
- GameM.commonData.roleData.turntableCard += Number(this.rewardData[i].count);
- EffectNode.instance.PlayCoinAnim(11, 5, cc.v2(0, -300));
- } else if (this.rewardData[i].type == "20001") {
- GameM.commonData.roleData.speedCard += Number(this.rewardData[i].count);
- EffectNode.instance.PlayCoinAnim(10, 5, cc.v2(0, -300));
- } else if (this.rewardData[i].type == "20003") {
- GameM.commonData.roleData.ticket += Number(this.rewardData[i].count);
- EffectNode.instance.PlayCoinAnim(12, 5, cc.v2(0, -300));
- } else if (this.rewardData[i].type == "20006") {
- MateData.Ins.talentCoin += Number(this.rewardData[i].count)
- GameM.httpM.SendData(HTTP_TYPE.updateBattleStoneCount, { "count": MateData.Ins.talentCoin })
- EffectNode.instance.PlayCoinAnim(13, 5, cc.v2(0, -300));
- } else if (this.rewardData[i].type == "30001") {
- if (richDice == null) richDice = {};
- richDice.diceAdNum = Number(this.rewardData[i].count);
- EffectNode.instance.PlayCoinAnim(6, 5, cc.v2(0, -300));
- } else if (this.rewardData[i].type == "30002") {
- if (richDice == null) richDice = {};
- richDice.remoteCtrlNum = Number(this.rewardData[i].count);
- EffectNode.instance.PlayCoinAnim(7, 5, cc.v2(0, -300));
- } else if (this.rewardData[i].type == "30004") {
- if (richDice == null) richDice = {};
- richDice.scriptureNum = Number(this.rewardData[i].count);
- EffectNode.instance.PlayCoinAnim(9, 5, cc.v2(0, -300));
- } else if (this.rewardData[i].type == "30005") {
- if (richDice == null) richDice = {};
- richDice.doubleNum = Number(this.rewardData[i].count);
- EffectNode.instance.PlayCoinAnim(8, 5, cc.v2(0, -300));
- }
- }
- if (richDice != null) {
- //进入取经战斗 前提就是满足奖励条件下
- RichData.Ins.UpdateItemCard2(richDice, null, false);
- }
- HttpM.Instance.SendData(HTTP_TYPE.redeemGetRedemption, {}, (res) => {
- console.log("--->RedeemGift RedeemPanel:", res);
- if (res.data != null && res.errcode == 0) {
- GameM.commonData.redeemData = res.data;
- UiM.Instance.hallNode.getComponent(Main).redeemBtn.active = res.data.code == 1;
- if (res.data.code == 1) {
- this.InitData();
- } else {
- UiM.Instance.offPanel(PANEL_NAME.RedeemNode);
- }
- } else {
- UiM.Instance.offPanel(PANEL_NAME.RedeemNode);
- }
- });
-
- AdM.onSendEvent('duihuan_success', '兑换码-兑换成功', 'duihuan')
- }
- }
|