ShowConfig.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import Global from "./Global";
  2. import LogMgr from "./LogMgr";
  3. import Tools from "./Tools";
  4. import Emit from "./manage/Emit/Emit";
  5. import EmitData from "./manage/Emit/EmitData";
  6. import QgBanner from "./manage/Api/QgBanner";
  7. export default class ShowConfig {
  8. private static str: string = '';
  9. private static showResolve: any = null;
  10. public static initEmit() {
  11. Emit.instance().on(EmitData.IN_NATIVE_NEXT, this.inNativeNext, this);
  12. }
  13. public static show(str: string) {
  14. return new Promise((resolve) => {
  15. this.showResolve = resolve;
  16. if (!Global.isVivo) {
  17. this.showResolve(false);
  18. this.showResolve = null;
  19. return;
  20. }
  21. if (!str || !Global.config[str]) {
  22. LogMgr.error('参数为空或者config中不存在该配置:str:' + str);
  23. this.showResolve(false);
  24. this.showResolve = null;
  25. return
  26. }
  27. LogMgr.log('检测配置信息');
  28. this.str = str;
  29. if (Global.config[this.str].nativeConfig.type == 2) {
  30. QgBanner.hideBanner();
  31. }
  32. console.log('AAA>>>>>>')
  33. this.playVideo().then(() => {
  34. console.log('BBB>>>>>>')
  35. return this.openNative();
  36. }).then((res) => {
  37. if (!res) {
  38. this.inNativeNext();
  39. }
  40. })
  41. })
  42. }
  43. private static playVideo() {
  44. return new Promise((resolve) => {
  45. if (Global.config[this.str].startVideo == 0) {
  46. Global.config[this.str].startVideo = 1;
  47. resolve(true);
  48. return
  49. }
  50. if (Tools.checkPer(Global.config[this.str].videoPer)) {
  51. Tools.handleVideo().then(() => {
  52. resolve(true);
  53. })
  54. } else {
  55. resolve(true);
  56. }
  57. })
  58. }
  59. private static openNative() {
  60. return new Promise((resolve) => {
  61. console.log('CCC>>>>>>');
  62. if (Global.config[this.str].startNative == 0) {
  63. Global.config[this.str].startNative = 1;
  64. resolve(false);
  65. return
  66. }
  67. if (Tools.checkPer(Global.config[this.str].nativePer)) {
  68. Tools.showNative(Global.config[this.str].nativeConfig.type, Global.config[this.str].nativeConfig.labelType, Global.config[this.str].nativeConfig.time).then((res) => {
  69. resolve(res);
  70. });
  71. } else {
  72. resolve(false);
  73. }
  74. })
  75. }
  76. private static openIntersAd() {
  77. return new Promise((resolve) => {
  78. console.log('DDD>>>>>>')
  79. if (Global.config[this.str].startIntersAd == 0) {
  80. Global.config[this.str].startIntersAd = 1;
  81. resolve(false);
  82. return
  83. }
  84. if (Tools.checkPer(Global.config[this.str].intersAdPer)) {
  85. Tools.handlerInters().then((res) => {
  86. resolve(res);
  87. })
  88. } else {
  89. resolve(false);
  90. }
  91. })
  92. }
  93. private static inNativeNext() {
  94. this.openIntersAd().then((res) => {
  95. console.log('EEE>>>>>>')
  96. this.showResolve(true);
  97. this.showResolve = null;
  98. })
  99. }
  100. }