xx 2 年之前
父節點
當前提交
d1b92a4bbe
共有 2 個文件被更改,包括 41 次插入22 次删除
  1. 9 1
      assets/Scripts/GameMng.ts
  2. 32 21
      assets/Scripts/native_manager.ts

+ 9 - 1
assets/Scripts/GameMng.ts

@@ -3,12 +3,14 @@ import {game,AudioClip,Prefab,Component, _decorator, Game ,director,Node} from "
 import { ClientEvent } from "./clientEvent";
 import ItemDataConfig, { itemData } from "./config/ItemDataConfig";
 import { Constant, item_type } from "./constant";
+import GBoardChess from "./Game/ChessGame/GBoardChess";
 import { http } from "./Game/http";
 import UIDialog from "./Game/UIDialog";
 import ADSDK from "./gcommon/AdSdk/ADSDK";
 import ScenceMng from "./gcommon/ScenceMng";
 import UILoading from "./gcommon/UILoading";
 import { UIManager } from "./gcommon/UIManager";
+import { native_manager } from "./native_manager";
 import gameSocket from "./socket/gameSocket";
 import { msgManager } from "./socket/msgManager";
 import { Tools } from "./Tools";
@@ -110,7 +112,7 @@ export  class GameMng extends Component {
   static  _userData:userData = null;
   public loadingLayer: Node | null = null;
   public quit_view: quit_chess_show_view | null = null;
-
+  static isFirstRunApp:boolean = false;
   static UserDataInstance(){
     if(GameMng._userData==null){
       GameMng._userData = new userData();
@@ -296,9 +298,15 @@ export  class GameMng extends Component {
     }, this);
     game.on(Game.EVENT_SHOW, function(){
       console.log("游戏进入前台");
+      native_manager.check_jump_info()
       ClientEvent.dispatchEvent(Constant.EVENT_TYPE.MSG_HEART_BEAT)
              //ADSDK.ShareCallBack();
     },this);
+
+      if(!GameMng.isFirstRunApp){
+        GameMng.isFirstRunApp = true;
+        native_manager.check_jump_info()
+      }
       ClientEvent.on(Constant.EVENT_TYPE.MSG_EXTRUSION_LINE,this.extrusion_line,this)
       ClientEvent.on(Constant.EVENT_TYPE.MSG_HEART_BEAT,this.startTick,this)
   }

+ 32 - 21
assets/Scripts/native_manager.ts

@@ -2,32 +2,18 @@ import { _decorator, Component, Node, sys, native } from 'cc';
 import { GameMng } from './GameMng';
 import { UIManager } from './gcommon/UIManager';
 import { msgManager } from './socket/msgManager';
+import { Tools } from './Tools';
 const { ccclass, property } = _decorator;
 
 @ccclass('native_manager')
 export class native_manager  {
     public static wxLogin(){
+        UIManager.AddPrefab(GameMng.Instance.uiloading)
         if("ANDROID"==sys.platform){
-            UIManager.AddPrefab(GameMng.Instance.uiloading)
-            var o = native.reflection.callStaticMethod("com/cocos/game/AppActivity", "wxLogin", "()V");
-            native.bridge.onNative = (jsonStr:string)=>{
-                var json_ = JSON.parse(jsonStr);
-                console.log("wxLogin",jsonStr)
-                if(jsonStr!=""){
-                    for (const key in json_) {
-                        if (Object.prototype.hasOwnProperty.call(json_, key)) {
-                            const element = json_[key];
-                            console.log("wxLogin",element)
-                            
-                        }
-                    }
-                    msgManager.wxlogin(json_.nickname,json_.openId,json_.sex,json_.property,json_.city,json_.country,json_.headimgurl)
-                }else{
-                    console.log("wxLogin error",json_)
-                }
-            }
+            native.jsbBridgeWrapper.dispatchEventToNative("send_ios_login");
+            native.jsbBridgeWrapper.removeNativeEventListener("receive_ios_login",native_manager.ios_login)
+            native.jsbBridgeWrapper.addNativeEventListener("receive_ios_login",native_manager.ios_login);
         }else if("IOS"==sys.platform){
-
             native.jsbBridgeWrapper.dispatchEventToNative("send_ios_login");
             native.jsbBridgeWrapper.removeNativeEventListener("receive_ios_login",native_manager.ios_login)
             native.jsbBridgeWrapper.addNativeEventListener("receive_ios_login",native_manager.ios_login);
@@ -55,10 +41,35 @@ export class native_manager  {
     public static share(){
         if("ANDROID"==sys.platform){
             setTimeout(() => {
-                var o = native.reflection.callStaticMethod("com/cocos/game/AppActivity", "shareWx", "()V");
+                var o = native.reflection.callStaticMethod("com/cocos/game/AppActivity", "shareWx", "(Ljava/lang/String;)V",Tools.getShareObj());
             }, 1000);
          }else if("IOS"==sys.platform){
-            native.jsbBridgeWrapper.dispatchEventToNative("shareWx");
+            native.jsbBridgeWrapper.dispatchEventToNative("shareWx",Tools.getShareObj());
+         }
+    }
+
+    public static check_jump_info(){
+        native_manager.recv_jump_info();
+        if("ANDROID"==sys.platform){
+            native.jsbBridgeWrapper.dispatchEventToNative("check_jump_info");
+         }else if("IOS"==sys.platform){
+            native.jsbBridgeWrapper.dispatchEventToNative("check_jump_info");
+         }
+
+    }
+    public static recv_jump_info_call(jsonStr: string): void {
+        var json_ = JSON.parse(jsonStr);
+        console.log("recv_jump_info_call",jsonStr)
+
+    }
+    public static recv_jump_info(){
+        native.jsbBridgeWrapper.removeAllListeners()
+        if("ANDROID"==sys.platform){
+            native.jsbBridgeWrapper.removeNativeEventListener("recv_jump_info",native_manager.recv_jump_info_call);
+            native.jsbBridgeWrapper.addNativeEventListener("recv_jump_info",native_manager.recv_jump_info_call);
+         }else if("IOS"==sys.platform){
+            native.jsbBridgeWrapper.removeNativeEventListener("recv_jump_info",native_manager.recv_jump_info_call);
+            native.jsbBridgeWrapper.addNativeEventListener("recv_jump_info",native_manager.recv_jump_info_call);
          }
     }
     public static hideSplash(){