| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- const { ccclass, property } = cc._decorator;
- import JsbSystem from '../../mk/system/JsbSystem';
- import { OpenActionType } from '../../mk/system/UISystem';
- /**
- * 打开指定名字的面板
- * @author 薛鸿潇
- */
- @ccclass
- export default class BtnOpenPanel extends cc.Component {
- @property({ displayName: '预制体路径', tooltip: '对应路径:resources/' })
- private panel_name = '';
- @property({ displayName: '是否需要微信授权', tooltip: '授权勾选' })
- private bool_Auth: boolean = false;
- @property({ displayName: '打开类型', tooltip: 'normal不操作,closeOther关闭其他,closeLast关闭上一个', type: cc.Enum(OpenActionType) })
- private open_type = OpenActionType.normal;
- @property({ displayName: '点击效果', tooltip: "仅支持 NONE 和 SCALE", type: cc.Enum(cc.Button.Transition) })
- public transition_type: cc.Button.Transition = cc.Button.Transition.NONE;
- @property({ displayName: '完成回调', tooltip: "面板打开完成后触发", type: cc.Component.EventHandler })
- public onComplete: cc.Component.EventHandler[] = [];
- onLoad() {
- if (!this.node.getComponent(cc.Button)) {
- let btn_comp = this.node.addComponent(cc.Button);
- btn_comp.transition = this.transition_type;
- }
- }
- start() {
- this.node.on('click', this.openPanel, this);
- }
- private async openPanel() {
- if (!mk.game.checkContinuousClick(this.node)) {
- return;
- }
- mk.audio.playEffect("button");
- if (this.bool_Auth) {
- if (!gData.loginData.isAuth) {
- JsbSystem.WxAuth();
- return;
- }
- }
- if (!this.panel_name) return;
- await mk.ui.openPanel(this.panel_name, this.open_type);
- const c_count = this.onComplete.length;
- for (let i = 0; i < c_count; i++) {
- if (this.onComplete[i].handler) this.onComplete[i].emit([])
- }
- mk.console.log('open->' + this.panel_name)
- }
- // update (dt) {}
- }
|