YzUserPrivacyPanel.ts 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. import CompatibleTool from "./CompatibleTool";
  2. import PlatUtils from "./PlatUtils";
  3. import { utils } from "./Utils";
  4. import YZ_Constant, { BannerLocation } from "./YZ_Constant";
  5. import YZ_LocalStorage from "./YZ_LocalStorage";
  6. const { ccclass, property } = cc._decorator;
  7. @ccclass
  8. export default class YzUserPrivacyPanel extends cc.Component {
  9. _userPrivacyInfo: cc.Node = null;
  10. _checkExit: cc.Node = null;
  11. _mainPanel: cc.Node = null;
  12. _userPrivacyDesc: cc.Label = null;
  13. showDesc: boolean = false; //直接显示详情页面
  14. ratio: number = 1;
  15. imgCount: number = 7; //图片数量 横屏:5 竖屏:7
  16. scale: number = 1.5;
  17. imgPath: string = "http://xcx.youletd.com/xcx/h5/privacyImg/"
  18. companyInfoNode: cc.Node = null;
  19. onLoad() {
  20. if (PlatUtils.IsWechat || PlatUtils.IsQQ || PlatUtils.IsDouyin || PlatUtils.IsBaidu) {
  21. this.imgPath = "https://xcx.youletd.com/xcx/h5/privacyImg/"
  22. }
  23. this._userPrivacyInfo = cc.find("PrivacyDesc", this.node)
  24. this._checkExit = cc.find("CheckPanel", this.node)
  25. this._mainPanel = cc.find("Panel", this.node);
  26. // this._userPrivacyDesc = this._userPrivacyInfo.getComponent(cc.ScrollView).content.getChildByName("item").getComponent(cc.Label);
  27. // if (utils.ServerConfig.user_privacy_info) {
  28. // this._userPrivacyDesc.string = utils.ServerConfig.user_privacy_info;
  29. // }
  30. if (this.showDesc) {
  31. this._mainPanel.active = false;
  32. this._checkExit.active = false;
  33. // this._userPrivacyInfo.active = true;
  34. this._userPrivacyInfo.getComponent(cc.ScrollView).content.getChildByName("choiseNode").active = false;
  35. this.showDescPanel();
  36. }
  37. if (cc.winSize.height < cc.winSize.width) {
  38. // 横屏游戏
  39. this.ratio = cc.winSize.width / 1920 * 0.75;
  40. this.imgCount = 5;
  41. this.imgPath += "h_"
  42. this.scale = 1.4;
  43. } else {
  44. this.ratio = cc.winSize.width / 1080;
  45. this.imgPath += "p_"
  46. }
  47. this._mainPanel.scale = this.ratio;
  48. this._checkExit.scale = this.ratio;
  49. this._userPrivacyInfo.getComponent(cc.ScrollView).content.getChildByName("choiseNode").scale = this.ratio;
  50. this._userPrivacyInfo.getChildByName("view").getChildByName("closeImg").scale = this.ratio;
  51. this._userPrivacyInfo.getChildByName("view").getChildByName("LaodingLabel").scale = this.ratio;
  52. this.companyInfoNode = this._userPrivacyInfo.getComponent(cc.ScrollView).content.getChildByName("ContactInfo");
  53. let subject = "深圳市优智信息技术有限公司";
  54. let contact = "联系邮箱:youzhixx@163.com";
  55. if (utils.ServerConfig.company) {
  56. subject = utils.ServerConfig.company.subject;
  57. contact = utils.ServerConfig.company.contact;
  58. }
  59. this.companyInfoNode.getChildByName("subject").getComponent(cc.Label).string = subject;
  60. this.companyInfoNode.getChildByName("contact").getComponent(cc.Label).string = contact;
  61. }
  62. // onDestroy() {
  63. // utils.emitPrivacyCloseEvent();
  64. // }
  65. onOKClickListener() {
  66. YZ_LocalStorage.setItem(YZ_Constant.YZ_GAME_YSXY, "isOK");
  67. this.node.destroy();
  68. utils.emitPrivacyCloseEvent();
  69. }
  70. onCloseClickListener() {
  71. if (PlatUtils.IsHuaWei) {
  72. utils.GameExit();
  73. return;
  74. }
  75. if (this._checkExit.active && (PlatUtils.IsQQ || PlatUtils.IsOPPO || PlatUtils.IsXiaoMi)) {
  76. utils.GameExit();
  77. return;
  78. }
  79. this._checkExit.active = !this._checkExit.active;
  80. this._mainPanel.active = !this._mainPanel.active;
  81. }
  82. onClosePrivacyDesc() {
  83. if (this.showDesc) {
  84. this.node.destroy();
  85. } else {
  86. this._userPrivacyInfo.active = false;
  87. let childs = this._userPrivacyInfo.getComponent(cc.ScrollView).content.children;
  88. for (let i = 0; i < childs.length; i++) {
  89. childs[i].active = false;
  90. }
  91. }
  92. }
  93. is_btn_jump_desc: boolean = false;
  94. onJumpDescBtnClickListner() {
  95. this.is_btn_jump_desc = true;
  96. this.showDescPanel();
  97. }
  98. showDescPanel() {
  99. this._userPrivacyInfo.active = true;
  100. this._userPrivacyInfo.getChildByName("view").getChildByName("LaodingLabel").active = true;
  101. this.scheduleOnce(() => {
  102. let p = new cc.Node();
  103. p.addComponent(cc.Sprite);
  104. for (let i = 1; i <= this.imgCount; i++) {
  105. let p = new cc.Node();
  106. p.addComponent(cc.Sprite);
  107. this._userPrivacyInfo.getComponent(cc.ScrollView).content.addChild(p);
  108. // cc.loader.loadRes("img_font/h_" + i, (err, res) => {
  109. // if (!err && cc.isValid(this)) {
  110. // p.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(res);
  111. // console.log(p.width, "===", p.height);
  112. // p.height *= this.scale * this.ratio;
  113. // p.width *= this.scale * this.ratio;
  114. // if (i >= 1) {
  115. // this._userPrivacyInfo.getChildByName("view").getChildByName("LaodingLabel").active = false;
  116. // }
  117. // } else {
  118. // utils.showLog("yinsi");
  119. // }
  120. // })
  121. CompatibleTool.LoadRes(this.imgPath + i + ".png", (err, res) => {
  122. if (!err && cc.isValid(this)) {
  123. p.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(res);
  124. p.height *= this.scale * this.ratio;
  125. p.width *= this.scale * this.ratio;
  126. if (i >= 1) {
  127. this._userPrivacyInfo.getChildByName("view").getChildByName("LaodingLabel").active = false;
  128. }
  129. if (i >= this.imgCount) {
  130. this.companyInfoNode.zIndex = this.imgCount;
  131. this.companyInfoNode.active = true;
  132. if (this.is_btn_jump_desc) {
  133. this._userPrivacyInfo.getComponent(cc.ScrollView).content.getChildByName("choiseNode").zIndex = this.imgCount + 1;
  134. this._userPrivacyInfo.getComponent(cc.ScrollView).content.getChildByName("choiseNode").active = true;
  135. }
  136. }
  137. } else {
  138. utils.showMsg("隐私协议加载失败,请关闭窗口重新打开");
  139. }
  140. })
  141. }
  142. // let childs = this._userPrivacyInfo.getComponent(cc.ScrollView).content.children;
  143. // for (let i = 0; i < childs.length; i++) {
  144. // childs[i].opacity = 0;
  145. // childs[i].active = true;
  146. // childs[i].runAction(cc.fadeIn(0.3));
  147. // }
  148. }, 0.5);
  149. }
  150. // update (dt) {}
  151. }