check_view.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. import { _decorator, Component, Node, Label } from 'cc';
  2. import { ClientEvent } from '../clientEvent';
  3. import { Constant, privacy_select, privacy_type } from '../constant';
  4. import { GameMng } from '../GameMng';
  5. import { UIButton } from '../gcommon/UIButton';
  6. const { ccclass, property } = _decorator;
  7. @ccclass('check_view')
  8. export class check_view extends Component {
  9. @property(Node) tag_lab:Node = null
  10. @property(Node) check_1:Node = null
  11. @property(Node) check_2:Node = null
  12. @property(Node) check_3:Node = null
  13. @property(Node) check_1_lab:Node = null
  14. @property(Node) check_2_lab:Node = null
  15. @property(Node) check_3_lab:Node = null
  16. @property(Node) check_1_sp:Node = null
  17. @property(Node) check_2_sp:Node = null
  18. @property(Node) check_3_sp:Node = null
  19. private check_list:Node[] = []
  20. private curSelectType = 0;
  21. private curSelectPrivacyType:privacy_type;
  22. start() {
  23. UIButton.BindClick(this.check_1,()=>{
  24. if(this.curSelectType!=privacy_select.suo_you_ren){
  25. this.curSelectType = privacy_select.suo_you_ren
  26. this.updateSelectStatus(true)
  27. }
  28. },this);
  29. UIButton.BindClick(this.check_2,()=>{
  30. if(this.curSelectType != privacy_select.jin_hao_you){
  31. this.curSelectType = privacy_select.jin_hao_you
  32. this.updateSelectStatus(true)
  33. }
  34. },this);
  35. UIButton.BindClick(this.check_3,()=>{
  36. if(this.curSelectType != privacy_select.ju_jue){
  37. this.curSelectType = privacy_select.ju_jue
  38. this.updateSelectStatus(true)
  39. }
  40. },this);
  41. this.updateSelectStatus()
  42. }
  43. initCheckList(){
  44. if(this.check_list.length<=0){
  45. this.check_list.push(this.check_1_sp)
  46. this.check_list.push(this.check_2_sp)
  47. this.check_list.push(this.check_3_sp)
  48. }
  49. }
  50. show(type:privacy_type){
  51. this.curSelectPrivacyType = type
  52. let data = Constant.CHECK_PRIVACY[type]
  53. this.tag_lab.getComponent(Label).string = data.tag;
  54. this.check_1_lab.getComponent(Label).string = data.select_list[0]
  55. this.check_2_lab.getComponent(Label).string = data.select_list[1]
  56. this.check_3_lab.getComponent(Label).string = data.select_list[2]
  57. if(GameMng._userData.privacy===null||GameMng._userData.privacy===undefined){
  58. console.error("GameMng._userData.privacy error");
  59. return
  60. }
  61. switch(type)
  62. {
  63. case privacy_type.liu_yan:
  64. this.curSelectType = GameMng._userData.privacy.liuyan_type
  65. break;
  66. case privacy_type.zhan_ji:
  67. this.curSelectType = GameMng._userData.privacy.zhanji_type
  68. break;
  69. case privacy_type.yue_zhan:
  70. this.curSelectType = GameMng._userData.privacy.yuezhan_type
  71. break;
  72. }
  73. this.updateSelectStatus()
  74. }
  75. updateSelectStatus(change:boolean=false){
  76. this.initCheckList()
  77. for (let index = 0; index < this.check_list.length; index++) {
  78. const element = this.check_list[index];
  79. element.active = false;
  80. }
  81. this.check_list[this.curSelectType].active = true;
  82. switch( this.curSelectPrivacyType)
  83. {
  84. case privacy_type.liu_yan:
  85. GameMng._userData.privacy.liuyan_type =this.curSelectType
  86. break;
  87. case privacy_type.zhan_ji:
  88. GameMng._userData.privacy.zhanji_type = this.curSelectType
  89. break;
  90. case privacy_type.yue_zhan:
  91. GameMng._userData.privacy.yuezhan_type = this.curSelectType
  92. break;
  93. }
  94. if(change){
  95. ClientEvent.dispatchEvent(Constant.UI_EVENT.UI_MSG_UPDATE_PRIVACY)
  96. }
  97. }
  98. update(deltaTime: number) {
  99. }
  100. }