123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- import GameItem from "./GameItem";
- import QCrossWidgetItem from "./QCrossWidgetItem";
- import { utils } from "./Utils";
- import { BannerLocation, SubLocation } from "./YZ_Constant";
- import PlatUtils from "./PlatUtils";
- import CompatibleTool from "./CompatibleTool";
- import { YzRedBagInfo } from "./CommonConfig";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class WithdrawalPanel extends cc.Component {
- private _closeBtn: cc.Node = null;
- private _withdrawalBtn: cc.Node = null;
- private _moneyItemNodes: cc.Node[] = null;
- private _panel: cc.Node = null;
- private _balanceLbl: cc.Label = null;
- private _redBagInfo: YzRedBagInfo = null;
- _location: SubLocation = SubLocation.isMoreGame;
- onLoad() {
- if (utils.otherConfig && utils.otherConfig.group) {
- this.node.group = utils.otherConfig.group;
- }
- this._panel = this.node.getChildByName("Panel");
- this._moneyItemNodes = this._panel.getChildByName("WithdrawalPriceNodes").children;
- this._balanceLbl = this._panel.getChildByName("balanceLabel").getComponent(cc.Label);
- // this.node.active = false;
- this._redBagInfo = utils.yzRedBagInfo;
- let ratio: number = 1;
- if (cc.winSize.height < cc.winSize.width) {
- // 横屏游戏
- ratio = cc.winSize.width / 1920 * 0.5;
- } else {
- ratio = cc.winSize.width / 1080;
- }
- this._panel.scale = ratio;
- this._initWidget();
- }
- private _initWidget() {
- if (this._redBagInfo.balance > 0) {
- this._balanceLbl.string = `${this._redBagInfo.balance}元`
- }
- for (let i = 0; i < 4; i++) {
- let data: any = utils.yzRedBagInfo.withdrawaMoneys[i];
- if (data) {
- this._moneyItemNodes[i].getChildByName("PriceLbl").getComponent(cc.Label).string = `${data}元`
- this._moneyItemNodes[i].on(cc.Node.EventType.TOUCH_START, () => {
- this.selectedMoneyNode(i)
- }, this);
- }
- }
- }
- _selectedMoneyItemIndex: number = -1;
- selectedMoneyNode(itemIndex) {
- if (this._redBagInfo.balance >= utils.yzRedBagInfo.withdrawaMoneys[itemIndex]) {
- this._selectedMoneyItemIndex = itemIndex;
- this._moneyItemNodes.forEach((element, index) => {
- if (itemIndex != index) {
- this._moneyItemNodes[index].getChildByName("selectedBg").active = false;
- }
- });
- this._moneyItemNodes[itemIndex].getChildByName("selectedBg").active = true;
- } else {
- utils.showMsg("当前余额不足!");
- }
- }
- withDrawalMoney() {
- console.log("money");
- if (this._selectedMoneyItemIndex > -1) {
- } else {
- utils.showMsg("请选择要提现的金额!");
- }
- }
- // update() {
- // if (this._dataDirty) {
- // this._dataDirty = false;
- // this._updatePanel();
- // }
- // }
- _updatePanel() {
- utils.postRecommentShowData(this._location);
- this._initWidget();
- return;
- }
- public init(YzRedBagInfo: YzRedBagInfo) {
- }
- public show() {
- this.node.active = true;
- }
- public hide() {
- let self = this;
- // this._panel.runAction(cc.sequence(cc.moveTo(0.3, CompatibleTool.position(-this._panel.getContentSize().width, 0)).easing(cc.easeQuadraticActionOut()), cc.callFunc(() => {
- self.node.active = false;
- // })));
- // if (!PlatUtils.IsNativeAndroid) {
- // utils.adManager.ShowBanner(BannerLocation.Home);
- // }
- }
- public onCloseBtnHandler(event: any, data: any) {
- this.hide();
- }
- }
|