AlertManager.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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('drawScroll')
  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("DrawScroll").init(drawData, typeId);
  47. });
  48. }
  49. /// 显示抽奖成功得到明星的界面
  50. static showDrawSuccessAlert(drawData, typeId, backGroudId) {
  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, backGroudId);
  58. });
  59. }
  60. /// 显示技能弹窗界面
  61. static showSkillAlert() {
  62. GameModule.audioMng.playClickButton();
  63. if (GameGlobal.skillContent === undefined) {
  64. PrefabManager.loadPrefab('skill_content')
  65. .then((result) => {
  66. let alert = result;
  67. let canvas = cc.find("Canvas/commonNode");
  68. canvas.addChild(alert);
  69. GameGlobal.skillContent = alert;
  70. });
  71. } else {
  72. GameGlobal.skillContent.getComponent('skillContent').show();
  73. }
  74. }
  75. static showSkillBuyAlert (skillInfo, nextSkillInfo, starItem) {
  76. GameModule.audioMng.playClickButton();
  77. DWTool.loadResPrefab("./prefabs/skill/skillBuyAlert")
  78. .then((result) => {
  79. let alert = cc.instantiate(result);
  80. let canvas = cc.find("Canvas");
  81. canvas.addChild(alert);
  82. alert.getComponent('SkillBuyAlert').init(skillInfo, nextSkillInfo, starItem);
  83. });
  84. }
  85. /// 显示明星图鉴
  86. static showStarHandbookAlert() {
  87. GameModule.audioMng.playClickButton();
  88. PrefabManager.loadPrefab('starHandbook')
  89. .then((result) => {
  90. let alert = result;
  91. let canvas = cc.find("Canvas");
  92. canvas.addChild(alert);
  93. });
  94. }
  95. /// 显示明星界面
  96. static showStarAlert() {
  97. GameModule.audioMng.playClickButton();
  98. if (GameGlobal.starContent === undefined) {
  99. PrefabManager.loadPrefab('star_content')
  100. .then((result) => {
  101. let alert = result;
  102. let canvas = cc.find("Canvas/commonNode");
  103. canvas.addChild(alert);
  104. GameGlobal.starContent = alert;
  105. });
  106. } else {
  107. GameGlobal.starContent.getComponent('StarContent').show();
  108. }
  109. }
  110. /// 显示获取道具弹窗界面
  111. static showActGiftAlert(type, showText, spriteFrame) {
  112. DWTool.loadResPrefab("./prefabs/common/actgift")
  113. .then((result) => {
  114. let alert = cc.instantiate(result);
  115. let canvas = cc.find("Canvas");
  116. canvas.addChild(alert);
  117. alert.getComponent("Actgift").init(type, showText, spriteFrame);
  118. });
  119. }
  120. /// 显示签到界面
  121. static showSignInAlert() {
  122. PrefabManager.loadPrefab('sign_in')
  123. .then((result) => {
  124. let alert = result;
  125. let canvas = cc.find("Canvas");
  126. canvas.addChild(alert);
  127. });
  128. }
  129. /// 显示明星图鉴
  130. static showRankAlert(index = 0) {
  131. GameModule.audioMng.playClickButton();
  132. PrefabManager.loadPrefab('game_rank')
  133. .then((result) => {
  134. let alert = result;
  135. let canvas = cc.find("Canvas");
  136. canvas.addChild(alert);
  137. alert.getComponent('GameRank').init(index);
  138. });
  139. }
  140. /// 显示商城界面
  141. static showStoreAlert() {
  142. GameModule.audioMng.playClickButton();
  143. PrefabManager.loadPrefab('store_content')
  144. .then((result) => {
  145. let alert = result;
  146. let canvas = cc.find("Canvas");
  147. canvas.addChild(alert);
  148. });
  149. }
  150. /// 显示商城合辑界面
  151. static showStoreAlbumAlert(temDatas) {
  152. DWTool.loadResPrefab("./prefabs/store/storeAlbum")
  153. .then((result) => {
  154. let alert = cc.instantiate(result);
  155. alert.getComponent('StoreSubcript').init(temDatas);
  156. let canvas = cc.find("Canvas");
  157. canvas.addChild(alert);
  158. });
  159. }
  160. /// 显示商城钻石优惠界面
  161. static showStoreDiamondAlert(selectIndex) {
  162. DWTool.loadResPrefab("./prefabs/store/storeDiamond")
  163. .then((result) => {
  164. let alert = cc.instantiate(result);
  165. let canvas = cc.find("Canvas");
  166. canvas.addChild(alert);
  167. alert.getComponent('StoreDiamondDiscount').init(selectIndex);
  168. });
  169. }
  170. //// 显示商城礼包弹窗
  171. static showStoreGiftAlert(giftIndex, giftData) {
  172. DWTool.loadResPrefab("./prefabs/store/storeGiftAlert")
  173. .then((result) => {
  174. let alert = cc.instantiate(result);
  175. let canvas = cc.find("Canvas");
  176. canvas.addChild(alert);
  177. alert.getComponent('StoreGiftAlert').init(giftIndex, giftData);
  178. });
  179. }
  180. /// 显示技能2弹出金币效果
  181. static showSkill2Efc(gold) {
  182. DWTool.loadResPrefab("./prefabs/skill/use_skill2_efc")
  183. .then((result) => {
  184. let alert = cc.instantiate(result);
  185. let canvas = cc.find("Canvas/useSkillNode");
  186. canvas.addChild(alert);
  187. alert.getComponent('UseSkill2Efc').init(gold);
  188. });
  189. }
  190. /// 显示共有弹窗
  191. static showCommonAlert(iconPath, desc, title) {
  192. DWTool.loadResPrefab("./prefabs/common/commonAlert")
  193. .then((result) => {
  194. let alert = cc.instantiate(result);
  195. let canvas = cc.find("Canvas");
  196. canvas.addChild(alert);
  197. alert.getComponent('commAlert').init(iconPath, desc, title);
  198. });
  199. }
  200. /// 显示通知弹窗
  201. static showNoticeAlert(noticeStr) {
  202. DWTool.loadResPrefab("./prefabs/common/noticeAlert")
  203. .then((result) => {
  204. let alert = cc.instantiate(result);
  205. let canvas = cc.find("Canvas");
  206. canvas.addChild(alert);
  207. alert.getComponent('NoticeAlert').init(noticeStr);
  208. });
  209. }
  210. /// 显示分享失败弹窗
  211. static showShareFailAlert() {
  212. DWTool.loadResPrefab("./prefabs/common/shareFailAlert")
  213. .then((result) => {
  214. let alert = cc.instantiate(result);
  215. let canvas = cc.find("Canvas");
  216. canvas.addChild(alert);
  217. alert.getComponent('shareFailAlert').show();
  218. });
  219. }
  220. // 显示错误消息提示
  221. static showCommonErrorAlert(message) {
  222. if (CC_WECHATGAME) {
  223. wx.showToast({
  224. title: message,
  225. icon: 'none'
  226. });
  227. /// qq平台直接弹出错误
  228. } else if (CC_QQPLAY) {
  229. BK.UI.showToast({
  230. title: message,
  231. duration:1500, complete:function() {
  232. BK.Script.log(0,0,"complete show");
  233. }
  234. });
  235. } else {
  236. alert(message);
  237. }
  238. }
  239. // 显示所拥有礼包界面
  240. static showStarGiftBag(array) {
  241. DWTool.loadResPrefab("./prefabs/star/star_gift_bag")
  242. .then((result) => {
  243. let alert = cc.instantiate(result);
  244. let canvas = cc.find("Canvas");
  245. canvas.addChild(alert);
  246. alert.getComponent('StarGiftBag').init(array);
  247. });
  248. }
  249. // 显示所拥有礼包界面
  250. static showStoreQQaddGroup() {
  251. DWTool.loadResPrefab("./prefabs/store/storeQQAlert")
  252. .then((result) => {
  253. let alert = cc.instantiate(result);
  254. let canvas = cc.find("Canvas");
  255. canvas.addChild(alert);
  256. });
  257. }
  258. }
  259. module.exports = AlertManager;