AlertManager.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. const GameModule = require("./GameModule");
  2. const DWTool = require("./DWTool");
  3. const PrefabManager = require("./PrefabManager");
  4. /**
  5. * 通用弹窗管理
  6. */
  7. class AlertManager {
  8. // 显示任务界面弹窗
  9. static showQuestPopup() {
  10. GameModule.audioMng.playClickButton();
  11. PrefabManager.loadPrefab('quest_popup')
  12. .then((result) => {
  13. let alert = result;
  14. let canvas = cc.find("Canvas");
  15. canvas.addChild(alert);
  16. });
  17. }
  18. static showOfflineGrossIncome(offlineGold) {
  19. PrefabManager.loadPrefab('offline_grossIncome')
  20. .then((result) => {
  21. let alert = result;
  22. let canvas = cc.find("Canvas");
  23. canvas.addChild(alert);
  24. alert.getComponent('OfflineGrossIncome').init(offlineGold);
  25. });
  26. }
  27. /// 显示抽奖界面
  28. static showDrawAlert(data = 1) {
  29. GameModule.audioMng.playClickButton();
  30. PrefabManager.loadPrefab('draw_content')
  31. .then((result) => {
  32. let alert = result;
  33. let canvas = cc.find("Canvas");
  34. alert.setPosition(0, 0);
  35. canvas.addChild(alert);
  36. });
  37. }
  38. /// 显示抽奖滚动界面
  39. static showDrawScrollAlert(drawData, typeId) {
  40. PrefabManager.loadPrefab('drawCycleScroll')
  41. .then((result) => {
  42. let alert = result;
  43. let canvas = cc.find("Canvas");
  44. alert.setPosition(0, 0);
  45. canvas.addChild(alert);
  46. alert.getComponent("DrawCycleScroll").init(drawData, typeId);
  47. });
  48. }
  49. /// 显示抽奖成功得到明星的界面
  50. static showDrawSuccessAlert(drawData, typeId) {
  51. DWTool.loadResPrefab("./prefabs/draw/drawStarSuccss")
  52. .then((result) => {
  53. let alert = cc.instantiate(result);
  54. let canvas = cc.find("Canvas");
  55. alert.setPosition(0, 0);
  56. canvas.addChild(alert);
  57. alert.getComponent("DrawStarSuccss").init(drawData, typeId);
  58. });
  59. }
  60. /// 显示抽奖红包的界面
  61. static showDrawRedRecordAlert() {
  62. DWTool.loadResPrefab("./prefabs/draw/drawRedRecord")
  63. .then((result) => {
  64. let alert = cc.instantiate(result);
  65. let canvas = cc.find("Canvas");
  66. alert.setPosition(0, 0);
  67. canvas.addChild(alert);
  68. });
  69. }
  70. /// 显示技能弹窗界面
  71. static showSkillAlert() {
  72. GameModule.audioMng.playClickButton();
  73. if (Global.skillContent === undefined) {
  74. PrefabManager.loadPrefab('skill_content')
  75. .then((result) => {
  76. let alert = result;
  77. let canvas = cc.find("Canvas/commonNode");
  78. canvas.addChild(alert);
  79. Global.skillContent = alert;
  80. });
  81. } else {
  82. Global.skillContent.getComponent('skillContent').show();
  83. }
  84. }
  85. static showSkillBuyAlert (skillInfo, nextSkillInfo, starItem) {
  86. GameModule.audioMng.playClickButton();
  87. DWTool.loadResPrefab("./prefabs/skill/skillBuyAlert")
  88. .then((result) => {
  89. let alert = cc.instantiate(result);
  90. let canvas = cc.find("Canvas");
  91. canvas.addChild(alert);
  92. alert.getComponent('SkillBuyAlert').init(skillInfo, nextSkillInfo, starItem);
  93. });
  94. }
  95. /// 显示明星图鉴
  96. static showStarHandbookAlert() {
  97. GameModule.audioMng.playClickButton();
  98. PrefabManager.loadPrefab('starHandbook')
  99. .then((result) => {
  100. let alert = result;
  101. let canvas = cc.find("Canvas");
  102. canvas.addChild(alert);
  103. });
  104. }
  105. /// 显示明星界面
  106. static showStarAlert() {
  107. GameModule.audioMng.playClickButton();
  108. if (Global.starContent === undefined || Global.starContent === null) {
  109. PrefabManager.loadPrefab('star_content')
  110. .then((result) => {
  111. let alert = result;
  112. let canvas = cc.find("Canvas/commonNode");
  113. canvas.addChild(alert);
  114. Global.starContent = alert;
  115. });
  116. } else {
  117. Global.starContent.getComponent('StarContent').show();
  118. }
  119. }
  120. /// 显示获取道具弹窗界面
  121. static showActGiftAlert(type, showText, spriteFrame) {
  122. DWTool.loadResPrefab("./prefabs/common/actgift")
  123. .then((result) => {
  124. let alert = cc.instantiate(result);
  125. let canvas = cc.find("Canvas");
  126. canvas.addChild(alert);
  127. alert.getComponent("Actgift").init(type, showText, spriteFrame);
  128. });
  129. }
  130. /// 显示签到界面
  131. static showSignInAlert() {
  132. PrefabManager.loadPrefab('sign_in')
  133. .then((result) => {
  134. let alert = result;
  135. let canvas = cc.find("Canvas");
  136. canvas.addChild(alert);
  137. });
  138. }
  139. /// 显示明星图鉴
  140. static showRankAlert(index = 0) {
  141. GameModule.audioMng.playClickButton();
  142. PrefabManager.loadPrefab('game_rank')
  143. .then((result) => {
  144. let alert = result;
  145. let canvas = cc.find("Canvas");
  146. canvas.addChild(alert);
  147. alert.getComponent('GameRank').init(index);
  148. });
  149. }
  150. /// 显示商城界面
  151. static showStoreAlert() {
  152. GameModule.audioMng.playClickButton();
  153. PrefabManager.loadPrefab('store_content')
  154. .then((result) => {
  155. let alert = result;
  156. let canvas = cc.find("Canvas");
  157. canvas.addChild(alert);
  158. });
  159. }
  160. /// 显示商城合辑界面
  161. static showStoreAlbumAlert(temDatas) {
  162. DWTool.loadResPrefab("./prefabs/store/storeAlbum")
  163. .then((result) => {
  164. let alert = cc.instantiate(result);
  165. alert.getComponent('StoreSubcript').init(temDatas);
  166. let canvas = cc.find("Canvas");
  167. canvas.addChild(alert);
  168. });
  169. }
  170. /// 显示商城钻石优惠界面
  171. static showStoreDiamondAlert(selectIndex) {
  172. DWTool.loadResPrefab("./prefabs/store/storeDiamond")
  173. .then((result) => {
  174. let alert = cc.instantiate(result);
  175. let canvas = cc.find("Canvas");
  176. canvas.addChild(alert);
  177. alert.getComponent('StoreDiamondDiscount').init(selectIndex);
  178. });
  179. }
  180. //// 显示商城礼包弹窗
  181. static showStoreGiftAlert(giftIndex, giftData) {
  182. DWTool.loadResPrefab("./prefabs/store/storeGiftAlert")
  183. .then((result) => {
  184. let alert = cc.instantiate(result);
  185. let canvas = cc.find("Canvas");
  186. canvas.addChild(alert);
  187. alert.getComponent('StoreGiftAlert').init(giftIndex, giftData);
  188. });
  189. }
  190. /// 显示技能2弹出金币效果
  191. static showSkill2Efc(gold) {
  192. DWTool.loadResPrefab("./prefabs/skill/use_skill2_efc")
  193. .then((result) => {
  194. let alert = cc.instantiate(result);
  195. let canvas = cc.find("Canvas/useSkillNode");
  196. canvas.addChild(alert);
  197. alert.getComponent('UseSkill2Efc').init(gold);
  198. });
  199. }
  200. /// 显示共有弹窗
  201. static showCommonAlert(iconPath, desc, title) {
  202. DWTool.loadResPrefab("./prefabs/common/commonAlert")
  203. .then((result) => {
  204. let alert = cc.instantiate(result);
  205. let canvas = cc.find("Canvas");
  206. canvas.addChild(alert);
  207. alert.getComponent('commAlert').init(iconPath, desc, title);
  208. });
  209. }
  210. /// 显示每天获取钻石弹窗
  211. static showGetDiamondEveryDayAlert(iconPath, desc, title, diamond) {
  212. DWTool.loadResPrefab("./prefabs/common/commonAlert")
  213. .then((result) => {
  214. let alert = cc.instantiate(result);
  215. let canvas = cc.find("Canvas");
  216. canvas.addChild(alert);
  217. alert.getComponent('commAlert').initAddDiamond(iconPath, desc, title, diamond);
  218. });
  219. }
  220. /// 显示通知弹窗
  221. static showNoticeAlert(noticeStr) {
  222. DWTool.loadResPrefab("./prefabs/common/noticeAlert")
  223. .then((result) => {
  224. let alert = cc.instantiate(result);
  225. let canvas = cc.find("Canvas");
  226. canvas.addChild(alert);
  227. alert.getComponent('NoticeAlert').init(noticeStr);
  228. });
  229. }
  230. /// 显示分享失败弹窗
  231. static showShareFailAlert() {
  232. DWTool.loadResPrefab("./prefabs/common/shareFailAlert")
  233. .then((result) => {
  234. let alert = cc.instantiate(result);
  235. let canvas = cc.find("Canvas");
  236. canvas.addChild(alert);
  237. alert.getComponent('shareFailAlert').show();
  238. });
  239. }
  240. // 显示错误消息提示
  241. static showCommonErrorAlert(message) {
  242. if (CC_WECHATGAME) {
  243. wx.showToast({
  244. title: message,
  245. icon: 'none'
  246. });
  247. } else {
  248. alert(message);
  249. }
  250. }
  251. // 显示所拥有礼包界面
  252. static showStarGiftBag(array) {
  253. DWTool.loadResPrefab("./prefabs/star/star_gift_bag")
  254. .then((result) => {
  255. let alert = cc.instantiate(result);
  256. let canvas = cc.find("Canvas");
  257. canvas.addChild(alert);
  258. alert.getComponent('StarGiftBag').init(array);
  259. });
  260. }
  261. //显示我的小程序神秘礼包界面
  262. static showAppletAlert() {
  263. GameModule.audioMng.playClickButton();
  264. PrefabManager.loadPrefab('my_applet')
  265. .then((result) => {
  266. let alert = result;
  267. let canvas = cc.find("Canvas");
  268. canvas.addChild(alert);
  269. });
  270. }
  271. //显示邀请好友界面
  272. static showInviteAlert() {
  273. GameModule.audioMng.playClickButton();
  274. PrefabManager.loadPrefab('invite_mission')
  275. .then((result) => {
  276. let alert = result;
  277. let canvas = cc.find("Canvas");
  278. canvas.addChild(alert);
  279. });
  280. }
  281. static showLoginRewardAlert() {
  282. GameModule.audioMng.playClickButton();
  283. PrefabManager.loadPrefab('login_reward')
  284. .then((result) => {
  285. let alert = result;
  286. let canvas = cc.find("Canvas");
  287. canvas.addChild(alert);
  288. });
  289. }
  290. }
  291. module.exports = AlertManager;