Browse Source

add native

xx 2 years ago
parent
commit
56326525db
1 changed files with 24 additions and 2 deletions
  1. 24 2
      assets/Scripts/native_manager.ts

+ 24 - 2
assets/Scripts/native_manager.ts

@@ -26,9 +26,31 @@ export class native_manager  {
                     console.log("wxLogin error",json_)
                 }
             }
-        }else{
-            //   msgManager.wxlogin(json_.nickname,json_.openId,json_.sex,json_.property,json_.city,json_.country,json_.headimgurl)
+        }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){