native_manager.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { _decorator, Component, Node, sys, native } from 'cc';
  2. import { GameMng } from './GameMng';
  3. import { UIManager } from './gcommon/UIManager';
  4. import { msgManager } from './socket/msgManager';
  5. const { ccclass, property } = _decorator;
  6. @ccclass('native_manager')
  7. export class native_manager {
  8. public static wxLogin(){
  9. if("ANDROID"==sys.platform){
  10. UIManager.AddPrefab(GameMng.Instance.uiloading)
  11. var o = native.reflection.callStaticMethod("com/cocos/game/AppActivity", "wxLogin", "()V");
  12. native.bridge.onNative = (jsonStr:string)=>{
  13. var json_ = JSON.parse(jsonStr);
  14. console.log("wxLogin",jsonStr)
  15. if(jsonStr!=""){
  16. for (const key in json_) {
  17. if (Object.prototype.hasOwnProperty.call(json_, key)) {
  18. const element = json_[key];
  19. console.log("wxLogin",element)
  20. }
  21. }
  22. msgManager.wxlogin(json_.nickname,json_.openId,json_.sex,json_.property,json_.city,json_.country,json_.headimgurl)
  23. }else{
  24. console.log("wxLogin error",json_)
  25. }
  26. }
  27. }else{
  28. // msgManager.wxlogin(json_.nickname,json_.openId,json_.sex,json_.property,json_.city,json_.country,json_.headimgurl)
  29. }
  30. }
  31. public static share(){
  32. if("ANDROID"==sys.platform){
  33. setTimeout(() => {
  34. var o = native.reflection.callStaticMethod("com/cocos/game/AppActivity", "shareWx", "()V");
  35. }, 1000);
  36. }
  37. }
  38. public static hideSplash(){
  39. if("ANDROID"==sys.platform){
  40. setTimeout(() => {
  41. var o = native.reflection.callStaticMethod("com/cocos/game/AppActivity", "hideSplash", "()V");
  42. }, 1000);
  43. }
  44. }
  45. }