yingchigamesdk-cocos-v3 25.9.3 → 26.1.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -424,7 +424,7 @@ var AdType = /* @__PURE__ */ ((AdType2) => {
424
424
  })(AdType || {});
425
425
 
426
426
  // assets/script/ycsdk/YCSDK.ts
427
- import { sys as sys7, view as view3 } from "cc";
427
+ import { sys as sys3, view } from "cc";
428
428
 
429
429
  // assets/script/ycsdk/minigame/DebugGame.ts
430
430
  import { instantiate as instantiate2, Node as Node2, Prefab as Prefab2, resources as resources2 } from "cc";
@@ -550,12 +550,6 @@ var DebugGame = class {
550
550
  }
551
551
  };
552
552
 
553
- // assets/script/ycsdk/minigame/MiniGame.ts
554
- import { instantiate as instantiate4, Node as Node4, Prefab as Prefab4, resources as resources4, sys as sys6 } from "cc";
555
-
556
- // assets/script/ycsdk/AdTactics.ts
557
- import { sys as sys3 } from "cc";
558
-
559
553
  // assets/script/ycsdk/SDKConfig.ts
560
554
  var sdkconfig = {
561
555
  open: true,
@@ -584,2255 +578,221 @@ var sdkconfig = {
584
578
  customFunc: {}
585
579
  };
586
580
 
587
- // assets/script/ycsdk/AdTactics.ts
588
- var AdTactics = class {
589
- constructor() {
590
- this.bannerIndex = 0;
591
- this.bannerLoaded = [];
592
- this.intersIndex = 0;
593
- this.intersLoaded = [];
594
- this.nativeIndex = 0;
595
- this.nativeLoaded = [];
596
- this.videoIndex = 0;
597
- this.videoLoaded = [];
598
- this.nativeBannerIndex = 0;
599
- this.nativeBanerLoaded = [];
600
- }
601
- onLoad(type) {
602
- console.log("on load: ", type);
603
- this.refreshId(type);
604
- switch (type) {
605
- case "Banner" /* Banner */:
606
- this.bannerLoaded = [];
607
- break;
608
- case "NativeBanner" /* NativeBanner */:
609
- this.nativeBanerLoaded = [];
610
- break;
611
- case "Inters" /* Inters */:
612
- this.intersLoaded = [];
613
- break;
614
- case "Native" /* Native */:
615
- this.nativeLoaded = [];
616
- break;
617
- case "Video" /* Video */:
618
- this.videoLoaded = [];
619
- break;
620
- }
621
- }
622
- onError(type, callBack) {
623
- console.log("on error: ", type);
624
- if (YCSDK.ins.isRun(sys3.Platform.OPPO_MINI_GAME)) {
625
- this.reLoadAd(type, callBack);
626
- }
627
- }
628
- onShow(type) {
629
- console.log("on show: ", type);
630
- }
631
- onClick(type) {
632
- console.log("on click: ", type);
633
- }
634
- onClose(type, callBack) {
635
- console.log("on close: ", type);
636
- }
637
- onReward() {
638
- console.log("on reward");
639
- }
640
- reLoadAd(type, callback) {
641
- console.log("reLoadAd: ", type);
642
- switch (type) {
643
- case "Banner" /* Banner */:
644
- this.reshowBanner();
645
- break;
646
- case "NativeBanner" /* NativeBanner */:
647
- this.reshowNativeBanner();
648
- break;
649
- case "Inters" /* Inters */:
650
- this.reshowInterstitial();
651
- break;
652
- case "Native" /* Native */:
653
- this.reshowNative();
654
- break;
655
- case "Video" /* Video */:
656
- this.reshowVideo(callback);
657
- break;
658
- }
659
- }
660
- reshowBanner() {
661
- const length = sdkconfig.bannerId.length;
662
- if (length == 0 || length == 1) {
663
- console.log("re show banner need more than 1 id");
664
- return;
665
- }
666
- if (this.bannerLoaded.includes(sdkconfig.ycBannerId)) {
667
- console.log("reshowBanner1: ", sdkconfig.ycBannerId, " already loaded");
668
- this.bannerLoaded = [];
669
- return;
670
- }
671
- this.bannerLoaded.push(sdkconfig.ycBannerId);
672
- this.refreshId("Banner" /* Banner */);
673
- if (this.bannerLoaded.includes(sdkconfig.ycBannerId)) {
674
- console.log("reshowBanner2: ", sdkconfig.ycBannerId, " already loaded");
675
- this.bannerLoaded = [];
676
- return;
677
- }
678
- YCSDK.ins.showBanner();
679
- }
680
- reshowNativeBanner() {
681
- const length = sdkconfig.nativeBannerId.length;
682
- if (length == 0 || length == 1) {
683
- console.log("re show native banner need more than 1 id");
684
- return;
685
- }
686
- if (this.nativeBanerLoaded.includes(sdkconfig.ycNativeBannerId)) {
687
- console.log("reshow native Banner1: ", sdkconfig.ycNativeBannerId, " already loaded");
688
- this.nativeBanerLoaded = [];
689
- return;
690
- }
691
- this.nativeBanerLoaded.push(sdkconfig.ycNativeBannerId);
692
- this.refreshId("Banner" /* Banner */);
693
- if (this.nativeBanerLoaded.includes(sdkconfig.ycNativeBannerId)) {
694
- console.log("reshow native Banner2: ", sdkconfig.ycNativeBannerId, " already loaded");
695
- this.nativeBanerLoaded = [];
696
- return;
697
- }
698
- YCSDK.ins.showBanner("Native" /* Native */);
699
- }
700
- reshowNative() {
701
- const length = sdkconfig.nativeId.length;
702
- if (length == 0 || length == 1) {
703
- console.log("re show native need more than 1 id");
704
- return;
705
- }
706
- if (this.nativeLoaded.includes(sdkconfig.ycNativeId)) {
707
- console.log("reshowNative1: ", sdkconfig.ycNativeId, " already loaded");
708
- this.nativeLoaded = [];
709
- return;
710
- }
711
- this.nativeLoaded.push(sdkconfig.ycNativeId);
712
- this.refreshId("Native" /* Native */);
713
- if (this.nativeLoaded.includes(sdkconfig.ycNativeId)) {
714
- console.log("reshowNative2: ", sdkconfig.ycNativeId, " already loaded");
715
- this.nativeLoaded = [];
716
- return;
717
- }
718
- YCSDK.ins.showInters("Native" /* Native */);
719
- }
720
- reshowInterstitial() {
721
- const length = sdkconfig.intersId.length;
722
- if (length == 0 || length == 1) {
723
- console.log("re show inters need more than 1 id");
724
- return;
725
- }
726
- if (this.intersLoaded.includes(sdkconfig.ycIntersId)) {
727
- console.log("reshowInterstitial1: ", sdkconfig.ycIntersId, " already loaded");
728
- this.intersLoaded = [];
729
- return;
730
- }
731
- this.intersLoaded.push(sdkconfig.ycIntersId);
732
- this.refreshId("Inters" /* Inters */);
733
- if (this.intersLoaded.includes(sdkconfig.ycIntersId)) {
734
- console.log("reshowInterstitial2: ", sdkconfig.ycIntersId, " already loaded");
735
- this.intersLoaded = [];
736
- return;
737
- }
738
- YCSDK.ins.showInters("Initial" /* Initial */);
739
- }
740
- reshowVideo(callback) {
741
- const length = sdkconfig.videoId.length;
742
- if (length == 0 || length == 1) {
743
- console.log("re show video need more than 1 id");
744
- callback && callback(false);
745
- return;
746
- }
747
- if (this.videoLoaded.includes(sdkconfig.ycVideoId)) {
748
- console.log("reshowVideo1: ", sdkconfig.ycVideoId, " already loaded");
749
- callback && callback(false);
750
- this.videoLoaded = [];
751
- return;
752
- }
753
- this.videoLoaded.push(sdkconfig.ycVideoId);
754
- this.refreshId("Video" /* Video */);
755
- if (this.videoLoaded.includes(sdkconfig.ycVideoId)) {
756
- console.log("reshowVideo2: ", sdkconfig.ycVideoId, " already loaded");
757
- callback && callback(false);
758
- this.videoLoaded = [];
759
- return;
760
- }
761
- YCSDK.ins.showVideo(callback);
762
- }
763
- refreshAll() {
764
- const keys = Object.keys(AdType);
765
- for (const type of keys) {
766
- this.refreshId(type);
767
- }
768
- console.log("refreshAll");
769
- }
770
- checkBannerId() {
771
- var id = sdkconfig.bannerId;
772
- if (!id) {
773
- console.log("bannerId is not config");
774
- return;
775
- }
776
- if (!Array.isArray(id)) {
777
- console.log("bannerId is only one");
778
- sdkconfig.ycBannerId = id;
779
- return;
780
- }
781
- if (id.length == 1) {
782
- if (!id[0]) {
783
- console.log("id[0] config is empty string");
784
- return;
785
- }
786
- sdkconfig.ycBannerId = id[0];
787
- return;
788
- }
789
- if (id.length == 0) {
790
- console.log("bannerId config is empty");
791
- return;
792
- }
793
- sdkconfig.ycBannerId = id[this.bannerIndex];
794
- this.bannerIndex += 1;
795
- if (this.bannerIndex >= id.length) {
796
- this.bannerIndex = 0;
797
- }
798
- }
799
- checkNativeBannerId() {
800
- var id = sdkconfig.nativeBannerId;
801
- if (!id) {
802
- console.log("native banner id is not config");
803
- return;
804
- }
805
- if (!Array.isArray(id)) {
806
- console.log("native banner id is only one");
807
- sdkconfig.ycNativeBannerId = id;
808
- return;
809
- }
810
- if (id.length == 1) {
811
- if (!id[0]) {
812
- console.log("id[0] config is empty string");
813
- return;
814
- }
815
- sdkconfig.ycNativeBannerId = id[0];
816
- return;
817
- }
818
- if (id.length == 0) {
819
- console.log("native banner id config is empty");
820
- return;
821
- }
822
- sdkconfig.ycNativeBannerId = id[this.nativeBannerIndex];
823
- this.nativeBannerIndex += 1;
824
- if (this.nativeBannerIndex >= id.length) {
825
- this.nativeBannerIndex = 0;
826
- }
827
- }
828
- checkIntersId() {
829
- var id = sdkconfig.intersId;
830
- if (!id) {
831
- console.log("intersId is not config");
832
- return;
833
- }
834
- if (!Array.isArray(id)) {
835
- console.log("intersId is only one");
836
- sdkconfig.ycIntersId = id;
837
- return;
838
- }
839
- if (id.length == 1) {
840
- if (!id[0]) {
841
- console.log("id[0] config is empty string");
842
- return;
843
- }
844
- sdkconfig.ycIntersId = id[0];
845
- return;
846
- }
847
- if (id.length == 0) {
848
- console.log("intersId config is empty");
849
- return;
850
- }
851
- sdkconfig.ycIntersId = id[this.intersIndex];
852
- this.intersIndex += 1;
853
- if (this.intersIndex >= id.length) {
854
- this.intersIndex = 0;
855
- }
856
- }
857
- checkNativeId() {
858
- var id = sdkconfig.nativeId;
859
- if (!id) {
860
- console.log("nativeId is not config");
861
- return;
862
- }
863
- if (!Array.isArray(id)) {
864
- console.log("nativeId is only one");
865
- sdkconfig.ycNativeId = id;
866
- return;
867
- }
868
- if (id.length == 1) {
869
- if (!id[0]) {
870
- console.log("id[0] config is empty string");
871
- return;
872
- }
873
- sdkconfig.ycNativeId = id[0];
874
- return;
875
- }
876
- if (id.length == 0) {
877
- console.log("nativeId config is empty");
878
- return;
879
- }
880
- sdkconfig.ycNativeId = id[this.nativeIndex];
881
- this.nativeIndex += 1;
882
- if (this.nativeIndex >= id.length) {
883
- this.nativeIndex = 0;
884
- }
885
- }
886
- checkVideoId() {
887
- var id = sdkconfig.videoId;
888
- if (!id) {
889
- console.log("videoId is not config");
890
- return;
891
- }
892
- if (!Array.isArray(id)) {
893
- console.log("videoId is only one");
894
- sdkconfig.ycVideoId = id;
895
- return;
896
- }
897
- if (id.length == 1) {
898
- console.log("videoId length is 1");
899
- if (!id[0]) {
900
- console.log("id[0] config is empty string");
901
- return;
902
- }
903
- sdkconfig.ycVideoId = id[0];
904
- return;
905
- }
906
- if (id.length == 0) {
907
- console.log("videoId config is empty");
908
- return;
909
- }
910
- sdkconfig.ycVideoId = id[this.videoIndex];
911
- this.videoIndex += 1;
912
- if (this.videoIndex >= id.length) {
913
- this.videoIndex = 0;
914
- }
915
- }
916
- refreshId(type) {
917
- console.log("refresh id, type: ", type);
918
- switch (type) {
919
- case "Banner" /* Banner */:
920
- this.checkBannerId();
921
- break;
922
- case "NativeBanner" /* NativeBanner */:
923
- this.checkNativeBannerId();
924
- break;
925
- case "Inters" /* Inters */:
926
- this.checkIntersId();
927
- break;
928
- case "Native" /* Native */:
929
- this.checkNativeId();
930
- break;
931
- case "Video" /* Video */:
932
- this.checkVideoId();
933
- break;
934
- }
935
- }
936
- random(max) {
937
- max = Math.floor(max);
938
- return Math.floor(Math.random() * max);
939
- }
940
- };
941
-
942
- // assets/script/ycsdk/minigame/douyin/DouYinGame.ts
943
- var DouYinGame = class {
581
+ // assets/script/ycsdk/nativegame/anroid/AndroidGame.ts
582
+ var AndroidGame = class {
944
583
  constructor() {
945
- this.bannerAd = null;
946
- this.videoAd = null;
947
- this.callBack = null;
584
+ this.className = "com/ycsdk/cocos/GameBridge";
948
585
  }
949
- init() {
950
- this.initViedoAd(false);
586
+ init(callBack) {
587
+ callBack && callBack();
588
+ this.login();
951
589
  }
952
590
  login(callBack) {
591
+ jsb.reflection.callStaticMethod(this.className, "login", "()V");
953
592
  }
954
- pay(params, callBack) {
955
- }
956
- showBanner(position) {
957
- if (!sdkconfig.open) {
958
- console.log("\u5E7F\u544A\u672A\u5F00\u542F");
959
- return;
960
- }
961
- this.hideBanner();
962
- this.bannerAd = window["tt"].createBannerAd({
963
- adUnitId: sdkconfig.ycBannerId
964
- });
965
- this.bannerAd.onLoad(() => {
966
- YCSDK.ins.onLoad("Banner" /* Banner */);
967
- this.bannerAd.show().then(() => {
968
- YCSDK.ins.onShow("Banner" /* Banner */);
969
- console.log("\u5E7F\u544A\u663E\u793A\u6210\u529F");
970
- }).catch((err) => {
971
- YCSDK.ins.onError("Banner" /* Banner */);
972
- console.log("\u5E7F\u544A\u7EC4\u4EF6\u51FA\u73B0\u95EE\u9898", err);
973
- });
974
- });
975
- this.bannerAd.onError(({ errorCode, errMsg }) => {
976
- YCSDK.ins.onError("Banner" /* Banner */);
977
- console.log(errorCode, errMsg);
978
- });
979
- }
980
- hideBanner() {
981
- if (this.bannerAd) {
982
- this.bannerAd.hide();
983
- this.bannerAd.destroy();
984
- this.bannerAd = null;
985
- }
986
- }
987
- showInters(type) {
988
- const interstitialAd = window["tt"].createInterstitialAd({
989
- adUnitId: sdkconfig.ycIntersId
990
- });
991
- interstitialAd.onLoad(() => {
992
- YCSDK.ins.onLoad("Inters" /* Inters */);
993
- console.log("interstitialAd load");
994
- });
995
- interstitialAd.onError(({ errCode, errMsg }) => {
996
- YCSDK.ins.onError("Inters" /* Inters */);
997
- console.log("\u76D1\u542C\u5230\u9519\u8BEF", errCode, errMsg);
998
- });
999
- interstitialAd.load().then(() => {
1000
- interstitialAd.show().then(() => {
1001
- YCSDK.ins.onShow("Inters" /* Inters */);
1002
- console.log("\u63D2\u5C4F\u5E7F\u544A\u5C55\u793A\u6210\u529F");
1003
- });
1004
- }).catch((err) => {
1005
- YCSDK.ins.onError("Inters" /* Inters */);
1006
- console.log(err);
1007
- });
1008
- }
1009
- hideInters(type) {
1010
- }
1011
- initViedoAd(show) {
1012
- this.videoAd = window["tt"].createRewardedVideoAd({
1013
- adUnitId: sdkconfig.ycVideoId
1014
- });
1015
- this.videoAd.onLoad(() => {
1016
- YCSDK.ins.onLoad("Video" /* Video */);
1017
- console.log("\u5E7F\u544A\u52A0\u8F7D\u5B8C\u6210");
1018
- });
1019
- this.videoAd.onError((errMsg) => {
1020
- YCSDK.ins.onError("Video" /* Video */);
1021
- console.log("\u5E7F\u544A\u52A0\u8F7D\u5931\u8D25", errMsg);
1022
- });
1023
- this.videoAd.onClose((res) => {
1024
- if (res && res.isEnded || res === void 0) {
1025
- console.log("\u5E7F\u544A\u64AD\u653E\u5B8C\u6210");
1026
- this.callBack && this.callBack(true);
1027
- } else {
1028
- console.log("\u5E7F\u544A\u64AD\u653E\u672A\u5B8C\u6210");
1029
- this.callBack && this.callBack(false);
1030
- }
1031
- });
1032
- if (show) {
1033
- this.videoAd.load().then(() => {
1034
- this.videoAd.show().then(() => {
1035
- YCSDK.ins.onShow("Video" /* Video */);
1036
- console.log("\u6FC0\u52B1\u89C6\u9891\u5E7F\u544A\u5C55\u793A\u6210\u529F");
1037
- }).catch((err) => {
1038
- YCSDK.ins.onError("Video" /* Video */);
1039
- console.log("\u6FC0\u52B1\u89C6\u9891\u5E7F\u544A\u5C55\u793A\u5931\u8D25", err);
1040
- });
1041
- });
1042
- } else {
1043
- this.videoAd.load();
1044
- }
1045
- }
1046
- showVideo(callBack) {
1047
- this.callBack = callBack;
1048
- if (!sdkconfig.ycVideoId) {
1049
- console.log("\u8BF7\u914D\u7F6E\u6FC0\u52B1\u89C6\u9891\u5E7F\u544AID");
1050
- callBack && callBack(false);
1051
- YCSDK.ins.onError("Video" /* Video */);
1052
- return false;
1053
- }
1054
- if (this.videoAd) {
1055
- this.videoAd.show().then(() => {
1056
- YCSDK.ins.onShow("Video" /* Video */);
1057
- console.log("\u6FC0\u52B1\u89C6\u9891\u5E7F\u544A\u5C55\u793A\u6210\u529F");
1058
- }).catch((err) => {
1059
- YCSDK.ins.onError("Video" /* Video */);
1060
- console.log("\u6FC0\u52B1\u89C6\u9891\u5E7F\u544A\u5C55\u793A\u5931\u8D25", err);
1061
- });
1062
- return true;
1063
- }
1064
- this.initViedoAd(true);
1065
- return false;
1066
- }
1067
- customFunc(methodName, params, callBack) {
1068
- }
1069
- };
1070
-
1071
- // assets/script/ycsdk/minigame/HttpRequest.ts
1072
- var HttpRequest = class _HttpRequest {
1073
- static {
1074
- this.AUTHORIZATION = "Authorization";
1075
- }
1076
- static {
1077
- this.CONTENT_TYPE = "Content-Type";
1078
- }
1079
- static {
1080
- this.Accept = "Accept";
1081
- }
1082
- static get() {
1083
- if (!_HttpRequest.instance) {
1084
- _HttpRequest.instance = new _HttpRequest();
1085
- }
1086
- return _HttpRequest.instance;
1087
- }
1088
- requestPostx3w(url, data, callback, head) {
1089
- console.log("HttpRequest url:", url);
1090
- console.log("HttpRequest data:", JSON.stringify(data));
1091
- this.httpRequest = new XMLHttpRequest();
1092
- this.httpRequest.onreadystatechange = function() {
1093
- console.log("HttpRequest", "onreadystatechange:", this.readyState, this.status);
1094
- if (this.readyState == 4 && this.status == 200) {
1095
- let res = JSON.parse(this.responseText);
1096
- console.log("HttpRequest", "response:", JSON.stringify(res));
1097
- if (res.status == 200) {
1098
- callback(true, res.data);
1099
- } else {
1100
- callback(false, res);
1101
- }
1102
- }
1103
- };
1104
- this.httpRequest.timeout = 5e3;
1105
- this.httpRequest.ontimeout = () => {
1106
- console.log("HttpRequest:", "request time out", url);
1107
- callback(false);
1108
- };
1109
- this.httpRequest.onerror = function(e) {
1110
- console.log("HttpRequest", url, " request error", JSON.stringify(e));
1111
- callback(false);
1112
- };
1113
- this.httpRequest.open("POST", url, true);
1114
- this.httpRequest.setRequestHeader(_HttpRequest.CONTENT_TYPE, "application/x-www-form-urlencoded" /* APPLICATION_X_WWW_FORM_URLENCODED */);
1115
- if (head) {
1116
- this.httpRequest.setRequestHeader(_HttpRequest.AUTHORIZATION, head);
1117
- }
1118
- this.httpRequest.send(data);
1119
- }
1120
- requestGetx3w(url, data, callback, head) {
1121
- console.log("HttpRequest url:", url);
1122
- console.log("HttpRequest data:", JSON.stringify(data));
1123
- this.httpRequest = new XMLHttpRequest();
1124
- this.httpRequest.onreadystatechange = function() {
1125
- if (this.readyState == 4 && this.status == 200) {
1126
- let response = this.responseText.replace(/:s*([0-9]{15,})s*(,?)/g, ': "$1" $2');
1127
- let res = JSON.parse(response);
1128
- console.log("HttpRequest", "response:", JSON.stringify(res));
1129
- if (res.status == 200) {
1130
- callback(true, res.data);
1131
- } else {
1132
- callback(false, res);
1133
- }
1134
- }
1135
- };
1136
- this.httpRequest.timeout = 5e3;
1137
- this.httpRequest.ontimeout = () => {
1138
- console.log("HttpRequest:", "request time out", url);
1139
- callback(false);
1140
- };
1141
- this.httpRequest.onerror = function(e) {
1142
- console.log("HttpRequest", url, " request error", JSON.stringify(e));
1143
- callback(false);
1144
- };
1145
- this.httpRequest.open("GET", url, true);
1146
- this.httpRequest.setRequestHeader(_HttpRequest.CONTENT_TYPE, "application/x-www-form-urlencoded" /* APPLICATION_X_WWW_FORM_URLENCODED */);
1147
- if (head) {
1148
- this.httpRequest.setRequestHeader(_HttpRequest.AUTHORIZATION, head);
1149
- }
1150
- this.httpRequest.send(data);
1151
- }
1152
- requestPostjson(url, data, callback, head) {
1153
- console.log("HttpRequest url:", url);
1154
- this.httpRequest = new XMLHttpRequest();
1155
- this.httpRequest.onreadystatechange = function() {
1156
- if (this.readyState == 4 && this.status == 200) {
1157
- let res = JSON.parse(this.responseText);
1158
- console.log("HttpRequest", "response:", JSON.stringify(res));
1159
- if (res.code == 0) {
1160
- callback(true, res.data.config);
1161
- } else {
1162
- callback(false, res);
1163
- }
1164
- }
1165
- };
1166
- this.httpRequest.timeout = 3e3;
1167
- this.httpRequest.ontimeout = () => {
1168
- console.log("HttpRequest:", "request time out", url);
1169
- callback(false);
1170
- };
1171
- this.httpRequest.onerror = function(e) {
1172
- console.log("HttpRequest", url, " request error", JSON.stringify(e));
1173
- callback(false);
1174
- };
1175
- this.httpRequest.open("POST", url, true);
1176
- this.httpRequest.setRequestHeader(_HttpRequest.Accept, "application/json" /* APPLICATION_JSON */);
1177
- this.httpRequest.setRequestHeader(_HttpRequest.CONTENT_TYPE, "application/json" /* APPLICATION_JSON */);
1178
- this.httpRequest.send(JSON.stringify(data));
1179
- }
1180
- };
1181
-
1182
- // assets/script/ycsdk/minigame/huawei/HuaWeiGame.ts
1183
- import { assetManager, instantiate as instantiate3, Label, Node as Node3, Prefab as Prefab3, resources as resources3, Sprite, SpriteFrame, Texture2D } from "cc";
1184
- var HuaWeiGame = class {
1185
- constructor() {
1186
- this.qg = window["qg"];
1187
- }
1188
- hideInters(type) {
1189
- }
1190
- customFunc(methodName, params, callBack) {
1191
- }
1192
- init(callBack) {
1193
- callBack && callBack();
1194
- this.loadVideo(this.callback);
1195
- }
1196
- login(callBack) {
1197
- this.qg.gameLoginWithReal({
1198
- forceLogin: 1,
1199
- appid: sdkconfig.appId,
1200
- success: function(data) {
1201
- callBack && callBack(true);
1202
- console.log(" game login with real success:" + JSON.stringify(data));
1203
- },
1204
- fail: function(data, code) {
1205
- console.log("game login with real fail:" + data + ", code:" + code);
1206
- if (code == 7004 || code == 2012) {
1207
- console.log("\u73A9\u5BB6\u53D6\u6D88\u767B\u5F55\uFF0C\u8FD4\u56DE\u6E38\u620F\u754C\u9762\u8BA9\u73A9\u5BB6\u91CD\u65B0\u767B\u5F55\u3002");
1208
- callBack && callBack(false, 7004);
1209
- }
1210
- if (code == 7021) {
1211
- callBack && callBack(false, 7021);
1212
- console.log("\u73A9\u5BB6\u53D6\u6D88\u5B9E\u540D\u8BA4\u8BC1\uFF0C\u7981\u6B62\u8FDB\u5165\u6E38\u620F");
1213
- }
1214
- }
1215
- });
1216
- }
1217
- pay(params, callBack) {
1218
- }
1219
- createPurchaseIntent(params, callBack) {
1220
- }
1221
- doCheck(content, sign, publicKey) {
1222
- if (!sign || !publicKey) {
1223
- return false;
1224
- }
1225
- }
1226
- consumeOwnedPurchase() {
1227
- }
1228
- showBanner(position) {
1229
- if (!sdkconfig.ycBannerId) {
1230
- console.log("banner\u5E7F\u544A\u53C2\u6570\u6CA1\u6709\u914D\u7F6E");
1231
- return;
1232
- }
1233
- this.hideBanner();
1234
- if (this.bannerAd) {
1235
- this.bannerAd.destroy();
1236
- this.bannerAd = null;
1237
- }
1238
- var sysInfo = this.qg.getSystemInfoSync();
1239
- var bannerTop = sysInfo.safeArea.height;
1240
- this.bannerAd = this.qg.createBannerAd({
1241
- adUnitId: sdkconfig.ycBannerId,
1242
- adIntervals: 35,
1243
- //刷新时间
1244
- style: {
1245
- top: bannerTop - 20,
1246
- left: 0,
1247
- height: 57,
1248
- width: 360
1249
- }
1250
- });
1251
- this.bannerAd.onError((err) => {
1252
- console.log("huawei banner error: ", JSON.stringify(err));
1253
- if (this.bannerAd) {
1254
- this.bannerAd.destroy();
1255
- this.bannerAd = null;
1256
- }
1257
- YCSDK.ins.onError("Banner" /* Banner */);
1258
- });
1259
- this.bannerAd.onLoad(() => {
1260
- console.log("huawei banner on load");
1261
- YCSDK.ins.onLoad("Banner" /* Banner */);
1262
- YCSDK.ins.onShow("Banner" /* Banner */);
1263
- });
1264
- this.bannerAd.onClose(() => {
1265
- console.log("huawei banner on close");
1266
- if (this.bannerAd) {
1267
- this.bannerAd.destroy();
1268
- this.bannerAd = null;
1269
- }
1270
- YCSDK.ins.onClose("Banner" /* Banner */);
1271
- });
1272
- setTimeout(() => {
1273
- this.bannerAd.show();
1274
- }, 1e3);
1275
- }
1276
- hideBanner() {
1277
- if (!this.bannerAd) {
1278
- console.log("huawei banner ad is hide");
1279
- return;
1280
- }
1281
- this.bannerAd.hide();
1282
- }
1283
- showInters(type = "Initial" /* Initial */) {
1284
- if (!type) {
1285
- let odds = YCSDK.ins.random(100);
1286
- if (odds >= 50 && sdkconfig.intersId.length >= 1) {
1287
- this.showIntersVideo();
1288
- } else if (sdkconfig.nativeId.length >= 1) {
1289
- this.showNative();
1290
- } else {
1291
- this.showIntersVideo();
1292
- }
1293
- return;
1294
- }
1295
- switch (type) {
1296
- case "Initial" /* Initial */:
1297
- case "Video" /* Video */:
1298
- this.showIntersVideo();
1299
- break;
1300
- case "Native" /* Native */:
1301
- this.showNative();
1302
- break;
1303
- }
1304
- }
1305
- showNative() {
1306
- if (!sdkconfig.ycNativeId) {
1307
- console.log("\u539F\u751F\u6A21\u677F\u5E7F\u544A\u53C2\u6570\u6CA1\u6709\u914D\u7F6E");
1308
- return;
1309
- }
1310
- let nativeAd = this.qg.createNativeAd({
1311
- adUnitId: sdkconfig.ycNativeId,
1312
- success: (code) => {
1313
- console.log("loadNativeAd success: ", code);
1314
- },
1315
- fail: (data, code) => {
1316
- console.log("loadNativeAd fail: " + data + "," + code);
1317
- nativeAd.destroy();
1318
- }
1319
- });
1320
- nativeAd.offLoad();
1321
- nativeAd.onLoad((data) => {
1322
- YCSDK.ins.onLoad("Native" /* Native */);
1323
- let ad = data.adList[0];
1324
- this.renderNative(ad, nativeAd);
1325
- });
1326
- nativeAd.offError();
1327
- nativeAd.onError((e) => {
1328
- console.error("load ad error:" + JSON.stringify(e));
1329
- nativeAd.destroy();
1330
- YCSDK.ins.onError("Native" /* Native */);
1331
- });
1332
- nativeAd.load();
1333
- }
1334
- // appName: 百度极速版
1335
- // developerName: 百度在线网络技术(北京)有限公司
1336
- // versionName: 6.55.0.10
1337
- // privacyUrl: https://h5hosting-drcn.dbankcdn.cn/cch5/PPS/ssp-privacy-url/index.html?src=https%3A%2F%2Fs.bdstatic.com%2Fcommon%2Fagreement%2Fprivacy_new_lite.html
1338
- // permissionUrl: https://appgallery.huawei.com/open/permission?packageName=com.baidu.searchbox.lite&mediaPackageName=com.tl.lxndwzxyx.huawei
1339
- // appDetailUrl: https://appgallery.huawei.com/#/app_simple/C100029965
1340
- // imgUrlList: https://contentcenter-drcn.dbankcdn.cn/img/pub_17/PPS_realtimeimage_100_1/e1/v3/A667xiJZQ7SMM7cmqhmMXw/0Vm6YJiyTH-IloGzbCUO5w.png/__source__.jpg
1341
- // adId: 51790be2-d2c2-48ca-9695-1a55bed81905
1342
- // creativeType: 103
1343
- renderNative(adItem, nativeAd) {
1344
- resources3.load("Privacy/bg", Prefab3, (err, prefab) => {
1345
- if (err) {
1346
- console.error("\u52A0\u8F7DPrefab\u5931\u8D25:", err);
1347
- YCSDK.ins.onError("Native" /* Native */);
1348
- return;
1349
- }
1350
- const node = instantiate3(prefab);
1351
- const native = node.getChildByName("native");
1352
- const close = native.getChildByName("close");
1353
- const title = native.getChildByName("title").getComponent(Label);
1354
- title.string = adItem.appName;
1355
- const source = native.getChildByName("source").getComponent(Label);
1356
- source.string = adItem.source;
1357
- const company = native.getChildByName("company").getComponent(Label);
1358
- company.string = adItem.developerName;
1359
- const pic = native.getChildByName("pic");
1360
- const info = native.getChildByName("info");
1361
- const version = info.getChildByName("verison");
1362
- version.on(Node3.EventType.TOUCH_END, () => {
1363
- console.log("change version");
1364
- version.getComponent(Label).string = adItem.versionName;
1365
- });
1366
- const description = info.getChildByName("description");
1367
- description.on(Node3.EventType.TOUCH_END, () => {
1368
- console.log("open description");
1369
- this.qg.openDeeplink({ uri: adItem.appDetailUrl });
1370
- });
1371
- const privacy = info.getChildByName("privacy");
1372
- privacy.on(Node3.EventType.TOUCH_END, () => {
1373
- console.log("open privacy");
1374
- this.qg.openDeeplink({ uri: adItem.privacyUrl });
1375
- });
1376
- const permission = info.getChildByName("permission");
1377
- permission.on(Node3.EventType.TOUCH_END, () => {
1378
- console.log("open permission");
1379
- this.qg.openDeeplink({ uri: adItem.permissionUrl });
1380
- });
1381
- pic.on(Node3.EventType.TOUCH_END, () => {
1382
- console.log("native click");
1383
- YCSDK.ins.onClick("Native" /* Native */);
1384
- nativeAd.reportAdClick({ adId: adItem.adId });
1385
- });
1386
- close.on(Node3.EventType.TOUCH_END, () => {
1387
- console.log("close native");
1388
- nativeAd.destroy();
1389
- node.destroy();
1390
- YCSDK.ins.getGameNode().removeChild(node);
1391
- nativeAd.hideDownloadButton({
1392
- adId: adItem.adId,
1393
- success: (code) => {
1394
- console.log("hideDownloadButton: success");
1395
- },
1396
- fail: (data, code) => {
1397
- console.log(" hideDownloadButton fail: " + data + "," + code);
1398
- }
1399
- });
1400
- YCSDK.ins.onClose("Native" /* Native */);
1401
- });
1402
- assetManager.loadRemote(adItem.imgUrlList[0], (err2, image) => {
1403
- if (err2) {
1404
- console.error("\u52A0\u8F7D\u8FDC\u7A0B\u56FE\u7247\u5931\u8D25:", err2);
1405
- YCSDK.ins.onError("Native" /* Native */);
1406
- return;
1407
- }
1408
- const texture = new Texture2D();
1409
- texture.image = image;
1410
- let spriteFrame = new SpriteFrame();
1411
- spriteFrame.texture = texture;
1412
- pic.getComponent(Sprite).spriteFrame = spriteFrame;
1413
- YCSDK.ins.getGameNode().addChild(node);
1414
- YCSDK.ins.onShow("Native" /* Native */);
1415
- this.showNativeDownload(adItem, nativeAd, node);
1416
- nativeAd.reportAdShow({ adId: adItem.adId });
1417
- });
1418
- });
1419
- }
1420
- showNativeDownload(adItem, nativeAd, node) {
1421
- const { screenWidth, screenHeight } = this.qg.getSystemInfoSync();
1422
- console.log(screenWidth);
1423
- console.log(screenHeight);
1424
- nativeAd.showDownloadButton({
1425
- adId: adItem.adId,
1426
- style: {
1427
- left: screenWidth / 2 - screenWidth / 4,
1428
- top: screenHeight * 0.65,
1429
- heightType: "normal",
1430
- width: screenWidth / 2,
1431
- fixedWidth: true,
1432
- textSize: 50,
1433
- horizontalPadding: 50,
1434
- cornerRadius: 22,
1435
- normalTextColor: "#FFFFFF",
1436
- normalBackground: "#5291FF",
1437
- pressedColor: "#0A59F7",
1438
- normalStroke: 5,
1439
- normalStrokeCorlor: "#FF000000",
1440
- processingTextColor: "#5291FF",
1441
- processingBackground: "#0F000000",
1442
- processingColor: "#000000",
1443
- processingStroke: 10,
1444
- processingStrokeCorlor: "#0A59F7",
1445
- installingTextColor: "#000000",
1446
- installingBackground: "#FFFFFF",
1447
- installingStroke: 15,
1448
- installingStrokeCorlor: "#5291FF"
1449
- },
1450
- success: (code) => {
1451
- console.log("showDownloadButton: success");
1452
- },
1453
- fail: (data, code) => {
1454
- console.log("showDownloadButton fail: " + data + "," + code);
1455
- }
1456
- });
1457
- }
1458
- showIntersVideo() {
1459
- if (!sdkconfig.ycIntersId) {
1460
- console.log("\u63D2\u5C4F\u5E7F\u544Aid\u672A\u914D\u7F6E");
1461
- return;
1462
- }
1463
- let interstitialAd = this.qg.createInterstitialAd({
1464
- adUnitId: sdkconfig.ycIntersId
1465
- });
1466
- interstitialAd.onLoad(function(data) {
1467
- YCSDK.ins.onLoad("Inters" /* Inters */);
1468
- console.log("huawei inters onLoad data " + JSON.stringify(data));
1469
- interstitialAd.show();
1470
- YCSDK.ins.onShow("Inters" /* Inters */);
1471
- });
1472
- interstitialAd.onError((err) => {
1473
- interstitialAd.destroy();
1474
- console.log("huawei inters on error: ", JSON.stringify(err));
1475
- YCSDK.ins.onError("Inters" /* Inters */);
1476
- });
1477
- interstitialAd.onClose(() => {
1478
- console.log("huawei interstitialAd closed");
1479
- interstitialAd.destroy();
1480
- YCSDK.ins.onClose("Inters" /* Inters */);
1481
- });
1482
- interstitialAd.load();
1483
- }
1484
- showVideo(callBack) {
1485
- this.callback = callBack;
1486
- let lastCallTime = 0;
1487
- let nowCallTime = (/* @__PURE__ */ new Date()).getTime();
1488
- if (lastCallTime != 0 && nowCallTime - lastCallTime < 400) {
1489
- console.log("show video time too many");
1490
- return;
1491
- }
1492
- lastCallTime = nowCallTime;
1493
- if (this.rewardedVideoAd && this.callback) {
1494
- this.show();
1495
- return;
1496
- }
1497
- this.loadVideo(true);
1498
- return false;
1499
- }
1500
- loadVideo(show) {
1501
- if (!sdkconfig.ycVideoId) {
1502
- console.log("\u6FC0\u52B1\u89C6\u9891\u5E7F\u544A\u53C2\u6570\u6CA1\u6709\u914D\u7F6E");
1503
- this.callback && this.callback(false);
1504
- return;
1505
- }
1506
- this.rewardedVideoAd = this.qg.createRewardedVideoAd({
1507
- adUnitId: sdkconfig.ycVideoId,
1508
- success: (code) => {
1509
- console.log("loadVideoAd createRewardedVideoAd success" + code);
1510
- },
1511
- fail: (data, code) => {
1512
- console.log("loadVideoAd createRewardedVideoAd fail: " + data + "," + code);
1513
- }
1514
- });
1515
- this.rewardedVideoAd.onLoad(() => {
1516
- console.log("loadVideoAd: ad loaded.");
1517
- YCSDK.ins.onLoad("Video" /* Video */);
1518
- if (show) {
1519
- this.show();
1520
- }
1521
- });
1522
- this.rewardedVideoAd.onError((e) => {
1523
- console.error("load ad error:" + JSON.stringify(e));
1524
- this.callback && this.callback(false);
1525
- YCSDK.ins.onError("Video" /* Video */, this.callback);
1526
- });
1527
- this.rewardedVideoAd.onClose((res) => {
1528
- console.log("ad onClose: " + res.isEnded);
1529
- YCSDK.ins.onClose("Video" /* Video */);
1530
- if (res && res.isEnded || res === void 0) {
1531
- console.log("\u64AD\u653E\u6FC0\u52B1\u89C6\u9891\u7ED3\u675F\uFF0C\u7ED9\u4E88\u5956\u52B1");
1532
- this.callback && this.callback(true);
1533
- YCSDK.ins.onReward();
1534
- } else {
1535
- this.callback && this.callback(false);
1536
- console.log("\u64AD\u653E\u6CA1\u7ED3\u675F\uFF0C\u4E0D\u7ED9\u4E88\u5956\u52B1");
1537
- }
1538
- this.rewardedVideoAd.load();
1539
- });
1540
- this.rewardedVideoAd.load();
1541
- }
1542
- show() {
1543
- if (this.rewardedVideoAd) {
1544
- this.rewardedVideoAd.show();
1545
- YCSDK.ins.onShow("Video" /* Video */);
1546
- }
1547
- }
1548
- };
1549
-
1550
- // assets/script/ycsdk/minigame/oppo/OppoGame.ts
1551
- var OppoGame = class {
1552
- constructor() {
1553
- this.qg = window["qg"];
1554
- this.count = 0;
1555
- console.log("current channel is oppo");
1556
- }
1557
- init(callback, adconfig, config) {
1558
- if (sdkconfig.subornUserTest) {
1559
- sdkconfig.subornUser = true;
1560
- this.configVideo(adconfig);
1561
- this.configNative(config);
1562
- callback && callback();
1563
- return;
1564
- }
1565
- let info = this.qg.getEnterOptionsSync();
1566
- console.log("oppo init: ", info);
1567
- if (info) {
1568
- let type = info.type;
1569
- let query = info.query;
1570
- let referrerInfo = info.referrerInfo;
1571
- if (query && query.key1 && query.key2) {
1572
- sdkconfig.subornUser = true;
1573
- this.configVideo(adconfig);
1574
- this.configNative(config);
1575
- }
1576
- }
1577
- callback && callback();
1578
- }
1579
- configNative(config) {
1580
- if (!config.switch) {
1581
- return;
1582
- }
1583
- if (config.loop > 0) {
1584
- setInterval(() => {
1585
- this.showInters(config.type == 0 ? "Initial" /* Initial */ : "Native" /* Native */);
1586
- }, config.loop * 1e3);
1587
- }
1588
- }
1589
- configVideo(adconfig) {
1590
- if (!adconfig.switch) {
1591
- return;
1592
- }
1593
- if (adconfig.delay > 0) {
1594
- setTimeout(() => {
1595
- this.loadVideoAdNoCallBack(adconfig.count);
1596
- }, adconfig.delay * 1e3);
1597
- return;
1598
- }
1599
- this.loadVideoAdNoCallBack(adconfig.count);
1600
- }
1601
- login(callBack) {
1602
- }
1603
- pay(params, callBack) {
1604
- }
1605
- showBanner(position = "Bottom" /* Bottom */) {
1606
- if (!sdkconfig.ycBannerId) {
1607
- console.log("banner\u5E7F\u544A\u53C2\u6570\u6CA1\u6709\u914D\u7F6E");
1608
- return;
1609
- }
1610
- if (position == "Native" /* Native */) {
1611
- this.showNativeBanner();
1612
- return;
1613
- }
1614
- this.hideBanner();
1615
- this.createBannerAd(position);
1616
- }
1617
- createBannerAd(position) {
1618
- if (this.bannerAd) {
1619
- this.bannerAd.destroy();
1620
- this.bannerAd = null;
1621
- }
1622
- this.bannerAd = this.qg.createBannerAd({ adUnitId: sdkconfig.ycBannerId });
1623
- this.bannerAd.onResize((obj) => {
1624
- console.log("banner \u5BBD\u5EA6\uFF1A" + obj.width + ", banner \u9AD8\u5EA6\uFF1A" + obj.height);
1625
- });
1626
- this.bannerAd.onLoad(() => {
1627
- console.log("[Banner\u5E7F\u544A] \u5E7F\u544A\u52A0\u8F7D\u6210\u529F");
1628
- YCSDK.ins.onLoad("Banner" /* Banner */);
1629
- YCSDK.ins.onShow("Banner" /* Banner */);
1630
- });
1631
- this.bannerAd.onHide(() => {
1632
- console.log("banner\u5E7F\u544A\u9690\u85CF");
1633
- YCSDK.ins.onClose("Banner" /* Banner */);
1634
- if (this.bannerAd) {
1635
- this.bannerAd.destroy();
1636
- this.bannerAd = null;
1637
- }
1638
- });
1639
- this.bannerAd.onError((err) => {
1640
- console.log("banner\u9519\u8BEF\u76D1\u542C: ", JSON.stringify(err));
1641
- if (this.bannerAd) {
1642
- this.bannerAd.destroy();
1643
- this.bannerAd = null;
1644
- }
1645
- if (!sdkconfig.nativeBannerId || sdkconfig.nativeBannerId.length <= 0) {
1646
- YCSDK.ins.onError("Banner" /* Banner */);
1647
- return;
1648
- }
1649
- YCSDK.ins.onLoad("Banner" /* Banner */);
1650
- this.showNativeBanner();
1651
- });
1652
- this.bannerAd.onClick((obj) => {
1653
- console.log(`\u5F00\u542FBanner\u5E7F\u544A\u70B9\u51FB\u56DE\u8C03: code: ${obj.code},msg: '${obj.msg}'`);
1654
- });
1655
- this.bannerAd.show();
1656
- }
1657
- hideBanner() {
1658
- console.log("oppo hide banner");
1659
- if (this.bannerAd) {
1660
- this.bannerAd.hide();
1661
- }
1662
- }
1663
- showInters(type = "Initial" /* Initial */) {
1664
- if (!type) {
1665
- this.showInitialType();
1666
- return;
1667
- }
1668
- switch (type) {
1669
- case "Initial" /* Initial */:
1670
- this.showInitialType();
1671
- break;
1672
- case "Native" /* Native */:
1673
- this.showNativeType();
1674
- break;
1675
- case "Video" /* Video */:
1676
- this.showVideo(() => {
1677
- console.log("oppo video ad show success");
1678
- });
1679
- break;
1680
- }
1681
- }
1682
- showInitialType() {
1683
- if (!sdkconfig.ycIntersId) {
1684
- console.log("\u63D2\u5C4F\u5E7F\u544Aid\u672A\u914D\u7F6E");
1685
- return;
1686
- }
1687
- if (this.qg.getSystemInfoSync().platformVersionCode < 1061) {
1688
- console.log("\u5FEB\u5E94\u7528\u5E73\u53F0\u7248\u672C\u53F7\u4F4E\u4E8E1061,\u6682\u4E0D\u652F\u6301\u63D2\u5C4F\u5E7F\u544A\u76F8\u5173 API");
1689
- return;
1690
- }
1691
- var interstitialAd = this.qg.createInterstitialAd({
1692
- adUnitId: sdkconfig.ycIntersId
1693
- });
1694
- interstitialAd.onLoad(function() {
1695
- console.log("\u63D2\u5C4F\u5E7F\u544A\u52A0\u8F7D\u6210\u529F");
1696
- YCSDK.ins.onLoad("Inters" /* Inters */);
1697
- interstitialAd.show();
1698
- });
1699
- interstitialAd.onClose(function() {
1700
- console.log("\u63D2\u5C4F\u5E7F\u544A\u5173\u95ED");
1701
- YCSDK.ins.onClose("Inters" /* Inters */);
1702
- });
1703
- interstitialAd.onError(function(err) {
1704
- console.log("\u63D2\u5C4F\u5E7F\u544A\u51FA\u9519: ", err);
1705
- interstitialAd.destroy();
1706
- interstitialAd = null;
1707
- YCSDK.ins.onError("Inters" /* Inters */);
1708
- });
1709
- interstitialAd.load();
1710
- }
1711
- showNativeType() {
1712
- if (!sdkconfig.ycNativeId) {
1713
- console.log("\u539F\u751F\u6A21\u677F\u5E7F\u544A\u53C2\u6570\u6CA1\u6709\u914D\u7F6E");
1714
- return;
1715
- }
1716
- let { windowHeight, windowWidth, platformVersionCode } = this.qg.getSystemInfoSync();
1717
- if (platformVersionCode < 1094) {
1718
- console.log("\u5FEB\u5E94\u7528\u5E73\u53F0\u7248\u672C\u53F7\u4F4E\u4E8E1094,\u6682\u4E0D\u652F\u6301\u539F\u751F\u6A21\u677F\u5E7F\u544A\u76F8\u5173API");
1719
- return;
1720
- }
1721
- if (this.nativeAd) {
1722
- this.nativeAd.destroy();
1723
- this.nativeAd = null;
1724
- }
1725
- let style;
1726
- if (YCSDK.ins.vertical()) {
1727
- style = {
1728
- top: windowHeight * 0.4,
1729
- left: (windowWidth - windowWidth * 0.6) / 2,
1730
- width: windowWidth * 0.6
1731
- };
1732
- } else {
1733
- style = {
1734
- //广告尺寸按4:3计算
1735
- top: (windowHeight - windowWidth * 0.6 * 0.75) / 2,
1736
- left: (windowWidth - windowWidth * 0.6) / 2,
1737
- width: windowWidth * 0.6
1738
- };
1739
- }
1740
- this.nativeAd = this.qg.createCustomAd({
1741
- adUnitId: sdkconfig.ycNativeId,
1742
- style
1743
- });
1744
- this.nativeAd.onLoad(() => {
1745
- console.log("[\u539F\u751F\u6A21\u677F\u5E7F\u544A] \u5E7F\u544A\u52A0\u8F7D\u6210\u529F");
1746
- YCSDK.ins.onLoad("Native" /* Native */);
1747
- });
1748
- this.nativeAd.onClick((obj) => {
1749
- console.log(`\u539F\u751F\u6A21\u677F\u5E7F\u544A\u70B9\u51FB\u56DE\u8C03: code: ${obj.code},msg: '${obj.msg}'`);
1750
- YCSDK.ins.onClick("Native" /* Native */);
1751
- });
1752
- this.nativeAd.onHide(() => {
1753
- console.log("\u539F\u751F\u6A21\u677F\u5E7F\u544A\u9690\u85CF");
1754
- if (this.nativeAd) {
1755
- this.nativeAd.destroy();
1756
- this.nativeAd = null;
1757
- }
1758
- YCSDK.ins.onClose("Native" /* Native */);
1759
- });
1760
- this.nativeAd.onError((err) => {
1761
- console.log("\u539F\u751F\u6A21\u677F\u5E7F\u544A\u9519\u8BEF\u76D1\u542C\uFF1A", JSON.stringify(err));
1762
- if (this.nativeAd) {
1763
- this.nativeAd.destroy();
1764
- this.nativeAd = null;
1765
- }
1766
- YCSDK.ins.onError("Native" /* Native */);
1767
- });
1768
- this.nativeAd.show().then(() => {
1769
- console.log("\u539F\u751F\u6A21\u677F\u5E7F\u544Apromise \u56DE\u8C03\uFF1A\u5C55\u793A\u6210\u529F");
1770
- YCSDK.ins.onShow("Native" /* Native */);
1771
- }).catch((err) => {
1772
- console.log(`\u539F\u751F\u6A21\u677F\u5E7F\u544Apromise \u56DE\u8C03\uFF1A\u5C55\u793A\u5931\u8D25 ${JSON.stringify(err)}`);
1773
- });
1774
- }
1775
- hideInters(type) {
1776
- if (type = "Native" /* Native */) {
1777
- if (!!this.nativeAd) {
1778
- this.nativeAd.hide();
1779
- }
1780
- }
1781
- }
1782
- showVideo(callBack) {
1783
- console.log("oppo video ad start show");
1784
- this.loadVideoAd(callBack);
1785
- return false;
1786
- }
1787
- loadVideoAd(videoCallBack) {
1788
- if (!sdkconfig.ycVideoId) {
1789
- console.log("\u89C6\u9891\u5E7F\u544A\u53C2\u6570\u6CA1\u6709\u914D\u7F6E");
1790
- videoCallBack && videoCallBack(false);
1791
- return;
1792
- }
1793
- let videoAd = this.qg.createRewardedVideoAd({
1794
- adUnitId: sdkconfig.ycVideoId
1795
- });
1796
- videoAd.onLoad(() => {
1797
- console.log("oppo video load success");
1798
- YCSDK.ins.onLoad("Video" /* Video */);
1799
- videoAd.show();
1800
- YCSDK.ins.onShow("Video" /* Video */);
1801
- });
1802
- videoAd.onError((err) => {
1803
- console.log("onError:" + JSON.stringify(err));
1804
- videoAd.destroy();
1805
- YCSDK.ins.onError("Video" /* Video */, videoCallBack);
1806
- });
1807
- videoAd.onClick(function(obj) {
1808
- console.log(`on click: code: ${obj.code}, msg: '${obj.msg}'`);
1809
- YCSDK.ins.onClick("Video" /* Video */);
1810
- });
1811
- videoAd.onClose((res) => {
1812
- YCSDK.ins.onClose("Video" /* Video */);
1813
- console.log("==> oppoRewardVideoAd onClose", res);
1814
- if (res == void 0) {
1815
- videoCallBack && videoCallBack(true);
1816
- YCSDK.ins.onReward();
1817
- } else {
1818
- if (res.isEnded) {
1819
- videoCallBack && videoCallBack(true);
1820
- YCSDK.ins.onReward();
1821
- } else {
1822
- console.log("\u5E7F\u544A\u6CA1\u770B\u5B8C");
1823
- YCSDK.ins.onClose("Video" /* Video */);
1824
- videoCallBack && videoCallBack(false);
1825
- }
1826
- }
1827
- });
1828
- videoAd.load();
1829
- }
1830
- loadVideoAdNoCallBack(adcount = 3) {
1831
- if (!sdkconfig.ycVideoId) {
1832
- console.log("\u89C6\u9891\u5E7F\u544A\u53C2\u6570\u6CA1\u6709\u914D\u7F6E");
1833
- return;
1834
- }
1835
- let videoAd = this.qg.createRewardedVideoAd({
1836
- adUnitId: sdkconfig.ycVideoId
1837
- });
1838
- videoAd.onLoad(() => {
1839
- console.log("oppo video load success");
1840
- videoAd.show();
1841
- });
1842
- videoAd.onError((err) => {
1843
- console.log("onError:" + JSON.stringify(err));
1844
- YCSDK.ins.onError("Video" /* Video */);
1845
- });
1846
- videoAd.onClose((res) => {
1847
- this.count++;
1848
- if (this.count >= adcount) {
1849
- return;
1850
- }
1851
- this.loadVideoAdNoCallBack(adcount);
1852
- });
1853
- videoAd.load();
1854
- YCSDK.ins.onLoad("Video" /* Video */);
1855
- }
1856
- showNativeBanner() {
1857
- if (this.qg.getSystemInfoSync().platformVersionCode < 1144) {
1858
- console.log("\u5FEB\u5E94\u7528\u5E73\u53F0\u7248\u672C\u53F7\u4F4E\u4E8E1144\uFF0C\u6682\u4E0D\u652F\u6301\u539F\u751F2.0\u76F8\u5173API");
1859
- return;
1860
- }
1861
- let { windowHeight, windowWidth } = this.qg.getSystemInfoSync();
1862
- let style = null;
1863
- let bannerHeight = null;
1864
- if (YCSDK.ins.vertical()) {
1865
- bannerHeight = windowWidth / 5;
1866
- style = {
1867
- top: windowHeight - bannerHeight,
1868
- left: 0,
1869
- width: windowWidth,
1870
- height: bannerHeight
1871
- };
1872
- } else {
1873
- bannerHeight = windowHeight / 5;
1874
- style = {
1875
- top: windowHeight - bannerHeight,
1876
- left: (windowWidth - windowHeight) / 2,
1877
- width: windowHeight,
1878
- height: bannerHeight
1879
- };
1880
- }
1881
- let nativeAdvanceAd = this.qg.createNativeAdvanceAd({
1882
- adUnitId: sdkconfig.ycNativeBannerId,
1883
- style
1884
- });
1885
- nativeAdvanceAd.load().then(() => {
1886
- console.log("promise \u56DE\u8C03\uFF1A\u52A0\u8F7D\u6210\u529F");
1887
- }).catch((err) => {
1888
- console.log(`promise \u56DE\u8C03\uFF1A\u52A0\u8F7D\u5931\u8D25 ${JSON.stringify(err)}`);
1889
- });
1890
- nativeAdvanceAd.onLoad(function(res) {
1891
- console.log(`\u539F\u751F\u5E7F\u544A2.0\u52A0\u8F7D\u56DE\u8C03, code: ${res.code}, msg: ${res.msg}, adList:${JSON.stringify(res.adList)}`);
1892
- YCSDK.ins.onLoad("NativeBanner" /* NativeBanner */);
1893
- if (res.code === 0 && res.adList && res.adList.length > 0) {
1894
- let _adId = res.adList[0].adId;
1895
- console.log("\u83B7\u53D6\u5E7F\u544Aid: " + _adId);
1896
- if (_adId) {
1897
- try {
1898
- let nativeAdvanceAdRect = nativeAdvanceAd.createComponent({
1899
- adId: _adId,
1900
- componentType: "Rect",
1901
- style: {
1902
- color: "#FFFFFFFF",
1903
- borderRadius: 20,
1904
- borderWidth: 4,
1905
- borderColor: "#89FFFFFF",
1906
- opacity: 1,
1907
- left: 0,
1908
- top: 0,
1909
- width: windowWidth,
1910
- height: bannerHeight
1911
- }
1912
- });
1913
- console.log(
1914
- "\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 Rect, \u83B7\u53D6\u7EC4\u4EF6ID\uFF1A ",
1915
- nativeAdvanceAdRect.getComponentId()
1916
- );
1917
- } catch (error) {
1918
- console.log("\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 Rect \u5F02\u5E38,\u8BF7\u68C0\u67E5\u53C2\u6570");
1919
- }
1920
- try {
1921
- let nativeAdvanceAdImage = nativeAdvanceAd.createComponent({
1922
- adId: _adId,
1923
- componentType: "AdImage",
1924
- style: {
1925
- imageStyle: "icon",
1926
- width: windowWidth / 5 - 30,
1927
- height: bannerHeight - 30,
1928
- borderRadius: 20,
1929
- left: 15,
1930
- top: 15
1931
- }
1932
- });
1933
- console.log("\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 AdImage, \u83B7\u53D6\u7EC4\u4EF6ID\uFF1A ", nativeAdvanceAdImage.getComponentId());
1934
- } catch (error) {
1935
- console.log("\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 AdImage \u5F02\u5E38,\u8BF7\u68C0\u67E5\u53C2\u6570");
1936
- }
1937
- try {
1938
- let adTextComponent = nativeAdvanceAd.createComponent({
1939
- adId: _adId,
1940
- componentType: "AdText",
1941
- style: {
1942
- textStyle: "title",
1943
- color: "#000000",
1944
- fontSize: 18,
1945
- top: bannerHeight / 4,
1946
- left: windowWidth / 5 + 20,
1947
- width: windowWidth / 2,
1948
- height: bannerHeight / 2
1949
- }
1950
- });
1951
- console.log("\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 AdText, \u83B7\u53D6\u7EC4\u4EF6ID\uFF1A ", adTextComponent.getComponentId());
1952
- } catch {
1953
- console.log("\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 AdText \u5F02\u5E38,\u8BF7\u68C0\u67E5\u53C2\u6570");
1954
- }
1955
- try {
1956
- let nativeAdvanceAdButton = nativeAdvanceAd.createComponent({
1957
- adId: _adId,
1958
- componentType: "AdButton",
1959
- style: {
1960
- left: windowWidth - windowWidth / 3,
1961
- top: bannerHeight / 3,
1962
- opacity: 1
1963
- }
1964
- });
1965
- console.log(
1966
- "\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 AdButton, \u83B7\u53D6\u7EC4\u4EF6ID\uFF1A ",
1967
- nativeAdvanceAdButton.getComponentId()
1968
- );
1969
- } catch (error) {
1970
- console.log("\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 AdButton \u5F02\u5E38,\u8BF7\u68C0\u67E5\u53C2\u6570");
1971
- }
1972
- try {
1973
- let nativeAdvanceAdCloseButton = nativeAdvanceAd.createComponent({
1974
- adId: _adId,
1975
- componentType: "AdCloseButton",
1976
- style: {
1977
- closeStyle: "topRight"
1978
- }
1979
- });
1980
- console.log(
1981
- "\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 AdCloseButton, \u83B7\u53D6\u7EC4\u4EF6ID\uFF1A ",
1982
- nativeAdvanceAdCloseButton.getComponentId()
1983
- );
1984
- } catch (error) {
1985
- console.log("\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 AdCloseButton \u5F02\u5E38,\u8BF7\u68C0\u67E5\u53C2\u6570");
1986
- }
1987
- try {
1988
- let nativeAdvanceAdLogo = nativeAdvanceAd.createComponent({
1989
- adId: _adId,
1990
- componentType: "AdLogo",
1991
- style: {
1992
- left: windowWidth - 80,
1993
- top: bannerHeight - 30
1994
- }
1995
- });
1996
- console.log(
1997
- "\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 AdLogo, \u83B7\u53D6\u7EC4\u4EF6ID\uFF1A ",
1998
- nativeAdvanceAdLogo.getComponentId()
1999
- );
2000
- } catch (error) {
2001
- console.log("\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 AdLogo \u5F02\u5E38,\u8BF7\u68C0\u67E5\u53C2\u6570");
2002
- }
2003
- try {
2004
- let nativeAdvanceAdPrivacy = nativeAdvanceAd.createComponent({
2005
- adId: _adId,
2006
- componentType: "AdPrivacy",
2007
- style: {
2008
- privacyStyle: "light",
2009
- fontSize: 12
2010
- }
2011
- });
2012
- console.log("\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 AdPrivacy, \u83B7\u53D6\u7EC4\u4EF6ID\uFF1A ", nativeAdvanceAdPrivacy.getComponentId());
2013
- } catch (error) {
2014
- console.log("\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 AdPrivacy \u5F02\u5E38,\u8BF7\u68C0\u67E5\u53C2\u6570");
2015
- }
2016
- nativeAdvanceAd.show({ adId: _adId }).then(() => {
2017
- console.log("promise \u56DE\u8C03\uFF1A\u5C55\u793A\u6210\u529F");
2018
- }).catch((err) => {
2019
- console.log(`promise \u56DE\u8C03\uFF1A\u5C55\u793A\u5931\u8D25 ${JSON.stringify(err)}`);
2020
- nativeAdvanceAd.destroy();
2021
- });
2022
- }
2023
- }
2024
- });
2025
- nativeAdvanceAd.onCreateComponentSucc(function(res) {
2026
- console.log(`\u521B\u5EFA\u539F\u751F\u5E7F\u544A2.0\u7EC4\u4EF6\u6210\u529F\u56DE\u8C03, code: ${res.code}, msg: ${res.msg},adId: ${res.adId}, \u7EC4\u4EF6ID: ${res.componentId}`);
2027
- });
2028
- nativeAdvanceAd.onShow(function(res) {
2029
- console.log(`\u539F\u751F\u5E7F\u544A2.0\u5C55\u793A\u56DE\u8C03, code: ${res.code}, msg: ${res.msg}`);
2030
- YCSDK.ins.onShow("NativeBanner" /* NativeBanner */);
2031
- });
2032
- nativeAdvanceAd.onError(function(err) {
2033
- console.log(`\u539F\u751F\u5E7F\u544A2.0\u9519\u8BEF\u56DE\u8C03 : ${JSON.stringify(err)}`);
2034
- YCSDK.ins.onError("NativeBanner" /* NativeBanner */);
2035
- });
2036
- nativeAdvanceAd.onClose((res) => {
2037
- console.log(`\u539F\u751F\u5E7F\u544A2.0\u5173\u95ED\u56DE\u8C03, code: ${res.code}, msg: ${res.msg}`);
2038
- YCSDK.ins.onClose("NativeBanner" /* NativeBanner */);
2039
- nativeAdvanceAd.destroy();
2040
- });
2041
- }
2042
- customFunc(methodName, params, callBack) {
2043
- console.log("oppo custom function name:", methodName);
2044
- }
2045
- };
2046
-
2047
- // assets/script/ycsdk/minigame/vivo/VivoGame.ts
2048
- import { view as view2 } from "cc";
2049
- var VivoGame = class {
2050
- constructor() {
2051
- this.qg = window["qg"];
2052
- this.bannerShowing = false;
2053
- }
2054
- init() {
2055
- this.platformVersionCode = this.qg.getSystemInfoSync().platformVersionCode;
2056
- console.log("vivo platformVersionCode: ", this.platformVersionCode);
2057
- }
2058
- login(callBack) {
2059
- }
2060
- pay(params, callBack) {
2061
- }
2062
- showBanner(position) {
2063
- if (this.platformVersionCode < 1031) {
2064
- console.log("platformVersionCode below 1031, can't show banner");
2065
- return;
2066
- }
2067
- if (!sdkconfig.ycBannerId) {
2068
- console.log("banner\u5E7F\u544A\u53C2\u6570\u6CA1\u6709\u914D\u7F6E");
2069
- return;
2070
- }
2071
- if (this.bannerShowing) {
2072
- console.log("banner\u5E7F\u544A\u5C55\u793A\u4E2D");
2073
- return;
2074
- }
2075
- this.hideBanner();
2076
- this.bannerShowing = true;
2077
- this.bannerAd = this.qg.createBannerAd({
2078
- posId: sdkconfig.ycBannerId,
2079
- adIntervals: 35,
2080
- style: {}
2081
- });
2082
- this.bannerAd.onLoad(() => {
2083
- console.log("banner load");
2084
- this.bannerShowing = true;
2085
- YCSDK.ins.onLoad("Banner" /* Banner */);
2086
- });
2087
- this.bannerAd.onClose(() => {
2088
- console.log("banner close");
2089
- this.bannerShowing = false;
2090
- YCSDK.ins.onClose("Banner" /* Banner */);
2091
- });
2092
- this.bannerAd.onError((err) => {
2093
- console.log("banner\u5E7F\u544A\u52A0\u8F7D\u5931\u8D25:", err);
2094
- this.bannerShowing = false;
2095
- YCSDK.ins.onError("Banner" /* Banner */);
2096
- });
2097
- this.bannerAd.show().then(() => {
2098
- console.log("banner\u5E7F\u544A\u5C55\u793A\u5B8C\u6210");
2099
- YCSDK.ins.onShow("Banner" /* Banner */);
2100
- this.bannerShowing = true;
2101
- }).catch((err) => {
2102
- this.bannerShowing = false;
2103
- console.log("banner\u5E7F\u544A\u5C55\u793A\u5931\u8D25:", JSON.stringify(err));
2104
- YCSDK.ins.onError("Banner" /* Banner */);
2105
- });
2106
- }
2107
- hideBanner() {
2108
- this.bannerShowing = false;
2109
- if (this.bannerAd) {
2110
- this.bannerAd.hide();
2111
- this.bannerAd.destroy();
2112
- this.bannerAd = null;
2113
- }
2114
- }
2115
- showInters(type) {
2116
- switch (type) {
2117
- case "Native" /* Native */:
2118
- this.showNative();
2119
- break;
2120
- case "Initial" /* Initial */:
2121
- case "Video" /* Video */:
2122
- this.showInitial();
2123
- break;
2124
- }
2125
- }
2126
- showInitial() {
2127
- if (this.platformVersionCode < 1031) {
2128
- console.log("platformVersionCode below 1031, can't show interstitialAd");
2129
- return;
2130
- }
2131
- if (!sdkconfig.ycIntersId) {
2132
- console.log("\u63D2\u5C4F\u5E7F\u544Aid\u672A\u914D\u7F6E");
2133
- return;
2134
- }
2135
- let interstitialAd = this.qg.createInterstitialAd({
2136
- posId: sdkconfig.ycIntersId
2137
- });
2138
- interstitialAd.onError((err) => {
2139
- console.log("\u63D2\u5C4F\u5E7F\u544A\u52A0\u8F7D\u5931\u8D25", err);
2140
- YCSDK.ins.onError("Inters" /* Inters */);
2141
- });
2142
- interstitialAd.onLoad(() => {
2143
- console.log("\u63D2\u5C4F\u5E7F\u544A\u52A0\u8F7D\u6210\u529F");
2144
- YCSDK.ins.onLoad("Inters" /* Inters */);
2145
- });
2146
- interstitialAd.onClose(() => {
2147
- console.log("\u63D2\u5C4F\u5E7F\u544A\u5173\u95ED");
2148
- YCSDK.ins.onClose("Inters" /* Inters */);
2149
- });
2150
- interstitialAd.show().then(() => {
2151
- console.log("\u63D2\u5C4F\u5E7F\u544A\u5C55\u793A\u5B8C\u6210");
2152
- YCSDK.ins.onShow("Inters" /* Inters */);
2153
- }).catch((err) => {
2154
- console.log("\u63D2\u5C4F\u5E7F\u544A\u5C55\u793A\u5931\u8D25", JSON.stringify(err));
2155
- YCSDK.ins.onError("Inters" /* Inters */);
2156
- });
2157
- }
2158
- hideNative() {
2159
- if (this.customAd) {
2160
- this.customAd.hide();
2161
- this.customAd.destroy();
2162
- this.customAd = null;
2163
- }
2164
- }
2165
- showNative() {
2166
- if (this.platformVersionCode < 1091) {
2167
- console.log("platformVersionCode below 1091, can't show custom ad");
2168
- return;
2169
- }
2170
- if (!sdkconfig.ycNativeId) {
2171
- console.log("\u539F\u751F\u6A21\u677F\u5E7F\u544A\u53C2\u6570\u6CA1\u6709\u914D\u7F6E");
2172
- return;
2173
- }
2174
- if (this.customAd && this.customAd.isShow()) {
2175
- console.log("native ad is show ing");
2176
- this.hideNative();
2177
- }
2178
- this.customAd = this.qg.createCustomAd({
2179
- posId: sdkconfig.ycNativeId,
2180
- style: {
2181
- width: view2.getVisibleSize().width,
2182
- gravity: "center"
2183
- }
2184
- });
2185
- this.customAd.onClose(() => {
2186
- console.log("\u539F\u751F\u6A21\u677F\u5E7F\u544A\u5173\u95EDclose");
2187
- YCSDK.ins.onClose("Native" /* Native */);
2188
- });
2189
- this.customAd.onHide(() => {
2190
- console.log("\u539F\u751F\u6A21\u677F\u5E7F\u544A\u5173\u95EDhide");
2191
- YCSDK.ins.onClose("Native" /* Native */);
2192
- });
2193
- this.customAd.onLoad(() => {
2194
- console.log("\u539F\u751F\u6A21\u677F\u5E7F\u544A\u52A0\u8F7D\u6210\u529F");
2195
- YCSDK.ins.onLoad("Native" /* Native */);
2196
- });
2197
- this.customAd.onError((err) => {
2198
- console.log("\u539F\u751F\u6A21\u677F\u5E7F\u544A\u52A0\u8F7D\u5931\u8D25", err);
2199
- YCSDK.ins.onError("Native" /* Native */);
2200
- });
2201
- this.customAd.show().then(() => {
2202
- console.log("\u539F\u751F\u6A21\u677F\u5E7F\u544A\u5C55\u793A\u5B8C\u6210");
2203
- YCSDK.ins.onShow("Native" /* Native */);
2204
- }).catch((err) => {
2205
- console.log("\u539F\u751F\u6A21\u677F\u5E7F\u544A\u5C55\u793A\u5931\u8D25", JSON.stringify(err));
2206
- YCSDK.ins.onError("Native" /* Native */);
2207
- });
2208
- }
2209
- hideInters(type) {
2210
- this.hideNative();
2211
- }
2212
- showVideo(callBack) {
2213
- this.callback = callBack;
2214
- if (this.rewardedAd) {
2215
- this.rewardedAd.load();
2216
- } else {
2217
- this.loadVideo();
2218
- }
2219
- return false;
2220
- }
2221
- loadVideo() {
2222
- if (this.platformVersionCode < 1041) {
2223
- console.log("platformVersionCode below 1041, can't show video ad");
2224
- return;
2225
- }
2226
- if (!sdkconfig.ycVideoId) {
2227
- console.log("\u6FC0\u52B1\u89C6\u9891\u5E7F\u544A\u53C2\u6570\u6CA1\u6709\u914D\u7F6E");
2228
- return;
2229
- }
2230
- this.rewardedAd = this.qg.createRewardedVideoAd({
2231
- posId: sdkconfig.ycVideoId
2232
- });
2233
- this.rewardedAd.onLoad((res) => {
2234
- if (res == "localAdVideo") {
2235
- console.log("\u6FC0\u52B1\u89C6\u9891 \u515C\u5E95\u5E7F\u544A-onload\u89E6\u53D1 ", res);
2236
- } else {
2237
- console.log("\u6FC0\u52B1\u89C6\u9891\u5E7F\u544A\u52A0\u8F7D\u5B8C\u6210-onload\u89E6\u53D1 ", res);
2238
- }
2239
- YCSDK.ins.onLoad("Video" /* Video */);
2240
- this.rewardedAd.show().then(() => {
2241
- console.log("\u6FC0\u52B1\u89C6\u9891\u5E7F\u544A\u5C55\u793A\u5B8C\u6210");
2242
- YCSDK.ins.onShow("Video" /* Video */);
2243
- }).catch((err) => {
2244
- console.log("\u6FC0\u52B1\u89C6\u9891\u5E7F\u544A\u5C55\u793A\u5931\u8D25", JSON.stringify(err));
2245
- this.callback && this.callback(false);
2246
- this.showNative();
2247
- YCSDK.ins.onError("Video" /* Video */);
2248
- });
2249
- });
2250
- this.rewardedAd.onError((err) => {
2251
- console.log("\u6FC0\u52B1\u89C6\u9891\u5E7F\u544A\u52A0\u8F7D\u5931\u8D25: ", JSON.stringify(err));
2252
- this.callback && this.callback(false);
2253
- YCSDK.ins.onError("Video" /* Video */);
2254
- });
2255
- this.rewardedAd.onClose((res) => {
2256
- console.log("\u6FC0\u52B1\u89C6\u9891\u5173\u95ED");
2257
- YCSDK.ins.onClose("Video" /* Video */);
2258
- if (res && res.isEnded) {
2259
- console.log("\u6B63\u5E38\u64AD\u653E\u7ED3\u675F\uFF0C\u53EF\u4EE5\u4E0B\u53D1\u6E38\u620F\u5956\u52B1");
2260
- this.callback && this.callback(true);
2261
- YCSDK.ins.onReward();
2262
- } else {
2263
- YCSDK.ins.onClose("Video" /* Video */);
2264
- console.log("\u64AD\u653E\u4E2D\u9014\u9000\u51FA\uFF0C\u4E0D\u4E0B\u53D1\u6E38\u620F\u5956\u52B1");
2265
- }
2266
- });
2267
- }
2268
- customFunc(methodName, params, callBack) {
2269
- }
2270
- };
2271
-
2272
- // assets/script/ycsdk/minigame/xiaomi/XiaoMiGame.ts
2273
- var XiaoMiGame = class {
2274
- constructor() {
2275
- this.qg = window["qg"];
2276
- this.bannerShowing = false;
2277
- }
2278
- init() {
2279
- this.platformVersionCode = this.qg.getSystemInfoSync().platformVersionCode;
2280
- }
2281
- login(callBack) {
2282
- }
2283
- pay(params, callBack) {
2284
- console.log("mi pay not support");
2285
- }
2286
- showBanner(position) {
2287
- if (!sdkconfig.ycBannerId) {
2288
- console.log("banner\u5E7F\u544A\u53C2\u6570\u6CA1\u6709\u914D\u7F6E");
2289
- return;
2290
- }
2291
- let timeTag = Date.now();
2292
- if (timeTag - this.lastBanner < 30 * 1e3) {
2293
- console.log("30\u79D2\u5185\u4E0D\u5F97\u518D\u6B21\u5C55\u793A---banner");
2294
- return;
2295
- }
2296
- if (this.bannerShowing) {
2297
- console.log("banner already showing");
2298
- return;
2299
- }
2300
- this.hideBanner();
2301
- this.bannerShowing = true;
2302
- this.bannerAd = this.qg.createBannerAd({
2303
- adUnitId: sdkconfig.ycBannerId,
2304
- adIntervals: 35
2305
- // style: {
2306
- // left: 0,
2307
- // top: 0,
2308
- // width: 1080
2309
- // }
2310
- });
2311
- this.bannerAd.onLoad(() => {
2312
- console.log("mi banner on load");
2313
- this.bannerShowing = true;
2314
- YCSDK.ins.onLoad("Banner" /* Banner */);
2315
- YCSDK.ins.onShow("Banner" /* Banner */);
2316
- });
2317
- this.bannerAd.onError((err) => {
2318
- console.log("mi banner error: ", err);
2319
- this.bannerShowing = false;
2320
- YCSDK.ins.onError("Banner" /* Banner */);
2321
- });
2322
- this.bannerAd.onClose(() => {
2323
- console.log("mi banner on close");
2324
- this.bannerShowing = false;
2325
- this.lastBanner = Date.now();
2326
- YCSDK.ins.onClose("Banner" /* Banner */);
2327
- });
2328
- this.bannerAd.show();
2329
- console.log("mi banner load");
2330
- }
2331
- hideBanner() {
2332
- this.bannerShowing = false;
2333
- if (this.bannerAd) {
2334
- this.bannerAd.hide();
2335
- this.bannerAd.destroy();
2336
- this.bannerAd = null;
2337
- }
2338
- }
2339
- showInters(type) {
2340
- switch (type) {
2341
- case "Initial" /* Initial */:
2342
- case "Video" /* Video */:
2343
- this.showInitial();
2344
- break;
2345
- case "Native" /* Native */:
2346
- this.showNative();
2347
- break;
2348
- }
2349
- }
2350
- showNative() {
2351
- if (this.platformVersionCode < 1110) {
2352
- console.log("platformVersionCode below 1110, current code: ", this.platformVersionCode);
2353
- return;
2354
- }
2355
- if (!sdkconfig.ycNativeId) {
2356
- console.log("\u539F\u751F\u6A21\u677F\u5E7F\u544A\u53C2\u6570\u6CA1\u6709\u914D\u7F6E");
2357
- return;
2358
- }
2359
- let timeTag = Date.now();
2360
- if (timeTag - this.lastNative < 30 * 1e3) {
2361
- console.log("30\u79D2\u5185\u4E0D\u5F97\u518D\u6B21\u5C55\u793A---native");
2362
- return;
2363
- }
2364
- this.hideInters("Native" /* Native */);
2365
- this.customAd = this.qg.createCustomAd({
2366
- adUnitId: sdkconfig.ycNativeId,
2367
- style: {
2368
- left: 0,
2369
- top: 300,
2370
- width: 1080
2371
- }
2372
- });
2373
- this.customAd.onLoad(() => {
2374
- console.log("mi native on load");
2375
- YCSDK.ins.onLoad("Native" /* Native */);
2376
- });
2377
- this.customAd.onClose(() => {
2378
- console.log("mi native on close");
2379
- YCSDK.ins.onClose("Native" /* Native */);
2380
- this.lastNative = Date.now();
2381
- });
2382
- this.customAd.onShow(() => {
2383
- console.log("mi native show");
2384
- YCSDK.ins.onShow("Native" /* Native */);
2385
- });
2386
- this.customAd.onError((err) => {
2387
- console.log("mi native error: ", err);
2388
- YCSDK.ins.onError("Native" /* Native */);
2389
- });
2390
- this.customAd.show();
2391
- }
2392
- showInitial() {
2393
- if (!sdkconfig.ycIntersId) {
2394
- console.log("\u63D2\u5C4F\u5E7F\u544Aid\u672A\u914D\u7F6E");
2395
- return;
2396
- }
2397
- let timeTag = Date.now();
2398
- if (timeTag - this.lastInters < 30 * 1e3) {
2399
- console.log("30\u79D2\u5185\u4E0D\u5F97\u518D\u6B21\u5C55\u793A---inters");
2400
- return;
2401
- }
2402
- let interstitialAd = this.qg.createInterstitialAd({
2403
- adUnitId: sdkconfig.ycIntersId
2404
- });
2405
- interstitialAd.onLoad(() => {
2406
- console.log("mi\u63D2\u5C4F\u5E7F\u544A\u52A0\u8F7D\u6210\u529F");
2407
- YCSDK.ins.onLoad("Inters" /* Inters */);
2408
- interstitialAd.show();
2409
- YCSDK.ins.onShow("Inters" /* Inters */);
2410
- });
2411
- interstitialAd.onClose(() => {
2412
- console.log("mi innters on close");
2413
- YCSDK.ins.onClose("Inters" /* Inters */);
2414
- this.lastInters = Date.now();
2415
- });
2416
- interstitialAd.onError((err) => {
2417
- console.log("mi inters error: ", err);
2418
- YCSDK.ins.onError("Inters" /* Inters */);
2419
- interstitialAd.destroy();
2420
- });
2421
- }
2422
- hideInters(type) {
2423
- if (this.customAd && type == "Native" /* Native */) {
2424
- this.customAd.hide();
2425
- this.customAd.destroy();
2426
- this.customAd = null;
2427
- }
2428
- }
2429
- showVideo(callBack) {
2430
- this.callback = callBack;
2431
- let timeTag = Date.now();
2432
- if (timeTag - this.lastReward < 30 * 1e3) {
2433
- console.log("30\u79D2\u5185\u4E0D\u5F97\u518D\u6B21\u5C55\u793A---video");
2434
- this.callback && this.callback(false);
2435
- return;
2436
- }
2437
- this.loadVideo(true);
2438
- return false;
2439
- }
2440
- loadVideo(show) {
2441
- if (!sdkconfig.ycVideoId) {
2442
- console.log("\u89C6\u9891\u5E7F\u544A\u53C2\u6570\u6CA1\u6709\u914D\u7F6E");
2443
- this.callback && this.callback(false);
2444
- this.callback = null;
2445
- return;
2446
- }
2447
- if (this.rewardedVideoAd) {
2448
- this.rewardedVideoAd = this.qg.createRewardedVideoAd({
2449
- adUnitId: sdkconfig.ycVideoId
2450
- });
2451
- console.log("reload video, ad id: ", sdkconfig.ycVideoId);
2452
- this.rewardedVideoAd.load();
2453
- return;
2454
- }
2455
- this.rewardedVideoAd = this.qg.createRewardedVideoAd({
2456
- adUnitId: sdkconfig.ycVideoId
2457
- });
2458
- console.log("create video, ad id: ", sdkconfig.ycVideoId);
2459
- this.rewardedVideoAd.onLoad(() => {
2460
- console.log("mi video on load");
2461
- YCSDK.ins.onLoad("Video" /* Video */);
2462
- if (show) {
2463
- setTimeout(() => {
2464
- this.rewardedVideoAd.show();
2465
- YCSDK.ins.onShow("Video" /* Video */);
2466
- }, 100);
2467
- }
2468
- });
2469
- this.rewardedVideoAd.onClose((isEnded) => {
2470
- console.log("mi video on close: ", isEnded);
2471
- this.lastReward = Date.now();
2472
- YCSDK.ins.onClose("Video" /* Video */);
2473
- if (isEnded.isEnded) {
2474
- YCSDK.ins.onReward();
2475
- this.callback && this.callback(isEnded.isEnded);
2476
- } else {
2477
- YCSDK.ins.onClose("Video" /* Video */);
2478
- }
2479
- });
2480
- this.rewardedVideoAd.onError((err) => {
2481
- console.log("mi video error: ", err);
2482
- YCSDK.ins.onError("Video" /* Video */);
2483
- });
2484
- this.rewardedVideoAd.load();
2485
- }
2486
- customFunc(methodName, params, callBack) {
2487
- console.log("custom function name:", methodName);
2488
- }
2489
- };
2490
-
2491
- // assets/script/ycsdk/minigame/wechat/WeChatGame.ts
2492
- var WeChatGame = class {
2493
- constructor() {
2494
- this.wx = window["wx"];
2495
- }
2496
- init(callBack) {
2497
- callBack && callBack();
2498
- }
2499
- login(callBack) {
2500
- }
2501
- pay(params, callBack) {
2502
- }
2503
- showBanner(position) {
2504
- if (this.bannerAd) {
2505
- this.bannerAd.destroy();
2506
- this.bannerAd = null;
2507
- }
2508
- const { screenWidth, screenHeight } = this.wx.getSystemInfoSync();
2509
- this.bannerAd = this.wx.createBannerAd({
2510
- adUnitId: sdkconfig.ycBannerId,
2511
- style: {
2512
- left: 0,
2513
- top: 0,
2514
- width: screenWidth
2515
- }
2516
- });
2517
- this.bannerAd.onResize((size) => {
2518
- this.bannerAd.style.top = screenHeight - size.height;
2519
- });
2520
- this.bannerAd.onLoad(() => {
2521
- console.log("banner \u5E7F\u544A\u52A0\u8F7D\u6210\u529F");
2522
- YCSDK.ins.onLoad("Banner" /* Banner */);
2523
- YCSDK.ins.onShow("Banner" /* Banner */);
2524
- });
2525
- this.bannerAd.onError((err) => {
2526
- console.log("banner \u5E7F\u544A\u52A0\u8F7D\u5931\u8D25:", err);
2527
- YCSDK.ins.onError("Banner" /* Banner */);
2528
- this.showNativeBanner();
2529
- });
2530
- this.bannerAd.show();
2531
- }
2532
- showNativeBanner() {
2533
- const { screenWidth, screenHeight } = this.wx.getSystemInfoSync();
2534
- const customAd = this.wx.createCustomAd({
2535
- adUnitId: sdkconfig.ycNativeId,
2536
- style: {
2537
- left: (screenWidth - 360) / 2,
2538
- top: screenHeight - 106,
2539
- width: 360,
2540
- height: 106
2541
- }
2542
- });
2543
- customAd.onResize((res) => {
2544
- console.log("on resize:", res);
2545
- customAd.style.top = screenHeight - res.height;
2546
- customAd.style.left = (screenWidth - res.width) / 2;
2547
- });
2548
- customAd.onLoad(() => {
2549
- console.log("\u539F\u751F\u6A21\u677F\u5E7F\u544A\u52A0\u8F7D\u6210\u529F");
2550
- YCSDK.ins.onLoad("Native" /* Native */);
2551
- });
2552
- customAd.onError((err) => {
2553
- console.log("\u539F\u751F\u5E7F\u544A\u52A0\u8F7D\u5931\u8D25", err);
2554
- YCSDK.ins.onError("Native" /* Native */);
2555
- });
2556
- customAd.onClose(() => {
2557
- console.log("\u539F\u751F\u6A21\u677F\u5E7F\u544A\u5173\u95ED");
2558
- YCSDK.ins.onClose("Native" /* Native */);
2559
- });
2560
- customAd.show().then(() => {
2561
- console.log("\u539F\u751F\u6A21\u677F\u5E7F\u544A\u663E\u793A");
2562
- YCSDK.ins.onShow("Native" /* Native */);
2563
- });
593
+ showPolicy(node, callBack) {
594
+ jsb.reflection.callStaticMethod(this.className, "showPolicy", "()V");
595
+ }
596
+ showBanner(position) {
597
+ jsb.reflection.callStaticMethod(this.className, "showBanner", "()V");
2564
598
  }
2565
599
  hideBanner() {
2566
- if (this.bannerAd) {
2567
- this.bannerAd.hide();
2568
- this.bannerAd.destroy();
2569
- this.bannerAd = null;
2570
- }
600
+ jsb.reflection.callStaticMethod(this.className, "hideBanner", "()V");
2571
601
  }
2572
602
  showInters(type) {
2573
- let interstitialAd = this.wx.createInterstitialAd({ adUnitId: sdkconfig.ycIntersId });
2574
- interstitialAd.onLoad(() => {
2575
- console.log("\u63D2\u5C4F \u5E7F\u544A\u52A0\u8F7D\u6210\u529F");
2576
- YCSDK.ins.onLoad("Inters" /* Inters */);
2577
- YCSDK.ins.onShow("Inters" /* Inters */);
2578
- });
2579
- interstitialAd.onError((err) => {
2580
- console.log("\u63D2\u5C4F\u5E7F\u544A\u52A0\u8F7D\u5931\u8D25\uFF1A", err);
2581
- YCSDK.ins.onError("Inters" /* Inters */);
2582
- });
2583
- interstitialAd.onClose((res) => {
2584
- console.log("\u63D2\u5C4F \u5E7F\u544A\u5173\u95ED");
2585
- YCSDK.ins.onClose("Inters" /* Inters */);
2586
- });
2587
- interstitialAd.show().catch((err) => {
2588
- console.error("\u63D2\u5C4F\u5E7F\u544A\u5C55\u793A\u5931\u8D25\uFF1A", err);
2589
- YCSDK.ins.onError("Inters" /* Inters */);
2590
- });
603
+ jsb.reflection.callStaticMethod(this.className, "showInters", "()V");
2591
604
  }
2592
605
  hideInters(type) {
606
+ jsb.reflection.callStaticMethod(this.className, "hideInters", "()V");
2593
607
  }
2594
608
  showVideo(callBack) {
2595
- let rewardedVideoAd = this.wx.createRewardedVideoAd({ adUnitId: sdkconfig.ycVideoId });
2596
- rewardedVideoAd.onLoad(() => {
2597
- console.log("\u6FC0\u52B1\u89C6\u9891 \u5E7F\u544A\u52A0\u8F7D\u6210\u529F");
2598
- YCSDK.ins.onLoad("Video" /* Video */);
2599
- });
2600
- rewardedVideoAd.onError((err) => {
2601
- console.log("\u6FC0\u52B1\u89C6\u9891 \u5E7F\u544A\u52A0\u8F7D\u5931\u8D25\uFF1A", err);
2602
- YCSDK.ins.onError("Video" /* Video */, callBack);
2603
- });
2604
- rewardedVideoAd.onClose((res) => {
2605
- YCSDK.ins.onClose("Video" /* Video */);
2606
- if (res && res.isEnded || res === void 0) {
2607
- YCSDK.ins.onReward();
609
+ let videoCallBack = function(res) {
610
+ console.log("on video call back:", res);
611
+ if (res) {
2608
612
  callBack && callBack(true);
2609
613
  } else {
2610
614
  callBack && callBack(false);
2611
615
  }
2612
- });
2613
- rewardedVideoAd.show().catch((err) => {
2614
- rewardedVideoAd.load().then(() => {
2615
- rewardedVideoAd.show();
2616
- YCSDK.ins.onShow("Video" /* Video */);
2617
- });
2618
- });
616
+ };
617
+ window["videoCallBack"] = videoCallBack;
618
+ jsb.reflection.callStaticMethod(this.className, "showVideo", "()V");
2619
619
  return false;
2620
620
  }
2621
621
  customFunc(methodName, params, callBack) {
2622
- const { screenWidth, screenHeight } = this.wx.getSystemInfoSync();
2623
- let CustomAd = this.wx.createCustomAd({
2624
- adUnitId: sdkconfig.ycBigPicId,
2625
- style: {
2626
- left: 0,
2627
- top: (screenHeight - screenWidth) / 2,
2628
- width: screenWidth
2629
- }
2630
- });
2631
- CustomAd.onResize((res) => {
2632
- console.log("on resize:", res);
2633
- CustomAd.style.top = screenHeight - res.height;
2634
- CustomAd.style.left = (screenWidth - res.width) / 2;
2635
- });
2636
- CustomAd.onError((err) => {
2637
- console.error("\u77E9\u9635\u5E7F\u544A\u52A0\u8F7D\u5931\u8D25\uFF1A", err.errMsg);
2638
- });
2639
- CustomAd.show();
622
+ jsb.reflection.callStaticMethod(this.className, "customFunc", "(Ljava/lang/String;Ljava/lang/String;)V", methodName, params);
2640
623
  }
2641
624
  };
2642
625
 
2643
- // assets/script/ycsdk/minigame/MiniGame.ts
2644
- var MiniGame = class {
2645
- constructor(platform) {
2646
- this.privacyKey = "PRIVACY";
2647
- this.channelFactory(platform);
626
+ // assets/script/ycsdk/nativegame/harmony/HarmonySdk.ts
627
+ var initSdkPhasesCallback;
628
+ var intersCallback;
629
+ var videoCallback;
630
+ var payCallback;
631
+ var redeemCallback;
632
+ var TAG = "XSDK-HarmonySdk";
633
+ var HarmonySdk = class _HarmonySdk {
634
+ /**
635
+ * 私有构造方法 不允许在子类和外部实例化对象(new一下)
636
+ */
637
+ constructor() {
638
+ this.VERSION = "1.0.1";
2648
639
  }
2649
- channelFactory(platform) {
2650
- console.log("switch platform:", platform);
2651
- switch (platform) {
2652
- case sys6.Platform.HUAWEI_QUICK_GAME:
2653
- this.channel = new HuaWeiGame();
2654
- break;
2655
- case sys6.Platform.XIAOMI_QUICK_GAME:
2656
- this.channel = new XiaoMiGame();
2657
- break;
2658
- case sys6.Platform.OPPO_MINI_GAME:
2659
- this.channel = new OppoGame();
2660
- break;
2661
- case sys6.Platform.VIVO_MINI_GAME:
2662
- this.channel = new VivoGame();
2663
- break;
2664
- case sys6.Platform.BYTEDANCE_MINI_GAME:
2665
- this.channel = new DouYinGame();
2666
- break;
2667
- case sys6.Platform.WECHAT_GAME:
2668
- this.channel = new WeChatGame();
2669
- break;
2670
- default:
2671
- break;
640
+ /** 使用 🎈:用懒加载形式实现单例模式 */
641
+ // 前面加个static,变成静态方法,可以直接通过类来调用该方法
642
+ static getInstance() {
643
+ if (!_HarmonySdk.instance) {
644
+ _HarmonySdk.instance = new _HarmonySdk();
2672
645
  }
646
+ return _HarmonySdk.instance;
2673
647
  }
2674
- jsonToKeyValue(json) {
2675
- return Object.entries(json).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join("&");
648
+ initSDK(params, callback) {
649
+ console.log(TAG, "initSDK version:" + this.VERSION);
650
+ if (callback) initSdkPhasesCallback = callback;
651
+ else initSdkPhasesCallback = null;
652
+ globalThis.oh.postMessage("initSDK", 0);
2676
653
  }
2677
- init(callBack, adconfig, config) {
2678
- if (!adconfig) adconfig = { switch: false, count: 0, delay: 0 };
2679
- if (!config) config = { switch: false, type: 0, loop: 0 };
2680
- if (!YCSDK.ins.isRun(sys6.Platform.OPPO_MINI_GAME)) {
2681
- this.setAdStateListener();
2682
- this.channel.init(callBack, adconfig, config);
2683
- return;
2684
- }
2685
- const url = "https://iaa.rhino-times.com/api/game/query-match-config";
2686
- const data = { pkgName: sdkconfig.pkgName, version: sdkconfig.version };
2687
- const sign = Md5.hashStr(this.jsonToKeyValue(data));
2688
- data["sign"] = sign;
2689
- HttpRequest.get().requestPostjson(url, data, (success, result) => {
2690
- if (!success || !result) {
2691
- this.setAdStateListener();
2692
- this.channel.init(callBack, adconfig, config);
2693
- return;
2694
- }
2695
- const res = result.oexts;
2696
- sdkconfig.open = result.open;
2697
- sdkconfig.ratio = res.ratio;
2698
- sdkconfig.subornUserTest = res.subornUserTest;
2699
- if (res.subornVideoConfig) {
2700
- adconfig = res.subornVideoConfig;
2701
- }
2702
- if (res.subornNativeConfig) {
2703
- config = res.subornNativeConfig;
2704
- }
2705
- this.setAdStateListener();
2706
- this.channel.init(callBack, adconfig, config);
2707
- });
654
+ getIntersFlag() {
655
+ return true;
2708
656
  }
2709
- setAdStateListener() {
2710
- const st = new AdTactics();
2711
- st.refreshAll();
2712
- YCSDK.ins.setAdStateListener(st);
657
+ showInters(params, callback) {
658
+ if (callback) intersCallback = callback;
659
+ else intersCallback = null;
660
+ globalThis.oh.postMessage("showInters", 0);
2713
661
  }
2714
- showPolicy(node, callBack) {
2715
- let agree = StorageUtils.getStringData(this.privacyKey);
2716
- console.log(agree);
2717
- if (agree == "agree") {
2718
- console.log("user agree privacy, not show");
2719
- callBack.userAgree && callBack.userAgree();
2720
- return;
2721
- }
2722
- if (!node) {
2723
- console.log("node is null");
2724
- callBack.nodeError && callBack.nodeError();
2725
- return;
2726
- }
2727
- resources4.load("Privacy/policyUI", Prefab4, (err, prefab) => {
2728
- if (err) {
2729
- console.error("\u52A0\u8F7D\u9690\u79C1\u653F\u7B56Prefab\u5931\u8D25:", err);
2730
- return;
2731
- }
2732
- const yinsiUI = instantiate4(prefab);
2733
- const content = yinsiUI.getChildByName("panel").getChildByName("content");
2734
- if (!content.getComponent(PrivacyEvent)) {
2735
- content.addComponent(PrivacyEvent);
2736
- }
2737
- const agree2 = yinsiUI.getChildByName("panel").getChildByName("agree");
2738
- agree2.on(Node4.EventType.TOUCH_END, () => {
2739
- callBack.onAgree && callBack.onAgree();
2740
- StorageUtils.setStringData(this.privacyKey, "agree");
2741
- yinsiUI.active = false;
2742
- }, this);
2743
- const disagree = yinsiUI.getChildByName("panel").getChildByName("disagree");
2744
- disagree.on(Node4.EventType.TOUCH_END, () => {
2745
- callBack.onDisAgree && callBack.onDisAgree();
2746
- yinsiUI.getChildByName("panel").getChildByName("tip").active = true;
2747
- }, this);
2748
- YCSDK.ins.getGameNode().addChild(yinsiUI);
662
+ getVideoFlag() {
663
+ return true;
664
+ }
665
+ showVideo(params, callback) {
666
+ if (callback) videoCallback = callback;
667
+ else videoCallback = null;
668
+ globalThis.oh.postMessage("showVideo", "");
669
+ }
670
+ pay(params, callback) {
671
+ if (callback) payCallback = callback;
672
+ else payCallback = null;
673
+ globalThis.oh.postMessage("pay", JSON.stringify(params));
674
+ }
675
+ copyText(text) {
676
+ globalThis.oh.postMessage("copyText", text);
677
+ }
678
+ openUrl(url) {
679
+ globalThis.oh.postMessage("openUrl", url);
680
+ }
681
+ setRedeemCallback(callback) {
682
+ if (callback) redeemCallback = callback;
683
+ else redeemCallback = null;
684
+ }
685
+ consumeOrder(orderId) {
686
+ if (!orderId) return;
687
+ globalThis.oh.postMessage("consumeOrder", orderId);
688
+ }
689
+ vibrate() {
690
+ globalThis.oh.postMessage("vibrate", 0);
691
+ }
692
+ };
693
+ window["LightHarmonyInitCallback"] = (phases, res) => {
694
+ console.log(TAG, "\u521D\u59CB\u5316\u56DE\u8C03", phases, JSON.stringify(res));
695
+ initSdkPhasesCallback && initSdkPhasesCallback(phases, res);
696
+ };
697
+ window["LightHarmonyVideoCallback"] = (res) => {
698
+ console.log(TAG, "\u89C6\u9891\u662F\u5426\u64AD\u653E\u5B8C\u6210?", res == "1");
699
+ videoCallback && videoCallback(res == "1" ? "videoPlayFinish" : "videoPlayBreak", {});
700
+ videoCallback = null;
701
+ };
702
+ window["LightHarmonyIntersCallBack"] = () => {
703
+ console.log(TAG, "\u63D2\u5C4F\u5173\u95ED\u56DE\u8C03");
704
+ intersCallback && intersCallback("intersClose", {});
705
+ intersCallback = null;
706
+ };
707
+ window["LightHarmonyPayCallBack"] = (success, res) => {
708
+ console.log(TAG, "\u652F\u4ED8\u7ED3\u679C\u56DE\u8C03:" + res);
709
+ payCallback && payCallback(success == "1" ? "paySuccess" : "payFail", res);
710
+ payCallback = null;
711
+ };
712
+ window["LightHarmonyRedeemCallBack"] = (res) => {
713
+ console.log(TAG, "\u8865\u5355\u56DE\u8C03:" + res);
714
+ redeemCallback && redeemCallback(res);
715
+ };
716
+ window["LightHarmonyOnResultCallBack"] = (code, res) => {
717
+ console.log(TAG, "onResult\u56DE\u8C03, code:" + code + ";res:" + res);
718
+ };
719
+
720
+ // assets/script/ycsdk/nativegame/harmony/HarmonyGame.ts
721
+ var TAG2 = "HarmonyGame";
722
+ var HarmonyGame = class {
723
+ init(callBack, adconfig, config) {
724
+ HarmonySdk.getInstance().initSDK({}, (phases, res) => {
725
+ console.log(TAG2, "phases:", phases, "res:", JSON.stringify(res));
726
+ callBack && callBack();
2749
727
  });
2750
728
  }
2751
729
  login(callBack) {
2752
- this.channel.login(callBack);
730
+ }
731
+ showPolicy(node, callBack) {
2753
732
  }
2754
733
  pay(params, callBack) {
2755
- this.channel.pay(params, callBack);
2756
734
  }
2757
735
  showBanner(position) {
2758
- if (!sdkconfig.open) {
2759
- console.log("\u5E7F\u544A\u672A\u5F00\u542F");
2760
- return;
2761
- }
2762
- this.channel.showBanner(position);
2763
736
  }
2764
737
  hideBanner() {
2765
- this.channel.hideBanner();
2766
738
  }
2767
739
  showInters(type) {
2768
- if (!sdkconfig.open) {
2769
- console.log("\u5E7F\u544A\u672A\u5F00\u542F");
2770
- return;
2771
- }
2772
- this.channel.showInters(type);
740
+ HarmonySdk.getInstance().showInters();
2773
741
  }
2774
- hideInters(type = "Native" /* Native */) {
2775
- this.channel.hideInters(type);
742
+ hideInters(type) {
2776
743
  }
2777
744
  showVideo(callBack) {
2778
- if (!sdkconfig.open) {
2779
- console.log("\u5E7F\u544A\u672A\u5F00\u542F");
2780
- callBack && callBack(true);
2781
- return false;
2782
- }
2783
- return this.channel.showVideo(callBack);
745
+ HarmonySdk.getInstance().showVideo({}, (phases, res) => {
746
+ console.log(TAG2, "showVideo, phases:" + phases + ";res:" + JSON.stringify(res));
747
+ if (phases == "videoPlayFinish") {
748
+ callBack && callBack(true);
749
+ } else {
750
+ callBack && callBack(false);
751
+ }
752
+ });
753
+ return true;
2784
754
  }
2785
755
  customFunc(methodName, params, callBack) {
2786
- if (!sdkconfig.open) {
2787
- console.log("\u5E7F\u544A\u672A\u5F00\u542F");
2788
- return;
756
+ if (methodName == "vibrate") {
757
+ HarmonySdk.getInstance().vibrate();
2789
758
  }
2790
- this.channel.customFunc(methodName, params, callBack);
2791
759
  }
2792
760
  };
2793
761
 
2794
- // assets/script/ycsdk/nativegame/anroid/AndroidGame.ts
2795
- var AndroidGame = class {
2796
- constructor() {
2797
- this.className = "com/ycsdk/cocos/GameBridge";
762
+ // assets/script/ycsdk/nativegame/ios/IOSGame.ts
763
+ var IOSGame = class {
764
+ init(callBack, adconfig, config) {
2798
765
  }
2799
- init(callBack) {
2800
- callBack && callBack();
2801
- this.login();
766
+ showPolicy(node, callBack) {
2802
767
  }
2803
768
  login(callBack) {
2804
- jsb.reflection.callStaticMethod(this.className, "login", "()V");
2805
769
  }
2806
- showPolicy(node, callBack) {
2807
- jsb.reflection.callStaticMethod(this.className, "showPolicy", "()V");
770
+ pay(params, callBack) {
2808
771
  }
2809
772
  showBanner(position) {
2810
- jsb.reflection.callStaticMethod(this.className, "showBanner", "()V");
2811
773
  }
2812
774
  hideBanner() {
2813
- jsb.reflection.callStaticMethod(this.className, "hideBanner", "()V");
2814
775
  }
2815
776
  showInters(type) {
2816
- jsb.reflection.callStaticMethod(this.className, "showInters", "()V");
777
+ jsb.bridge.sendToNative("showInters");
2817
778
  }
2818
779
  hideInters(type) {
2819
- jsb.reflection.callStaticMethod(this.className, "hideInters", "()V");
2820
780
  }
2821
781
  showVideo(callBack) {
2822
- let videoCallBack = function(res) {
2823
- console.log("on video call back:", res);
2824
- if (res) {
2825
- callBack && callBack(true);
2826
- } else {
2827
- callBack && callBack(false);
782
+ jsb.bridge.onNative = (arg0, arg1) => {
783
+ if (arg0 == "close") {
784
+ if (arg1 == "finished") {
785
+ callBack(true);
786
+ } else {
787
+ callBack(false);
788
+ }
2828
789
  }
790
+ return;
2829
791
  };
2830
- window["videoCallBack"] = videoCallBack;
2831
- jsb.reflection.callStaticMethod(this.className, "showVideo", "()V");
2832
- return false;
792
+ jsb.bridge.sendToNative("showVideo");
793
+ return true;
2833
794
  }
2834
795
  customFunc(methodName, params, callBack) {
2835
- jsb.reflection.callStaticMethod(this.className, "customFunc", "(Ljava/lang/String;Ljava/lang/String;)V", methodName, params);
2836
796
  }
2837
797
  };
2838
798
 
@@ -2840,7 +800,7 @@ var AndroidGame = class {
2840
800
  var YCSDK = class _YCSDK {
2841
801
  constructor() {
2842
802
  this.states = [];
2843
- this.suportPlatfrom = [sys7.Platform.HUAWEI_QUICK_GAME, sys7.Platform.XIAOMI_QUICK_GAME, sys7.Platform.OPPO_MINI_GAME, sys7.Platform.VIVO_MINI_GAME, sys7.Platform.BYTEDANCE_MINI_GAME, sys7.Platform.WECHAT_GAME];
803
+ this.suportPlatfrom = [sys3.Platform.HUAWEI_QUICK_GAME, sys3.Platform.XIAOMI_QUICK_GAME, sys3.Platform.OPPO_MINI_GAME, sys3.Platform.VIVO_MINI_GAME, sys3.Platform.BYTEDANCE_MINI_GAME, sys3.Platform.WECHAT_GAME];
2844
804
  this.privacyKey = "PRIVACY";
2845
805
  this.createPlatform();
2846
806
  }
@@ -2851,16 +811,22 @@ var YCSDK = class _YCSDK {
2851
811
  return _YCSDK.instance;
2852
812
  }
2853
813
  createPlatform() {
2854
- let platform = sys7.platform;
814
+ let platform = sys3.platform;
2855
815
  console.log("current platform:", platform);
2856
- if (platform == sys7.Platform.ANDROID) {
816
+ if (platform == sys3.Platform.ANDROID) {
2857
817
  this.platform = new AndroidGame();
2858
818
  return;
2859
819
  }
2860
- if (this.isSupportMiniGame(platform)) {
2861
- this.platform = new MiniGame(platform);
820
+ if (platform == sys3.Platform.OPENHARMONY) {
821
+ this.platform = new HarmonyGame();
2862
822
  return;
2863
823
  }
824
+ if (platform == sys3.Platform.MACOS || sys3.Platform.IOS) {
825
+ if (this.isSupportMiniGame(platform)) {
826
+ this.platform = new IOSGame();
827
+ return;
828
+ }
829
+ }
2864
830
  console.log("ycsdk\u6682\u4E0D\u652F\u6301\u8BE5\u5C0F\u6E38\u620F\u5E73\u53F0,\u4EE5\u8C03\u8BD5\u6A21\u5F0F\u8FD0\u884C");
2865
831
  this.platform = new DebugGame();
2866
832
  }
@@ -2868,7 +834,7 @@ var YCSDK = class _YCSDK {
2868
834
  return this.suportPlatfrom.includes(platform);
2869
835
  }
2870
836
  isRun(platform) {
2871
- return sys7.platform == platform;
837
+ return sys3.platform == platform;
2872
838
  }
2873
839
  init(config, callBack, adconfig, cf) {
2874
840
  console.log("ycsdk init");
@@ -2888,7 +854,7 @@ var YCSDK = class _YCSDK {
2888
854
  this.platform.init(callBack, adconfig, cf);
2889
855
  }
2890
856
  agreePrivacy() {
2891
- if (this.isRun(sys7.Platform.ANDROID)) {
857
+ if (this.isRun(sys3.Platform.ANDROID) || this.isRun(sys3.Platform.OPENHARMONY)) {
2892
858
  return true;
2893
859
  }
2894
860
  return StorageUtils.getStringData(this.privacyKey) == "agree";
@@ -2942,7 +908,7 @@ var YCSDK = class _YCSDK {
2942
908
  this.states.push(state);
2943
909
  }
2944
910
  vertical() {
2945
- let winSize = view3.getDesignResolutionSize();
911
+ let winSize = view.getDesignResolutionSize();
2946
912
  console.log("vertical:", winSize.height > winSize.width);
2947
913
  return winSize.height > winSize.width;
2948
914
  }
@@ -3001,6 +967,117 @@ var YCSDK = class _YCSDK {
3001
967
  });
3002
968
  }
3003
969
  };
970
+
971
+ // assets/script/ycsdk/minigame/HttpRequest.ts
972
+ var HttpRequest = class _HttpRequest {
973
+ static {
974
+ this.AUTHORIZATION = "Authorization";
975
+ }
976
+ static {
977
+ this.CONTENT_TYPE = "Content-Type";
978
+ }
979
+ static {
980
+ this.Accept = "Accept";
981
+ }
982
+ static get() {
983
+ if (!_HttpRequest.instance) {
984
+ _HttpRequest.instance = new _HttpRequest();
985
+ }
986
+ return _HttpRequest.instance;
987
+ }
988
+ requestPostx3w(url, data, callback, head) {
989
+ console.log("HttpRequest url:", url);
990
+ console.log("HttpRequest data:", JSON.stringify(data));
991
+ this.httpRequest = new XMLHttpRequest();
992
+ this.httpRequest.onreadystatechange = function() {
993
+ console.log("HttpRequest", "onreadystatechange:", this.readyState, this.status);
994
+ if (this.readyState == 4 && this.status == 200) {
995
+ let res = JSON.parse(this.responseText);
996
+ console.log("HttpRequest", "response:", JSON.stringify(res));
997
+ if (res.status == 200) {
998
+ callback(true, res.data);
999
+ } else {
1000
+ callback(false, res);
1001
+ }
1002
+ }
1003
+ };
1004
+ this.httpRequest.timeout = 5e3;
1005
+ this.httpRequest.ontimeout = () => {
1006
+ console.log("HttpRequest:", "request time out", url);
1007
+ callback(false);
1008
+ };
1009
+ this.httpRequest.onerror = function(e) {
1010
+ console.log("HttpRequest", url, " request error", JSON.stringify(e));
1011
+ callback(false);
1012
+ };
1013
+ this.httpRequest.open("POST", url, true);
1014
+ this.httpRequest.setRequestHeader(_HttpRequest.CONTENT_TYPE, "application/x-www-form-urlencoded" /* APPLICATION_X_WWW_FORM_URLENCODED */);
1015
+ if (head) {
1016
+ this.httpRequest.setRequestHeader(_HttpRequest.AUTHORIZATION, head);
1017
+ }
1018
+ this.httpRequest.send(data);
1019
+ }
1020
+ requestGetx3w(url, data, callback, head) {
1021
+ console.log("HttpRequest url:", url);
1022
+ console.log("HttpRequest data:", JSON.stringify(data));
1023
+ this.httpRequest = new XMLHttpRequest();
1024
+ this.httpRequest.onreadystatechange = function() {
1025
+ if (this.readyState == 4 && this.status == 200) {
1026
+ let response = this.responseText.replace(/:s*([0-9]{15,})s*(,?)/g, ': "$1" $2');
1027
+ let res = JSON.parse(response);
1028
+ console.log("HttpRequest", "response:", JSON.stringify(res));
1029
+ if (res.status == 200) {
1030
+ callback(true, res.data);
1031
+ } else {
1032
+ callback(false, res);
1033
+ }
1034
+ }
1035
+ };
1036
+ this.httpRequest.timeout = 5e3;
1037
+ this.httpRequest.ontimeout = () => {
1038
+ console.log("HttpRequest:", "request time out", url);
1039
+ callback(false);
1040
+ };
1041
+ this.httpRequest.onerror = function(e) {
1042
+ console.log("HttpRequest", url, " request error", JSON.stringify(e));
1043
+ callback(false);
1044
+ };
1045
+ this.httpRequest.open("GET", url, true);
1046
+ this.httpRequest.setRequestHeader(_HttpRequest.CONTENT_TYPE, "application/x-www-form-urlencoded" /* APPLICATION_X_WWW_FORM_URLENCODED */);
1047
+ if (head) {
1048
+ this.httpRequest.setRequestHeader(_HttpRequest.AUTHORIZATION, head);
1049
+ }
1050
+ this.httpRequest.send(data);
1051
+ }
1052
+ requestPostjson(url, data, callback, head) {
1053
+ console.log("HttpRequest url:", url);
1054
+ this.httpRequest = new XMLHttpRequest();
1055
+ this.httpRequest.onreadystatechange = function() {
1056
+ if (this.readyState == 4 && this.status == 200) {
1057
+ let res = JSON.parse(this.responseText);
1058
+ console.log("HttpRequest", "response:", JSON.stringify(res));
1059
+ if (res.code == 0) {
1060
+ callback(true, res.data.config);
1061
+ } else {
1062
+ callback(false, res);
1063
+ }
1064
+ }
1065
+ };
1066
+ this.httpRequest.timeout = 3e3;
1067
+ this.httpRequest.ontimeout = () => {
1068
+ console.log("HttpRequest:", "request time out", url);
1069
+ callback(false);
1070
+ };
1071
+ this.httpRequest.onerror = function(e) {
1072
+ console.log("HttpRequest", url, " request error", JSON.stringify(e));
1073
+ callback(false);
1074
+ };
1075
+ this.httpRequest.open("POST", url, true);
1076
+ this.httpRequest.setRequestHeader(_HttpRequest.Accept, "application/json" /* APPLICATION_JSON */);
1077
+ this.httpRequest.setRequestHeader(_HttpRequest.CONTENT_TYPE, "application/json" /* APPLICATION_JSON */);
1078
+ this.httpRequest.send(JSON.stringify(data));
1079
+ }
1080
+ };
3004
1081
  export {
3005
1082
  AdType,
3006
1083
  BannerType,