privacy_setting.ts 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import { _decorator, Component, Node, Toggle, Label } from 'cc';
  2. import { ClientEvent } from '../clientEvent';
  3. import { Constant, privacy_type } from '../constant';
  4. import { GameMng } from '../GameMng';
  5. import GBaseUI from '../gcommon/GBaseUI';
  6. import { UIButton } from '../gcommon/UIButton';
  7. import { check_view } from './check_view';
  8. import { page_btn } from './page_btn';
  9. const { ccclass, property } = _decorator;
  10. @ccclass('privacy_setting')
  11. export class privacy_setting extends GBaseUI {
  12. @property(Node)
  13. btn_close: Node = null;
  14. @property(Node)
  15. btn_on_or_off: Node = null;
  16. @property(Node)
  17. btn_yuzhan: Node = null;
  18. @property(Node)
  19. btn_liuyan: Node = null;
  20. @property(Node)
  21. btn_zhanji: Node = null;
  22. @property(Node)
  23. lab_yuzhan: Node = null;
  24. @property(Node)
  25. lab_liuyan: Node = null;
  26. @property(Node)
  27. lab_zhanji: Node = null;
  28. @property(Node) check_view:Node = null;
  29. start() {
  30. UIButton.BindClick(this.btn_close,()=>{
  31. if(this.check_view.active === true){
  32. this.check_view.active = false;
  33. }else{
  34. this.closeUI()
  35. }
  36. },this)
  37. UIButton.BindClick(this.btn_on_or_off,()=>{
  38. this.clickToggle(this.btn_on_or_off)
  39. },this)
  40. UIButton.BindClick(this.btn_yuzhan,()=>{
  41. this.showSelectPrivacyCheck(privacy_type.yue_zhan)
  42. },this)
  43. UIButton.BindClick(this.btn_liuyan,()=>{
  44. this.showSelectPrivacyCheck(privacy_type.liu_yan)
  45. },this)
  46. UIButton.BindClick(this.btn_zhanji,()=>{
  47. this.showSelectPrivacyCheck(privacy_type.zhan_ji)
  48. },this)
  49. this.udpateCheckPrivacy()
  50. ClientEvent.on(Constant.UI_EVENT.UI_MSG_UPDATE_PRIVACY,this.udpateCheckPrivacy,this)
  51. }
  52. onDestroy(){
  53. ClientEvent.off(Constant.UI_EVENT.UI_MSG_UPDATE_PRIVACY,this.udpateCheckPrivacy,this)
  54. }
  55. udpateCheckPrivacy(){
  56. this.lab_zhanji.getComponent(Label).string = Constant.CHECK_PRIVACY[privacy_type.zhan_ji].select_list[GameMng._userData.privacy.zhanji_type]
  57. this.lab_liuyan.getComponent(Label).string = Constant.CHECK_PRIVACY[privacy_type.liu_yan].select_list[GameMng._userData.privacy.liuyan_type]
  58. this.lab_yuzhan.getComponent(Label).string = Constant.CHECK_PRIVACY[privacy_type.yue_zhan].select_list[GameMng._userData.privacy.yuezhan_type]
  59. }
  60. showSelectPrivacyCheck(type:privacy_type){
  61. this.check_view.active = true;
  62. this.check_view.getComponent(check_view).show(type)
  63. }
  64. clickToggle(node:Node){
  65. if(node.getComponent(page_btn).isSelect()){
  66. node.getComponent(page_btn).status_unselect()
  67. }else{
  68. node.getComponent(page_btn).status_select()
  69. }
  70. }
  71. update(deltaTime: number) {
  72. }
  73. }