Setting.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. cc.Class({
  2. extends: cc.BaseClass, // 继承自cc.BaseClass
  3. properties: {
  4. m_BtSwitch: cc.Button, // 切换账号按钮
  5. m_SliderMusic: cc.Node, // 音乐滑块节点
  6. m_SliderSound: cc.Node, // 音效滑块节点
  7. m_AgreeNode: cc.Node, // 同意条款节点
  8. },
  9. onLoad: function () {
  10. // 根据是否为H5或微信环境设置切换账号按钮的显示状态
  11. // this.$('New Node/BtSwitchAcc').active = !cc.share.IsH5_WX();
  12. },
  13. OnShowView: function () {
  14. // 加载设置信息
  15. window.LoadSetting();
  16. // 如果音乐控制对象未初始化,则通过$方法获取并初始化
  17. if (!this.m_CumMusic) this.m_CumMusic = this.$('Music@SettingMusic');
  18. // 如果音效控制对象未初始化,则通过$方法获取并初始化
  19. if (!this.m_CumSound) this.m_CumSound = this.$('Sound@SettingSound');
  20. // 加载音乐设置
  21. this.m_CumMusic.Load();
  22. // 加载音效设置
  23. this.m_CumSound.Load();
  24. },
  25. OnBtShowDlg: function () {
  26. cc.gSoundRes.PlaySound('Button');
  27. this.ShowPrefabDLG("RoomRules", this.m_DlgNode);
  28. },
  29. OnBtSwitchAcc: function () {
  30. // 播放按钮点击音效
  31. cc.gSoundRes.PlaySound('Button');
  32. // 设置重新登录标志
  33. gReLogin = true;
  34. // 如果存在切换账号的钩子函数,则调用
  35. if (this.m_Hook.OnSwitchAcc) this.m_Hook.OnSwitchAcc();
  36. // 销毁客户端核心对象
  37. gClientKernel.destory();
  38. // 切换到启动场景
  39. ChangeScene('Launch');
  40. // 关闭俱乐部客户端核心对象
  41. window.gClubClientKernel.shutdown();
  42. },
  43. OnBtExit: function () {
  44. // 播放按钮点击音效
  45. cc.gSoundRes.PlaySound('Button');
  46. // 显示退出游戏确认弹窗
  47. this.ShowAlert("確認退出遊戲?", Alert_YesNo, function (Res) {
  48. // 根据用户选择决定是否调用第三方退出游戏函数
  49. if (Res) ThirdPartyExitGame();
  50. // 关闭俱乐部客户端核心对象
  51. window.gClubClientKernel.shutdown();
  52. });
  53. },
  54. OnShowAgreeNode: function () {
  55. // 播放按钮点击音效
  56. cc.gSoundRes.PlaySound('Button');
  57. // 显示用户协议弹窗
  58. this.ShowPrefabDLG('AgreeMent');
  59. },
  60. OnBtShowDiamond: function () {
  61. cc.gSoundRes.PlaySound('Button');
  62. this.ShowPrefabDLG("DiamondPolicy");
  63. },
  64. //注销
  65. OnBtShowLogOff: function () {
  66. cc.gSoundRes.PlaySound('Button');
  67. this.ShowAlert("清空該帳號信息且無法復原,點擊'確定'則永久刪除帳號!", Alert_All, function (Res) {
  68. if (Res) {
  69. console.log("注销----")
  70. let pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  71. let webUrl = window.PHP_HOME + '/UserFunc.php?&GetMark=400&dwUserID=' + pGlobalUserData.dwUserID;
  72. WebCenter.GetData(webUrl, null, function (res) {
  73. console.log("删除返回", res)
  74. let jsonData = JSON.parse(res);
  75. if (jsonData.Code == "1") {
  76. console.log("删除成功")
  77. cc.sys.localStorage.clear();//cc.sys.localStorage.removeItem(key)
  78. this.ShowAlert('刪除帳戶成功!');
  79. gReLogin = true;
  80. // 如果存在切换账号的钩子函数,则调用
  81. if (this.m_Hook.OnSwitchAcc) this.m_Hook.OnSwitchAcc();
  82. // 销毁客户端核心对象
  83. gClientKernel.destory();
  84. // 切换到启动场景
  85. ChangeScene('Launch');
  86. // 关闭俱乐部客户端核心对象
  87. window.gClubClientKernel.shutdown();
  88. } else {
  89. console.log("删除失败")
  90. this.ShowAlert('刪除帳戶失敗!');
  91. }
  92. // if (Login.errcode != null) return this.ShowAlert("ErrCode:" + Login.errcode, Alert_Yes, function () {
  93. // });
  94. }.bind(this));
  95. } else {
  96. console.log("不注销----")
  97. }
  98. }.bind(this));
  99. },
  100. });