AlertManager.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. DWTool.loadResPrefab("./prefabs/share_dialog")
  30. .then((result) => {
  31. let talent = cc.instantiate(result);
  32. let canvas = cc.find("Canvas");
  33. canvas.addChild(talent);
  34. talent.getComponent('ShareDialog').showTalent();
  35. });
  36. };
  37. // 显示培养成功界面
  38. static showArtistTrainCompletion(data, zIndex = 0) {
  39. DWTool.loadResPrefab("./prefabs/artist_train_completion")
  40. .then((result) => {
  41. let alert = cc.instantiate(result);
  42. alert.zIndex = zIndex;
  43. let canvas = cc.find("Canvas");
  44. canvas.addChild(alert);
  45. alert.getComponent('ArtistTrainCompletion').init(data);
  46. });
  47. };
  48. // 艺人没有职业时弹窗提示
  49. static showArtistTrainNoJob(cb, zIndex = 0) {
  50. DWTool.loadResPrefab("./prefabs/artist_train_no_job")
  51. .then((result) => {
  52. let alert = cc.instantiate(result);
  53. alert.zIndex = zIndex;
  54. let canvas = cc.find("Canvas");
  55. canvas.addChild(alert);
  56. alert.getComponent('ArtistTrainNoJob').init(cb);
  57. });
  58. }
  59. // 显示选择驻场艺人
  60. static showArtistResident(buildingInfo, uid, isSelf) {
  61. DWTool.loadResPrefab("./prefabs/artist_resident")
  62. .then((result) => {
  63. let artistResident = cc.instantiate(result);
  64. let canvas = cc.find("Canvas");
  65. artistResident.getComponent('ArtistResident').init(buildingInfo, uid, isSelf);
  66. canvas.addChild(artistResident);
  67. });
  68. }
  69. // 显示通知消息弹窗
  70. static showNoticePopup() {
  71. DWTool.loadResPrefab("./prefabs/notice_popup")
  72. .then((result) => {
  73. let alert = cc.instantiate(result);
  74. let canvas = cc.find("Canvas");
  75. canvas.addChild(alert);
  76. });
  77. }
  78. // 显示任务大厅弹窗
  79. static showQuestPopup() {
  80. DWTool.loadResPrefab("./prefabs/quest_popup")
  81. .then((result) => {
  82. let alert = cc.instantiate(result);
  83. let canvas = cc.find("Canvas");
  84. canvas.addChild(alert);
  85. });
  86. }
  87. // 显示亲密度不够的弹窗
  88. static showIntimacyBotEnough() {
  89. DWTool.loadResPrefab("./prefabs/intimacy_not_enough")
  90. .then((result) => {
  91. let alert = cc.instantiate(result);
  92. let canvas = cc.find("Canvas");
  93. canvas.addChild(alert);
  94. });
  95. }
  96. // 显示亲密度不够的弹窗
  97. static showArtistReportSuccess(coinCount) {
  98. DWTool.loadResPrefab("./prefabs/artist_report_success")
  99. .then((result) => {
  100. let alert = cc.instantiate(result);
  101. let canvas = cc.find("Canvas");
  102. canvas.addChild(alert);
  103. alert.getComponent('ArtistReportSuccess').init(coinCount);
  104. });
  105. }
  106. // 显示艺人操作弹窗
  107. static showArtistOperationAlert(buildingInfo, uid, isSelf, artistData) {
  108. DWTool.loadResPrefab("./prefabs/artist_operation_alert")
  109. .then((result) => {
  110. let alert = cc.instantiate(result);
  111. let canvas = cc.find("Canvas");
  112. canvas.addChild(alert);
  113. alert.getComponent('ArtistOperationAlert').init(buildingInfo, uid, isSelf, artistData);
  114. });
  115. }
  116. static showOfflineGrossIncome(grossIncome) {
  117. DWTool.loadResPrefab("./prefabs/offline_grossIncome")
  118. .then((result) => {
  119. let alert = cc.instantiate(result);
  120. let canvas = cc.find("Canvas");
  121. canvas.addChild(alert);
  122. alert.getComponent('OfflineGrossIncome').init(grossIncome);
  123. });
  124. }
  125. static showRankPage() {
  126. DWTool.loadResPrefab('./prefabs/rank_page')
  127. .then((result) => {
  128. let alert = cc.instantiate(result);
  129. let canvas = cc.find('Canvas');
  130. canvas.addChild(alert);
  131. });
  132. }
  133. }
  134. module.exports = AlertManager;