| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- import { _decorator, AudioSource, Component, director, game, Node, Scheduler, Toggle } from 'cc';
- import { GameUILayers, gui, ui_base } from 'db://assets/core/ui/ui';
- import { ModuleDef } from 'db://assets/Script/ModuleDef';
- import { Layout_Settings } from './Layout_Settings';
- import { UI_Main } from '../main/UI_Main';
- import { ani_ui } from '../../game/animation_utils';
- import { Hall } from '../../hall/Hall';
- import { audioManager } from '../../Audio/AudioManager';
- const { ccclass, property } = _decorator;
- @ccclass('UI_Settings')
- export class UI_Settings extends ui_base {
- constructor() {
- super(ModuleDef.GAME, 'ui/UI_Settings/setDlg', GameUILayers.HUD, Layout_Settings);
- }
- protected onCreated() {
- ani_ui(this.node);
- const layout = this.getLayout<Layout_Settings>();
- this.onButtonEvent(layout.returnBtn, async () => {
- audioManager.playOneShot('sound/click_Btn')
- if (gui.get(UI_Main)) {
- gui.get(UI_Main).evt.emit(gui.get(UI_Main).evt.key.resume);
- }
- await gui.closeAll();
- Hall.getInstance().to_hall()
- console.log('大厅界面')
- });
- this.onButtonEvent(layout.shareBtn, () => {
- audioManager.playOneShot('sound/click_Btn')
- //TODO
- chsdk.shareAppMessage();
- });
- this.onButtonEvent(layout.closeBtn, () => {
- audioManager.playOneShot('sound/click_Btn')
- if (gui.get(UI_Main)) {
- gui.get(UI_Main).evt.emit(gui.get(UI_Main).evt.key.resume);
- }
- this.close()
- })
- }
- get_Count() {
- const layout = this.getLayout<Layout_Settings>();
- chsdk.getShareList().then((res) => {
- if (res.code === 0 && res.data) {
- // 确保数据有效
- const friendCount = res.data.length; // 计算人数
- // layout.Txt.string = friendCount + '/' + layout.target_count;
- // layout.progressBar.progress = friendCount / layout.target_count;
- // let remain= layout.target_count - friendCount;
- // layout.Num_Sp.spriteFrame=layout.Num[remain-1];
- } else {
- // 错误处理
- console.error(`获取分享列表失败: ${res.err || "未知错误"}`);
- }
- }).catch((err) => {
- // 捕获 promise 的异常
- console.error(`请求失败: ${err.message}`);
- });
- }
- }
|