You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
158 lines
6.1 KiB
158 lines
6.1 KiB
//#region 文件引入
|
|
import { _decorator, Button, Component, Label, Node, sp, Sprite,Animation, RichText, EditBox } from "cc";
|
|
import BaseUIForm from "../../Mgr_UI/BaseUIForm";
|
|
import { Global } from "../../Global";
|
|
import PlatformManager from "../../Platform/PlatformManager";
|
|
import UIMgr from "../../Mgr_UI/UIMgr";
|
|
import Base64 from "../../Mgr_LocalData/Base/Base64";
|
|
import LocalStorage from "../../Mgr_LocalData/LocalStorage";
|
|
import { MainConfig } from "db://assets/Launch/_MainConfig";
|
|
import { EPlatformType } from "../../Platform/T/EPlatformType";
|
|
import { EUIForms } from "../../const/UIFormCnf";
|
|
//#endregion 文件引入
|
|
const {ccclass, property,menu} = _decorator;
|
|
@ccclass("SettingUI_Proxy")
|
|
export default class SettingUI_Proxy extends BaseUIForm{
|
|
//#region 节点自动生成
|
|
@property(Button)
|
|
btn_ClickAudio: Button = null;
|
|
@property(Button)
|
|
btn_ClickMusic: Button = null;
|
|
@property(Button)
|
|
btn_ClickVibrate: Button = null;
|
|
@property(Button)
|
|
btn_Cloud: Button = null;
|
|
@property(Button)
|
|
btn_ClearData: Button = null;
|
|
@property(Button)
|
|
btn_OpenID: Button = null;
|
|
//#endregion 节点自动生成
|
|
@property(EditBox)
|
|
openidEditBox:EditBox;
|
|
|
|
onButtonClick(button:Button){
|
|
/**点击事件触发*/
|
|
switch (button) {
|
|
case this.btn_ClickAudio:
|
|
Global.Audio.switchEffect();
|
|
this.reflashAudioAndMusicAndVibrate();
|
|
break;
|
|
case this.btn_ClickMusic:
|
|
Global.Audio.switchMusic();
|
|
this.reflashAudioAndMusicAndVibrate();
|
|
break;
|
|
case this.btn_ClickVibrate:
|
|
Global.Vibrate.switchVibration();
|
|
this.reflashAudioAndMusicAndVibrate()
|
|
case this.btn_ClearData:
|
|
break;
|
|
case this.btn_Cloud:
|
|
if(LocalStorage.getCloudDiffTime() > 10000){
|
|
LocalStorage.CheckSaveServerData((flag)=>{
|
|
flag && UIMgr.Ins.ShowTipsUI("存档上传成功!");
|
|
});
|
|
}else{
|
|
UIMgr.Ins.ShowTipsUI("请不要频繁存档,10秒后再试!");
|
|
}
|
|
break;
|
|
case this.btn_OpenID:
|
|
this.setClipboardData(()=>{
|
|
this.openidEditBox.node.getComponent(Sprite).enabled = true;
|
|
this.openidEditBox.enabled = true;
|
|
});
|
|
break;
|
|
default:
|
|
ConsoleEx.Log(button);
|
|
break;
|
|
}
|
|
}
|
|
|
|
reflashAudioAndMusicAndVibrate(){
|
|
this.setButtonInfo(this.btn_ClickAudio,Global.Audio.Effect);
|
|
this.setButtonInfo(this.btn_ClickMusic,Global.Audio.Music);
|
|
this.setButtonInfo(this.btn_ClickVibrate,Global.Vibrate.vibration);
|
|
}
|
|
|
|
setButtonInfo(btn: Button, isOpen: boolean) {
|
|
const onNode = btn.node.getChildByName("on");
|
|
const offNode = btn.node.getChildByName("off");
|
|
const switchboard = btn.node.getChildByName("switchboard");
|
|
CNodeUtils.setActive(onNode, isOpen)
|
|
CNodeUtils.setActive(switchboard, isOpen)
|
|
CNodeUtils.setActive(offNode, !isOpen)
|
|
}
|
|
|
|
protected start(): void {
|
|
this.reflashAudioAndMusicAndVibrate();
|
|
|
|
let loginState = PlatformManager.PlatformInstance.loginState;
|
|
if (!loginState.uid && !!loginState.openid) {
|
|
loginState.uid = Base64.encode(`${loginState.openid}_10086`)
|
|
}
|
|
this.openidEditBox.string = (loginState.uid || "")
|
|
MainConfig.isGmOpen = PlatformManager.PlatformInstance.platform == EPlatformType.Web || Global.CsvMgr.CheckWlist(loginState.uid);
|
|
}
|
|
|
|
openGM(){
|
|
if(MainConfig.isGmOpen){
|
|
UIMgr.Ins.ShowUI(EUIForms.DebugUI)
|
|
this.CloseUI()
|
|
}
|
|
}
|
|
|
|
setClipboardData(callBack:Function) {
|
|
let loginState = PlatformManager.PlatformInstance.loginState;
|
|
if (window["tt"]) {
|
|
window["tt"].setClipboardData({
|
|
data: loginState.uid,
|
|
success: (res) => {
|
|
UIMgr.Ins.ShowTipsUI("复制成功")
|
|
},
|
|
fail(res) {
|
|
callBack && callBack();
|
|
console.log("复制失败", res)
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
if (window["wx"]) {
|
|
window["wx"].requirePrivacyAuthorize({
|
|
success: res => {
|
|
// 进入success回调说明用户已同意隐私政策
|
|
// TODO:非标准API的方式处理用户个人信息
|
|
window["wx"].setClipboardData({
|
|
data: loginState.uid,
|
|
success(res) {
|
|
UIMgr.Ins.ShowTipsUI("复制成功")
|
|
},
|
|
fail(res) {
|
|
callBack && callBack();
|
|
console.log("复制失败", res)
|
|
}
|
|
})
|
|
},
|
|
fail: () => {
|
|
// 进入fail回调说明用户拒绝隐私政策
|
|
// 游戏需要放弃处理用户个人信息,同时不要阻断游戏主流程
|
|
window["wx"].setClipboardData({
|
|
data: loginState.uid,
|
|
success(res) {
|
|
UIMgr.Ins.ShowTipsUI("复制成功")
|
|
},
|
|
fail(res) {
|
|
callBack && callBack();
|
|
console.log("复制失败", res)
|
|
}
|
|
})
|
|
}
|
|
})
|
|
|
|
return;
|
|
}
|
|
|
|
callBack && callBack();
|
|
|
|
console.log(loginState.uid);
|
|
|
|
}
|
|
}
|