AlertManager.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. const DWTool = require("./DWTool");
  2. /**
  3. * 通用弹窗管理
  4. */
  5. class AlertManager {
  6. // 显示培养弹窗
  7. static showTrainAlert(targetUid, zIndex = 0) {
  8. DWTool.loadResPrefab("./prefabs/artist_train")
  9. .then((result) => {
  10. let artistTrain = cc.instantiate(result);
  11. artistTrain.zIndex = zIndex;
  12. artistTrain.getComponent('ArtistTrain').init(targetUid);
  13. let canvas = cc.find("Canvas");
  14. canvas.addChild(artistTrain);
  15. });
  16. };
  17. // 显示充值弹窗
  18. static showRechargeAlert(zIndex = 0) {
  19. DWTool.loadResPrefab("./prefabs/artist_train_alert")
  20. .then((result) => {
  21. let alert = cc.instantiate(result);
  22. alert.zIndex = zIndex;
  23. let canvas = cc.find("Canvas");
  24. canvas.addChild(alert);
  25. });
  26. };
  27. // 显示星探界面
  28. static showTalentAlert() {
  29. cc.loader.loadRes('/prefabs/talent_mission', cc.Prefab, (error, prefab) => {
  30. if (error === null) {
  31. let mission = cc.instantiate(prefab);
  32. mission = mission.getComponent('TalentMission');
  33. mission.init();
  34. } else {
  35. console.log(JSON.stringify(error));
  36. }
  37. });
  38. };
  39. // 显示培养成功界面
  40. static showArtistTrainCompletion(data, zIndex = 0) {
  41. DWTool.loadResPrefab("./prefabs/artist_train_completion")
  42. .then((result) => {
  43. let alert = cc.instantiate(result);
  44. alert.zIndex = zIndex;
  45. let canvas = cc.find("Canvas");
  46. canvas.addChild(alert);
  47. alert.getComponent('ArtistTrainCompletion').init(data);
  48. });
  49. };
  50. // 艺人没有职业时弹窗提示
  51. static showArtistTrainNoJob(cb, zIndex = 0) {
  52. DWTool.loadResPrefab("./prefabs/artist_train_no_job")
  53. .then((result) => {
  54. let alert = cc.instantiate(result);
  55. alert.zIndex = zIndex;
  56. let canvas = cc.find("Canvas");
  57. canvas.addChild(alert);
  58. alert.getComponent('ArtistTrainNoJob').init(cb);
  59. });
  60. }
  61. // 显示选择驻场艺人
  62. static showArtistResident(buildingInfo, uid, isSelf) {
  63. DWTool.loadResPrefab("./prefabs/artist_resident")
  64. .then((result) => {
  65. let artistResident = cc.instantiate(result);
  66. let canvas = cc.find("Canvas");
  67. artistResident.getComponent('ArtistResident').init(buildingInfo, uid, isSelf);
  68. canvas.addChild(artistResident);
  69. });
  70. }
  71. // 显示通知消息弹窗
  72. static showNoticePopup() {
  73. DWTool.loadResPrefab("./prefabs/notice_popup")
  74. .then((result) => {
  75. let alert = cc.instantiate(result);
  76. let canvas = cc.find("Canvas");
  77. canvas.addChild(alert);
  78. });
  79. }
  80. // 显示任务大厅弹窗
  81. static showQuestPopup() {
  82. DWTool.loadResPrefab("./prefabs/quest_popup")
  83. .then((result) => {
  84. let alert = cc.instantiate(result);
  85. let canvas = cc.find("Canvas");
  86. canvas.addChild(alert);
  87. });
  88. }
  89. // 显示亲密度不够的弹窗
  90. static showIntimacyBotEnough() {
  91. DWTool.loadResPrefab("./prefabs/intimacy_not_enough")
  92. .then((result) => {
  93. let alert = cc.instantiate(result);
  94. let canvas = cc.find("Canvas");
  95. canvas.addChild(alert);
  96. });
  97. }
  98. // 显示亲密度不够的弹窗
  99. static showArtistReportSuccess(coinCount) {
  100. DWTool.loadResPrefab("./prefabs/artist_report_success")
  101. .then((result) => {
  102. let alert = cc.instantiate(result);
  103. let canvas = cc.find("Canvas");
  104. canvas.addChild(alert);
  105. alert.getComponent('ArtistReportSuccess').init(coinCount);
  106. });
  107. }
  108. // 显示艺人操作弹窗
  109. static showArtistOperationAlert(buildingInfo, uid, isSelf, artistData) {
  110. DWTool.loadResPrefab("./prefabs/artist_operation_alert")
  111. .then((result) => {
  112. let alert = cc.instantiate(result);
  113. let canvas = cc.find("Canvas");
  114. canvas.addChild(alert);
  115. alert.getComponent('ArtistOperationAlert').init(buildingInfo, uid, isSelf, artistData);
  116. });
  117. }
  118. static showOfflineGrossIncome(grossIncome) {
  119. DWTool.loadResPrefab("./prefabs/offline_grossIncome")
  120. .then((result) => {
  121. let alert = cc.instantiate(result);
  122. let canvas = cc.find("Canvas");
  123. canvas.addChild(alert);
  124. alert.getComponent('OfflineGrossIncome').init(grossIncome);
  125. });
  126. }
  127. static showRankPage() {
  128. DWTool.loadResPrefab('./prefabs/rank_page')
  129. .then((result) => {
  130. let alert = cc.instantiate(result);
  131. let canvas = cc.find('Canvas');
  132. canvas.addChild(alert);
  133. });
  134. }
  135. }
  136. module.exports = AlertManager;