a189260d-2ae1-4d3c-84c0-e82878c15294.js 6.04 KB
"use strict";
cc._RF.push(module, 'a1892YNKuFNPITA6Ch4wVKU', 'ShareSuitViewPresenter');
// script/game/ui/presenter/bedroom/ShareSuitViewPresenter.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 simba_cc_resutils_1 = require("simba-cc-resutils");
const CCWechatScreenShotMgr_1 = require("../../../../common/CCWechatScreenShotMgr");
const PresenterBase_1 = require("../../../../common/classbase/PresenterBase");
const UIManager_1 = require("../../../../common/gameplay/managers/UIManager");
const PresenterCCViewFactory_1 = require("../../PresenterCCViewFactory");
const ShareSuitView_1 = require("../../view/type/ShareSuitView");
let ShareSuitViewPresenter = /** @class */ (() => {
    let ShareSuitViewPresenter = class ShareSuitViewPresenter extends PresenterBase_1.Presenter {
        constructor() {
            super();
            this._onShow = false;
            this.onCloseBtnClickCallback = () => {
                this.view.close();
                this._onShow = false;
            };
        }
        onOpen(props) {
            super.onOpen(props);
            this._viewProps = props;
            this._viewProps.bgSpritePath = props.bgSpritePath;
            this._viewProps.rolePortraitSpritePath = props.rolePortraitSpritePath;
            this._viewProps.onCloseBtnClickCallback = this.onCloseBtnClickCallback;
            this.view.setProps(this._viewProps);
            this.onShow();
        }
        onShow() {
            super.onShow();
            this.showShareSuitRolePortrait();
        }
        onClose() {
            super.onClose();
        }
        onEnterBackground() {
            super.onEnterBackground();
        }
        onEnterForeground() {
            super.onEnterForeground();
        }
        async showShareSuitRolePortrait() {
            this._onShow = true;
            this.view.getShareSuitViewBgSprite().spriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(this._viewProps.bgSpritePath, cc.SpriteFrame);
            this.view.getShareSuitViewRolePortraitSprite().spriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(this._viewProps.rolePortraitSpritePath, cc.SpriteFrame);
            let shareNode = this.view.getShareNode();
            let shareNodeWorldSpace = shareNode.convertToWorldSpaceAR(cc.v2(0, 0));
            CCWechatScreenShotMgr_1.default.getInstance().doShot(shareNodeWorldSpace, shareNode.width, shareNode.height, () => {
                // 延迟2s退出
                cc.tween(this.view.getViewNode()).delay(2).call(() => {
                    this.onCloseBtnClickCallback();
                    this._viewProps.shareSuitViewCallback(true);
                    console.log('ShowShareSuitRolePortrait successCallback');
                }).start();
            }, () => {
                console.log('ShowShareSuitRolePortrait successCheckCallback: ', this._onShow);
                return this._onShow;
            }, () => {
                console.log('ShowShareSuitRolePortrait shareFailCallback');
                this._viewProps.shareSuitViewCallback(false);
                UIManager_1.UIManager.showSceneToast("自动截图失败,请升级微信哦~");
                this.onCloseBtnClickCallback();
            }, () => {
                console.log('ShowShareSuitRolePortrait failCallback');
                this._viewProps.shareSuitViewCallback(false);
                UIManager_1.UIManager.showSceneToast("自动截图失败,请稍后重试哦~");
                this.onCloseBtnClickCallback();
            }, () => {
                console.log('ShowShareSuitRolePortrait completeCallback');
            });
            // CCWechatScreenShotMgr.getInstance().shotFullScreen(
            //     () => { // successCallback
            //         // 延迟2s退出
            //         cc.tween(this.view.getViewNode()).delay(2).call(() => {
            //             this.onCloseBtnClickCallback();
            //             this._viewProps.shareSuitViewCallback(true);
            //             console.log('ShowShareSuitRolePortrait successCallback');
            //         }).start();
            //     },
            //     (): boolean => { // successCheckCallback
            //         console.log('ShowShareSuitRolePortrait successCheckCallback: ', this._onShow);
            //         return this._onShow;
            //     },
            //     () => { // shareFailCallback
            //         console.log('ShowShareSuitRolePortrait shareFailCallback');
            //         this._viewProps.shareSuitViewCallback(false);
            //         UIManager.showSceneToast("自动截图失败,请升级微信哦~");
            //         this.onCloseBtnClickCallback();
            //     },
            //     () => { // failCallback
            //         console.log('ShowShareSuitRolePortrait failCallback');
            //         this._viewProps.shareSuitViewCallback(false);
            //         UIManager.showSceneToast("自动截图失败,请稍后重试哦~");
            //         this.onCloseBtnClickCallback();
            //     },
            //     () => { // completeCallback
            //         console.log('ShowShareSuitRolePortrait completeCallback');
            //     }
            // );
        }
    };
    ShareSuitViewPresenter.uuid = "ShareSuitViewPresenter";
    ShareSuitViewPresenter = __decorate([
        PresenterCCViewFactory_1.RegPresenter(ShareSuitView_1.ShareSuitViewType)
    ], ShareSuitViewPresenter);
    return ShareSuitViewPresenter;
})();
exports.default = ShareSuitViewPresenter;

cc._RF.pop();