AlertManager.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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 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 (GameGlobal.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. GameGlobal.skillContent = alert;
  80. });
  81. } else {
  82. GameGlobal.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 (GameGlobal.starContent === undefined) {
  109. PrefabManager.loadPrefab('star_content')
  110. .then((result) => {
  111. let alert = result;
  112. let canvas = cc.find("Canvas/commonNode");
  113. canvas.addChild(alert);
  114. GameGlobal.starContent = alert;
  115. });
  116. } else {
  117. GameGlobal.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. /// qq平台直接弹出错误
  248. } else if (CC_QQPLAY) {
  249. BK.UI.showToast({
  250. title: message,
  251. duration:1500, complete:function() {
  252. BK.Script.log(0,0,"complete show");
  253. }
  254. });
  255. } else {
  256. alert(message);
  257. }
  258. }
  259. // 显示所拥有礼包界面
  260. static showStarGiftBag(array) {
  261. DWTool.loadResPrefab("./prefabs/star/star_gift_bag")
  262. .then((result) => {
  263. let alert = cc.instantiate(result);
  264. let canvas = cc.find("Canvas");
  265. canvas.addChild(alert);
  266. alert.getComponent('StarGiftBag').init(array);
  267. });
  268. }
  269. // 显示所拥有礼包界面
  270. static showStoreQQaddGroup() {
  271. DWTool.loadResPrefab("./prefabs/store/storeQQAlert")
  272. .then((result) => {
  273. let alert = cc.instantiate(result);
  274. let canvas = cc.find("Canvas");
  275. canvas.addChild(alert);
  276. });
  277. }
  278. //显示我的小程序神秘礼包界面
  279. static showAppletAlert() {
  280. GameModule.audioMng.playClickButton();
  281. PrefabManager.loadPrefab('my_applet')
  282. .then((result) => {
  283. let alert = result;
  284. let canvas = cc.find("Canvas");
  285. canvas.addChild(alert);
  286. });
  287. }
  288. //显示邀请好友界面
  289. static showInviteAlert() {
  290. GameModule.audioMng.playClickButton();
  291. PrefabManager.loadPrefab('invite_mission')
  292. .then((result) => {
  293. let alert = result;
  294. let canvas = cc.find("Canvas");
  295. canvas.addChild(alert);
  296. });
  297. }
  298. static showLoginRewardAlert() {
  299. GameModule.audioMng.playClickButton();
  300. PrefabManager.loadPrefab('login_reward')
  301. .then((result) => {
  302. let alert = result;
  303. let canvas = cc.find("Canvas");
  304. canvas.addChild(alert);
  305. });
  306. }
  307. }
  308. module.exports = AlertManager;