12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- 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){
- 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);
- }
- }
- public static ios_login(jsonStr: string): void {
- 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)
- }
- }
- public static share(){
- if("ANDROID"==sys.platform){
- setTimeout(() => {
- 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",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(){
- 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(){
- if("ANDROID"==sys.platform){
- setTimeout(() => {
- var o = native.reflection.callStaticMethod("com/cocos/game/AppActivity", "hideSplash", "()V");
- }, 1000);
- }else if("IOS"==sys.platform){
- native.jsbBridgeWrapper.dispatchEventToNative("hideSplash");
- }
- }
- }
|