Spring774
2025-10-30 24d1f8782c262a20ead3e0d68a93eb28cac7d376
assets/Script/Sdk/SdkHuawei.ts
@@ -1,19 +1,20 @@
import { SdkDefault } from "./SdkDefault";
var rewardCallback = null;
export class SdkHuawei {
export class SdkHuawei extends SdkDefault {
    private lastShowInterAdTime: number = 0;
    private static interstitialAd = null;
    private static rewardedVideoAd = null;
    private static interstitialAdLoaded: boolean = false;
    private interstitialAd = null;
    private rewardedVideoAd = null;
    private interstitialAdLoaded: boolean = false;
    /**
     * 开始游戏
     * @param cb 
     */
    static startGame(cb?: Function): void {
    startGame(cb?: Function): void {
        cc.log('SdkHuawei startGame.');
        qg.gameLoginWithReal({
@@ -36,20 +37,20 @@
                if (code == 7004 || code == 2012) {
                    console.log("玩家取消登录,返回游戏界面让玩家重新登录。");
                    cc.director.loadScene('logo');
                }else
                //状态码为7021表示玩家取消实名认证。
                //在中国大陆的情况下,此时需要禁止玩家进入游戏。
                if (code == 7021) {
                    console.log("The player has canceled identity verification. Forbid the player from entering the game.")
                    cc.director.loadScene('logo');
                }else{
                    cc.game.end();
                }
                } else
                    //状态码为7021表示玩家取消实名认证。
                    //在中国大陆的情况下,此时需要禁止玩家进入游戏。
                    if (code == 7021) {
                        console.log("The player has canceled identity verification. Forbid the player from entering the game.")
                        cc.director.loadScene('logo');
                    } else {
                        cc.game.end();
                    }
            }
        });
    }
    static getOAID() {
    getOAID() {
        "function" == typeof qg.getOAID && qg.getOAID({
            success: function (ret) {
                console.log("qg.getOAID success :" + JSON.stringify(ret));
@@ -64,7 +65,7 @@
    }
    //Ads
    static showInterAd() {
    showInterAd() {
        cc.log('show InterAd');
        // if (Date.now() - this.lastShowInterAdTime > 30000) {//最少间隔30秒
        //     this.lastShowInterAdTime = Date.now();
@@ -76,14 +77,14 @@
    }
    static loadInterAd() {
    loadInterAd() {
        if (this.interstitialAd) {
            this.interstitialAd.destroy();
        }
        this.interstitialAd = qg.createInterstitialAd({
            adUnitId:
            "g2tz5d4wkv" //测试ID
            //"q5m5hlquus"//正式ID
            //    "g2tz5d4wkv" //测试ID
            "q5m5hlquus"//正式ID
        });
        this.interstitialAd.load({
            "channelExtras": {
@@ -110,11 +111,11 @@
        });
    }
    static reLoadVideo() {
    reLoadVideo() {
        this.rewardedVideoAd = qg.createRewardedVideoAd({
            adUnitId:
            "testx9dtjwj8hp" //测试ID
            //"v1gtsb1ga8" //正式ID
            //    "testx9dtjwj8hp" //测试ID
            "v1gtsb1ga8" //正式ID
            ,
            success: (code) => {
                cc.log("ad demo : loadAndShowVideoAd createRewardedVideoAd success");
@@ -153,7 +154,7 @@
        this.rewardedVideoAd.load()
    }
    static showVideoAd(cb?: (result: boolean) => void) {
    showVideoAd(cb?: (result: boolean) => void) {
        cc.log('show VideoAd');
        // cb && cb(true);
@@ -162,4 +163,8 @@
        this.rewardedVideoAd.load();
    }
    isPaymentReady(cb?: (result: boolean) => void) {
        cb && cb(false);
    }
}