8e3fdf4e-e6f4-4839-8ab2-51c65d7a5a4b.js 9.94 KB
"use strict";
cc._RF.push(module, '8e3fd9O5vRIOYqyUcZdelpL', 'AlertDialogViewImpl');
// script/game/ui/view/impl/AlertDialogViewImpl.ts

"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
const PresenterCCViewFactory_1 = require("../../PresenterCCViewFactory");
const AlertDialogView_1 = require("../type/AlertDialogView");
const CCViewBase_1 = require("../../../../common/classbase/CCViewBase");
const CCDummyObjects_1 = require("../../../../common/CCDummyObjects");
const simba_sdk_ccsvbutton_1 = require("simba-sdk-ccsvbutton");
const GameDotMgr_1 = require("../../../GameDotMgr");
const simba_sdk_1 = require("simba-sdk");
const GameConstData_1 = require("../../../../common/gameplay/gamedata/GameConstData");
const GameEnumData_1 = require("../../../../common/gameplay/gamedata/GameEnumData");
const GameConfig_1 = require("../../../../GameConfig");
const UIManager_1 = require("../../../../common/gameplay/managers/UIManager");
const GameModelManager_1 = require("../../../model/GameModelManager");
const { ccclass, property } = cc._decorator;
let AlertDialogViewImpl = /** @class */ (() => {
    let AlertDialogViewImpl = class AlertDialogViewImpl extends CCViewBase_1.CCPureView {
        constructor() {
            super(...arguments);
            //#region 
            this.titlelabel = CCDummyObjects_1.DummyLabel;
            this.content = CCDummyObjects_1.DummyRichText;
            this.twobtnmode = CCDummyObjects_1.DummyNode;
            this.okbtn = CCDummyObjects_1.DummyButton;
            this.adokbtn = CCDummyObjects_1.DummyButton;
            this.adsvbtn = undefined;
            this.onebtnmode = CCDummyObjects_1.DummyNode;
            this.opacityBtn = CCDummyObjects_1.DummyNode;
            this.banner = CCDummyObjects_1.DummyNode;
            this.cancelNode = CCDummyObjects_1.DummyNode;
            this.cancelNode2 = CCDummyObjects_1.DummyNode;
            this.cancelNode3 = CCDummyObjects_1.DummyNode;
            this.shopNode = CCDummyObjects_1.DummyNode;
            this.shareScreenNode = CCDummyObjects_1.DummyNode;
            this.svType = GameEnumData_1.GetRewardType.Ad;
            this.getSvBtnType = () => {
                let ret = "";
                if (this.adsvbtn.svPoint) {
                    ret = this.adsvbtn.svPoint.type;
                }
                return ret;
            };
            this.showView = (props) => {
                this.opacityBtn.active = false;
                this.switchAdConfig(props);
                if (!props.hasBanner) {
                    simba_sdk_1.SDK.hideBannerAd();
                    return;
                }
                let info = simba_sdk_1.SDK.systemInfo.displayInfo;
                let aspect = info.windowSize.height / cc.view.getVisibleSize().height;
                this.node.getComponent(cc.Widget).updateAlignment();
                let _width = this.banner.width * aspect;
                let _height = this.banner.height * aspect;
                let _left = (info.windowSize.width - _width) * 0.5;
                let _top = info.windowSize.height - _height;
                let style = {
                    left: _left,
                    top: _top,
                    width: _width,
                    height: _height,
                    anchorX: 0.5,
                    anchorY: 1,
                };
                simba_sdk_1.SDK.showBannerAd(style, GameConstData_1.GameConstData.GAME_CONST_BANNER_REFRESH_TIME);
            };
        }
        onLoad() {
            this.adsvbtn.loadSVConfig();
            this.bindProp("titlecontent", (value) => {
                this.titlelabel.string = value;
            });
            this.bindProp("content", (value) => {
                this.content.string = value;
            });
            this.bindProp("ishasad", (value) => {
                if (this._props.istwobtn) {
                    this.adokbtn.node.active = value;
                    this.okbtn.node.active = !value;
                    this.adsvbtn.enabled = true;
                }
            });
            this.bindProp("istwobtn", (value) => {
                this.twobtnmode.active = value;
                let hasad = this._props.ishasad;
                this.adokbtn.node.active = hasad;
                this.okbtn.node.active = !hasad;
                this.onebtnmode.active = !value;
            });
            this.bindProp("adconfig", (value) => {
                this.adsvbtn.enabled = (value !== "");
                if (value !== "") {
                    this.adsvbtn.sharePointId = value;
                    this.adsvbtn.loadSVConfig();
                }
            });
            this.bindProp("isthreebtn", (value) => {
                let three = value ? true : false;
                this.shopNode.active = three;
                this.cancelNode2.active = three;
                this.cancelNode.active = !three;
            });
            this.bindProp("isadlimit", (value) => {
                let isadlimit = value ? true : false;
                this.shopNode.active = isadlimit;
                this.cancelNode3.active = isadlimit;
                this.adokbtn.node.active = !isadlimit;
            });
            this.bindProp("isShareScreen", (value) => {
                let isShareScreen = value ? true : false;
                this.shareScreenNode.active = isShareScreen;
                this.adokbtn.node.active = !isShareScreen;
            });
            this.adsvbtn.onResult = ((type, ret) => {
                this._props.callback(type, ret, this._props.dataptr);
                this.closeView();
            });
            this.adsvbtn.onConfigLoaded = (svPoint) => {
                if (svPoint.type === "share") {
                    this.svType = GameEnumData_1.GetRewardType.Share;
                }
                else {
                    this.svType = GameEnumData_1.GetRewardType.Ad;
                }
            };
        }
        onOkClickCallback(event) {
            this._props.callback("", true, this._props.dataptr);
            this.closeView();
        }
        onCancleClickCallback(event) {
            this._props.callback("", false, this._props.dataptr);
            this.closeView();
        }
        onGoToShopClickCallback(event) {
            this._props.callback("", false, this._props.dataptr);
            GameDotMgr_1.default.getInstance().dotClickUI("shop_btn_AlertDialogView");
            if (GameConfig_1.channel == "wechat") {
                // GameCenter.getInstance().openSubProgram(GameConfig.youZanShopAppId);
                let link = GameModelManager_1.GameModelManager.getYouZanShopUrlByType(2);
                if (link) {
                    simba_sdk_1.SDK.openProgramV2(GameConfig_1.GameConfig.youZanShopAppId, link);
                }
            }
            else if (GameConfig_1.channel == "android") {
                let link = GameModelManager_1.GameModelManager.getTaoBaoShopUrlByType(2);
                if (link) {
                    GameModelManager_1.GameModelManager.jumpToTaobaoShop(link);
                }
            }
            else {
                UIManager_1.UIManager.showToast("该功能在当前平台不可使用");
            }
        }
        onShareScreenClickCallback(event) {
        }
        onADBtnClick() {
            this.opacityBtn.active = true;
        }
        closeView() {
            simba_sdk_1.SDK.hideBannerAd();
            this.close();
            this.opacityBtn.active = false;
        }
        switchAdConfig(props) {
            if (props.istwobtn) { //两个按钮的
                if (props.adconfig && "" !== props.adconfig.trim()) {
                    this.adsvbtn.sharePointId = props.adconfig;
                    this.adsvbtn.loadSVConfig();
                }
            }
        }
    };
    __decorate([
        property(cc.Label)
    ], AlertDialogViewImpl.prototype, "titlelabel", void 0);
    __decorate([
        property(cc.RichText)
    ], AlertDialogViewImpl.prototype, "content", void 0);
    __decorate([
        property(cc.Node)
    ], AlertDialogViewImpl.prototype, "twobtnmode", void 0);
    __decorate([
        property(cc.Button)
    ], AlertDialogViewImpl.prototype, "okbtn", void 0);
    __decorate([
        property(cc.Button)
    ], AlertDialogViewImpl.prototype, "adokbtn", void 0);
    __decorate([
        property(simba_sdk_ccsvbutton_1.default)
    ], AlertDialogViewImpl.prototype, "adsvbtn", void 0);
    __decorate([
        property(cc.Node)
    ], AlertDialogViewImpl.prototype, "onebtnmode", void 0);
    __decorate([
        property(cc.Node)
    ], AlertDialogViewImpl.prototype, "opacityBtn", void 0);
    __decorate([
        property(cc.Node)
    ], AlertDialogViewImpl.prototype, "banner", void 0);
    __decorate([
        property(cc.Node)
    ], AlertDialogViewImpl.prototype, "cancelNode", void 0);
    __decorate([
        property(cc.Node)
    ], AlertDialogViewImpl.prototype, "cancelNode2", void 0);
    __decorate([
        property(cc.Node)
    ], AlertDialogViewImpl.prototype, "cancelNode3", void 0);
    __decorate([
        property(cc.Node)
    ], AlertDialogViewImpl.prototype, "shopNode", void 0);
    __decorate([
        property(cc.Node)
    ], AlertDialogViewImpl.prototype, "shareScreenNode", void 0);
    AlertDialogViewImpl = __decorate([
        ccclass,
        PresenterCCViewFactory_1.RegView(AlertDialogView_1.AlertDialogViewType, "prefab/ui/AlertDialogView")
    ], AlertDialogViewImpl);
    return AlertDialogViewImpl;
})();
exports.default = AlertDialogViewImpl;

cc._RF.pop();