hch
2025-06-05 07aee5604f365541c165f02bfe5437f1ed296fb5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
using UnityEngine;
using LitJson;
using UnityEngine.Events;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System;
using UnityEngine.Android;
 
public class SDKUtils : SingletonMonobehaviour<SDKUtils>
{
    public enum E_ChargingType
    {
        NoCharging = 1,
        Charging = 2,
        ChargingFull = 3,
    }
 
    public enum E_ChannelPlatform
    {
        Free = 1,// 默认
        Quick = 10, //quick
        Hy = 15, //欢游
    }
 
    //权限申请回调
    private Action<string, int> onPermissionCallBack;
 
    public event Action<int, JsonData> onSdkMsg;
 
    public E_ChannelPlatform ChannelPlatform { get; set; }
 
    public static string Yj_AppID
    {
        get; private set;
    }
 
    public static string ThirdPartVersion
    {
        get; private set;
    }
 
    public static string Yj_SpID
    {
        get; private set;
    }
 
    public static string ThirdPartAppID
    {
        get; private set;
    }
 
    public static string Yj_BanHao
    {
        get; private set;
    }
 
    // 是否同意隐私政策
    public bool IsAgreeSecret = false;
 
    /// <summary>
    /// sdk初始化是否完成标识
    /// 客户端一般需要等待这个值为true才继续逻辑
    /// </summary>
    public bool InitFinished { get; private set; }
 
    #region 基础定义与回调
 
    /// <summary>
    /// 当前设备电量值
    /// </summary>
    public int BatteryLevel { get; private set; }
    /// <summary>
    /// 设备电量值改变回调
    /// </summary>
    public UnityAction<int> OnBatteryLevelChanged;
 
    /// <summary>
    /// 当前充电状态
    /// </summary>
    public E_ChargingType ChargingType { get; private set; }
    /// <summary>
    /// 当前充电状态改变回调
    /// </summary>
    public UnityAction<E_ChargingType> OnChargingTypeChanged;
 
    /// <summary>
    /// 设备信息
    /// </summary>
    public DeviceInfo Device { get; private set; }
    /// <summary>
    /// 设备信息改变回调
    /// </summary>
    public UnityAction<DeviceInfo> OnDeviceInfoChanged;
 
    /// <summary>
    /// 当前网络状态
    /// </summary>
    public NetworkReachability NetworkType { get; private set; }
    /// <summary>
    /// 当前网络状态改变回调
    /// </summary>
    public UnityAction<NetworkReachability> OnNetworkStatusChanged;
 
    public static bool builtinAssetCopyFinished { get; private set; }
 
    /// <summary>
    /// 是否已经将StreamingAsset拷贝至目标路径
    /// </summary>
    public bool AssetCopyFinished { get; private set; }
 
    /// <summary>
    /// 安卓设备根目录
    /// </summary>
    public string DeviceRootPath { get; private set; }
 
    #endregion
 
    #region 极光推送
    public string RegistrationID { get; private set; }
    #endregion
 
    #region 自由sdk
    public FP_LoginOk FreePlatformInfo { get; private set; }
    #endregion
 
    private JsonData m_Json = new JsonData();
 
    public void Init()
    {
        Device = new DeviceInfo();
        string uid = LocalSave.GetString("Device_uniqueID");
        //Debug.Log(Math.Abs(System.Environment.TickCount));
        if (uid.Length <= 5)
        {
            long tick = Math.Abs(System.Environment.TickCount);
            uid = tick.ToString() + UnityEngine.Random.Range(1, ulong.MaxValue/*Constants.ExpPointValue*/).ToString();
            LocalSave.SetString("Device_uniqueID", uid);
        }
        Device.uniqueID = uid;
 
        Debug.Log(Device.uniqueID);
 
        Yj_AppID = string.Empty;
        Yj_SpID = string.Empty;
        ThirdPartVersion = string.Empty;
        RegistrationID = string.Empty;
        AssetCopyFinished = false;
        ChannelPlatform = E_ChannelPlatform.Free;
        NetworkType = NetworkReachability.NotReachable;
        BatteryLevel = 100;
 
#if !UNITY_EDITOR
        if (InitFinished)
        {
            return;
        }
#if UNITY_ANDROID
        var builtinAssetsCopyFinishVersion = LocalSave.GetString("BuiltInAssetCopyCompleted_Android");
        if (string.IsNullOrEmpty(builtinAssetsCopyFinishVersion))
        {
            builtinAssetCopyFinished = false;
        }
        else
        {
            builtinAssetCopyFinished = VersionConfig.Get().version == builtinAssetsCopyFinishVersion;
        }
#endif
#if UNITY_IOS || UNITY_STANDALONE
        var builtinAssetsCopyFinishVersion = LocalSave.GetString("BuiltInAssetCopyCompleted_IOSorStandalone");
        if (string.IsNullOrEmpty(builtinAssetsCopyFinishVersion))
        {
            builtinAssetCopyFinished = false;
        }
        else
        {
            builtinAssetCopyFinished = VersionConfig.Get().version == builtinAssetsCopyFinishVersion;
        }
 
        var assetsCopyFinishVersion = LocalSave.GetString("AssetCopyCompleted_IOSorStandalone");
        if (string.IsNullOrEmpty(assetsCopyFinishVersion))
        {
            AssetCopyFinished = false;
        }
        else
        {
            AssetCopyFinished = VersionConfig.Get().version == assetsCopyFinishVersion;
        }
 
#elif UNITY_ANDROID
        SyncClientPackageID();
#endif
 
        InitFinished = false;
        m_Json.Clear();
        m_Json["code"] = CodeU2A.Init;
        m_Json["appID"] = VersionConfig.Get().appId;
        m_Json["gameID"] = VersionConfig.Get().gameId;
        SendMessageToSDK(m_Json);
#endif
        StartCoroutine("ProcessNetworkStatus");
    }
 
    private void OnApplicationFocus(bool focus)
    {
#if !UNITY_EDITOR
        m_Json.Clear();
        if (focus)
        {
            m_Json["code"] = CodeU2A.BatteryListenStart;
            StopCoroutine("ProcessNetworkStatus");
            StartCoroutine("ProcessNetworkStatus");
        }
        else
        {
            m_Json["code"] = CodeU2A.BatteryListenStop;
            StopCoroutine("ProcessNetworkStatus");
        }
        SendMessageToSDK(m_Json);
#endif
    }
 
    private IEnumerator ProcessNetworkStatus()
    {
        while (true)
        {
            if (Application.internetReachability != NetworkType)
            {
                NetworkType = Application.internetReachability;
 
                if (OnNetworkStatusChanged != null)
                {
                    OnNetworkStatusChanged(NetworkType);
                }
            }
 
            yield return new WaitForSeconds(1f);
            // yield return WaitingForSecondConst.WaitMS1000;
        }
    }
 
    #region 业务层定义相关逻辑
 
    public void InstallAPK(string path)
    {
        if (Application.platform == RuntimePlatform.Android)
        {
            var dllPath1 = ResourcesPath.Instance.ExternalStorePath + "Assembly-CSharp-firstpass.dll";
            if (File.Exists(dllPath1))
            {
                File.Delete(dllPath1);
            }
 
            var dllPath2 = ResourcesPath.Instance.ExternalStorePath + "Assembly-CSharp.dll";
            if (File.Exists(dllPath2))
            {
                File.Delete(dllPath2);
            }
        }
 
        m_Json.Clear();
        m_Json["code"] = CodeU2A.InstallAPK;
        m_Json["path"] = path;
        SendMessageToSDK(m_Json);
    }
 
    //0 :拷贝所有资源 1:拷贝Config
    public void CopyAsset(int copyType = 0)
    {
        if (AssetCopyFinished)
        {
            return;
        }
        m_Json.Clear();
        m_Json["code"] = CodeU2A.CopyAsset;
        m_Json["copyType"] = copyType;
        SendMessageToSDK(m_Json);
    }
 
    public void CopyOneAsset(string relationPath)
    {
        m_Json.Clear();
        m_Json["code"] = CodeU2A.CopyOneAsset;
        m_Json["fileName"] = relationPath;
        SendMessageToSDK(m_Json);
    }
 
    public void CopyContent(string content)
    {
        m_Json.Clear();
        m_Json["code"] = CodeU2A.CopyContent;
        m_Json["content"] = content;
        SendMessageToSDK(m_Json);
    }
 
    public void RestartApp()
    {
        m_Json.Clear();
        m_Json["code"] = CodeU2A.RestartApp;
        SendMessageToSDK(m_Json);
    }
 
    public void OpenUrl(string url)
    {
        m_Json.Clear();
        m_Json["code"] = CodeU2A.OpenWebView;
        m_Json["url"] = url;
        SendMessageToSDK(m_Json);
    }
 
    public void MakeKeyAndVisible()
    {
        m_Json.Clear();
        m_Json["code"] = CodeU2A.MakeKeyAndVisible;
        SendMessageToSDK(m_Json);
    }
 
    public void SyncClientPackageID()
    {
#if UNITY_ANDROID
        m_Json.Clear();
        m_Json["code"] = CodeU2A.ClientPackage;
        m_Json["clientPkgID"] = VersionConfig.Get().clientPackageFlag;
        SendMessageToSDK(m_Json);
#endif
    }
 
    //申请Android 权限
    public void RequestAndroidPermission(string permission, Action<string, int> callBack)
    {
        onPermissionCallBack += callBack;
        m_Json.Clear();
        m_Json["code"] = CodeU2A.RequestPermission;
        m_Json["permission"] = permission;
        SendMessageToSDK(m_Json);
    }
 
    //申请Android 权限 启动时
    public void RequestAndroidPermissionStart()
    {
        m_Json.Clear();
        m_Json["code"] = CodeU2A.RequestPermissionStart;
        SendMessageToSDK(m_Json);
    }
 
 
    //跳转应用商店
    public void GoToAppStore(string url, string marketPkg = "")
    {
        m_Json.Clear();
        m_Json["code"] = CodeU2A.GoToAppStore;
        m_Json["marketPkg"] = marketPkg;
        m_Json["url"] = url;
        SendMessageToSDK(m_Json);
    }
 
    #endregion
 
    #region 处理与SDK交互的底层方法
 
    public static AndroidJavaObject GetApplicationContext()
    {
        using (AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
        {
            using (AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity"))
            {
                return jo.Call<AndroidJavaObject>("getApplicationContext");
            }
        }
    }
 
    public string GetSplicePackageID()
    {
        var _result = "default";
        switch (Application.platform)
        {
            case RuntimePlatform.Android:
                _result = "android";
                break;
            case RuntimePlatform.IPhonePlayer:
                _result = "ios";//ios平台固定返回ios
                break;
        }
 
        return _result;
    }
 
    private void SendMessageToSDK(JsonData json)
    {
 
#if !UNITY_EDITOR
#if UNITY_ANDROID
        using (AndroidJavaClass H2engineSDK = new AndroidJavaClass("com.secondworld.sdk.UnityMsgHandler"))
        {
            H2engineSDK.CallStatic("onUnityMessage", json.ToJson());
        }
#elif UNITY_IOS
        AotSdkUtility.IOSUniyMessageHandle(json.ToJson());
#elif UNITY_STANDALONE
        InitFinished=true;
#endif
        
#endif
 
    }
 
    public void HandleMsgWithSDK(string jsonString)
    {
//         Debug.Log("收到SDK发来的信息: " + jsonString);
//         var _json = JsonMapper.ToObject(jsonString);
//         var _code = (int)_json["code"];
//         switch (_code)
//         {
//             case CodeA2U.DeviceInfo:
 
 
//                 //Device.uniqueID = _json["unique_id"].ToString();
//                 Device.androidID = _json["android_id"].ToString();// ios平台下为idfa
//                 Device.userAgent = _json["userAgent"].ToString();
// #if UNITY_ANDROID
//                 Device.macAddress = _json["mac"].ToString();
//                 if (_json["imei"] != null)
//                 {
//                     Device.imei = _json["imei"].ToString();
//                 }
//                 else
//                 {
//                     Device.imei = Device.uniqueID;
//                 }
//                 Device.totalMemory = (int)_json["memoryTotal"];
// #endif
//                 if (OnDeviceInfoChanged != null)
//                 {
//                     OnDeviceInfoChanged(Device);
//                 }
 
//                 break;
//             case CodeA2U.AssetCopyFinished:
//                 AssetCopyFinished = true;
//                 break;
//             case CodeA2U.BatteryLevel:
 
//                 BatteryLevel = (int)_json["level"];
//                 if (OnBatteryLevelChanged != null)
//                 {
//                     OnBatteryLevelChanged(BatteryLevel);
//                 }
 
//                 break;
//             case CodeA2U.BatteryCharging:
 
//                 ChargingType = (E_ChargingType)((int)_json["status"]);
//                 if (OnChargingTypeChanged != null)
//                 {
//                     OnChargingTypeChanged(ChargingType);
//                 }
 
//                 break;
//             case CodeA2U.SdkInitComplete:
//                 InitFinished = true;
//                 var _dict = _json as IDictionary;
//                 if (_dict != null && _dict.Contains("channelPlatform"))
//                 {
//                     var _channelPlatform = _json["channelPlatform"].ToString();
//                     if (!string.IsNullOrEmpty(_channelPlatform))
//                     {
//                         if (_channelPlatform.Equals("hygame"))
//                         {
//                             ChannelPlatform = E_ChannelPlatform.Hy;
//                         }
//                         else if (_channelPlatform.Equals("quick"))
//                         {
//                             ChannelPlatform = E_ChannelPlatform.Quick;
//                         }
//                         else if (_channelPlatform.Equals("hyyn"))
//                         {
//                             ChannelPlatform = E_ChannelPlatform.newyn;
//                         }
//                         else if (_channelPlatform.Equals("hygtgame"))
//                         {
//                             ChannelPlatform = E_ChannelPlatform.hygt;
//                         }
//                         else if (_channelPlatform.Equals("hyenglish"))
//                         {
//                             ChannelPlatform = E_ChannelPlatform.en;
//                         }
//                     }
//                 }
 
//                 //Sdk 可能会修改渠道信息,所以需要重新获取
//                 if (_dict.Contains("yj_appid"))
//                 {
//                     Yj_AppID = _json["yj_appid"].ToString();
//                 }
 
//                 if (_dict.Contains("yj_spid"))
//                 {
//                     Yj_SpID = _json["yj_spid"].ToString();
//                 }
 
//                 if (_dict.Contains("banhao"))
//                 {
//                     Yj_BanHao = _json["banhao"].ToString();
//                 }
 
//                 break;
//             case CodeA2U.PushClientID:
//                 RegistrationID = _json["clientID"].ToString();
//                 break;
//             case CodeA2U.ExternalStorage:
//                 DeviceRootPath = _json["path"].ToString();
//                 break;
//             case CodeA2U.PermissionCallBack:
//                 {
//                     var state = (int)_json["state"];
//                     var permission = (string)_json["permission"];
//                     onPermissionCallBack?.Invoke(permission, state);
//                     onPermissionCallBack = null;
//                     break;
//                 }
//             case CodeA2U.FreePlatformInitOk:
 
//                 if (onFreePlatformInitOk != null)
//                 {
//                     onFreePlatformInitOk();
//                 }
 
//                 break;
//             case CodeA2U.FreePlatformInitFail:
//                 if (onFreePlatformInitFail != null)
//                 {
//                     onFreePlatformInitFail();
//                 }
//                 break;
//             case CodeA2U.FreePlatformRegisterOk:
//                 // HandleFreePlatformRegisteOk(_json);
//                 OperationLogCollect.Instance.RecordEvent(5);
//                 var values = new JsonData();
//                 if (_json.Keys.Contains("reg_type"))
//                     values["af_registration_method"] = _json["reg_type"];
//                 break;
//             case CodeA2U.FreePlatformLoginOk:
//                 HandleFreePlatformLoginOk(_json["info"]);
//                 OperationLogCollect.Instance.RecordEvent(6);
//                 break;
//             case CodeA2U.FreePlatformLoginFail:
//                 if (onFreePlatformLoginFail != null)
//                 {
//                     onFreePlatformLoginFail();
//                 }
//                 break;
//             case CodeA2U.FreePlatformLogoutOk:
//                 if (onFreePlatformLogoutOk != null)
//                 {
//                     onFreePlatformLogoutOk();
//                 }
//                 FreePlatformInfo = null;
//                 break;
//             case CodeA2U.FreePlatformSwitchAccountOk:
//                 BuildFreePlatformInfo(_json["info"]);
//                 if (onFreePlatformLogoutOk != null)
//                 {
//                     onFreePlatformLogoutOk();
//                 }
//                 FreePlatformInfo = null;
//                 break;
//             case CodeA2U.FreePlatformLogoutFail:
//                 if (onFreePlatformLogoutFail != null)
//                 {
//                     onFreePlatformLogoutFail();
//                 }
//                 break;
//             case CodeA2U.FreePlatformPayOk:
//                 if (onFreePlatformPayOk != null)
//                 {
//                     onFreePlatformPayOk();
//                 }
//                 //SnxxzGame.Instance.StartCoroutine(DelayQueryRecharge());
//                 break;
//             case CodeA2U.FreePlatformPayFail:
//                 if (onFreePlatformPayFail != null)
//                 {
//                     onFreePlatformPayFail();
//                 }
//                 break;
//             case CodeA2U.FreePlatformPayCancel:
//                 if (onFreePlatformPayCancel != null)
//                 {
//                     onFreePlatformPayCancel();
//                 }
//                 break;
//             case CodeA2U.ShareCallBack:
//                 {
//                     var state = int.Parse(_json["state"].ToString());
//                     if (state == CallBackState.Success)
//                         LocalSave.SetInt("ShareToFBDay" + PlayerDatas.Instance.baseData.PlayerID, TimeUtility.ServerNow.DayOfYear);
 
//                     onShareFBResult?.Invoke();
//                     break;
//                 }
//             case CodeA2U.ExitGame:
//                 if (ChannelPlatform == E_ChannelPlatform.Free)
//                 {
//                     vnxbqy.UI.WindowCenter.Instance.Open<vnxbqy.UI.ExitGameWin>();
//                 }
//                 else
//                 {
//                     //默认都是退出游戏
//                     Application.Quit();
//                 }
//                 break;
//         }
//         onSdkMsg?.Invoke(_code, _json);
    }
 
    #endregion
 
    #region 交互相关约定编号
 
    //回调的相关状态
    public static class CallBackState
    {
        public const int Cancel = 0;
        public const int Success = 1;
        public const int Error = 2;
    }
 
    public static class CodeA2U
    {
        #region 基础sdk_code
        /**
         * 资源拷贝完成
         */
        public const int AssetCopyFinished = 0;
        /**
         * 电量改变
         */
        public const int BatteryLevel = 1;
        /**
         * 充电状态改变
         */
        public const int BatteryCharging = 2;
        /**
         * 回调sdk逻辑完毕
         * */
        public const int SdkInitComplete = 3;
        /**
         * 回调android设备信息
         * */
        public const int DeviceInfo = 4;
        /**
         * 回调推送的独立id
         * */
        public const int PushClientID = 5;
        /**
         * 回调外部存储根目录地址
         */
        public const int ExternalStorage = 6;
        /**
         * 触发了退出游戏逻辑, 打开二次确认界面
         */
        public const int ExitGame = 7;
 
        /**
        * 权限申请结果
        */
        public const int PermissionCallBack = 8;
 
        #endregion
 
        #region 自由sdk_code
        public const int FreePlatformInitOk = 100;
        public const int FreePlatformInitFail = 101;
        public const int FreePlatformLoginOk = 102;
        public const int FreePlatformLoginFail = 103;
        public const int FreePlatformLoginCancel = 104;
        public const int FreePlatformLogoutOk = 105;
        public const int FreePlatformLogoutFail = 106;
        public const int FreePlatformSwitchAccountOk = 107;
        public const int FreePlatformPayOk = 108;
        public const int FreePlatformPayFail = 109;
        public const int FreePlatformPayCancel = 110;
        public const int FreePlatformRegisterOk = 111;
        public const int ShareCallBack = 112;
        public const int PingfenCallBack = 113;  //评分回调 和 GotoShopOK 不一样 具体看使用区分
        public const int GotoShopOK = 115;  //前往商店成功
        public const int GotoFBOK = 116;
        #endregion
    }
 
    private static class CodeU2A
    {
        /**
         * 执行资源拷贝
         */
        public const int CopyAsset = 0;
        /**
         * 执行开始电量改变,充电状态改变监听
         */
        public const int BatteryListenStart = 1;
        /**
         * 执行停止电量改变,充电状态改变监听
         */
        public const int BatteryListenStop = 2;
        /**
         * 获取唯一识别码
         */
        public const int UniqueID = 3;
        /**
         * 申请在AndroidManifest文件中
         */
        public const int RequestManifestPermissions = 4;
        /**
         * 单独动态申请某一个权限
         */
        public const int RequestPermission = 5;
        /**
         * 重启应用
         */
        public const int RestartApp = 6;
        /**
         * 拷贝文本信息
         */
        public const int CopyContent = 7;
        /**
         * 打开网址
         */
        public const int OpenWebView = 8;
        /**
         * SDK初始化, 完全自动初始化的流程, 完成必要逻辑后再回调回去
         */
        public const int Init = 9;
        /**
         * 安装应用
         */
        public const int InstallAPK = 10;
        /**
         * 外部存储根目录地址
         */
        public const int ExteneralStorage = 11;
        public const int CopyOneAsset = 12;
 
        //打开应用商店
        public const int GoToAppStore = 13;
 
        // 启动时申请权限,申请规则sdk决定
        public const int RequestPermissionStart = 14;
 
        /**
         * 自由sdk相关
         * */
        public const int FreePlatformInit = 100;
        public const int FreePlatformLogin = 101;
        public const int FreePlatformLogout = 102;
        public const int FreePlatformSwitchAccount = 103;
        public const int FreePlatformPay = 104;
        public const int PayFinished = 105;
        public const int CreateRole = 106;
        public const int RoleLogin = 107;
        public const int RoleLevelUp = 108;
        public const int TencentLogin = 109;
        public const int DownloadStart = 110;
        public const int DownloadEnd = 111;
        public const int ShareToFaceBook = 112;
        public const int GoToPingfen = 113;  //前往评分  和 GotoShop = 121; 有区别
        public const int ShowAccountView = 114;
        public const int RoleLoginOut = 119; //角色登出
        public const int FansHouse = 120; //粉丝屋 论坛等
        public const int GotoShop = 121; //前往商店
        public const int TrackEvent = 122; //自定义事件
        /**
         * 极光推送
         * */
        public const int JPushAddLocalMessage = 200;
        public const int JPushRemoveLocalMessage = 201;
        /**
         * IOS特殊需求
         */
        public const int MakeKeyAndVisible = 300;
        /**
         * ClientPackage向sdk发送分包id
         */
        public const int ClientPackage = 400;
        /**
         * 发送注册事件
         */
        public static int SendRegistEvent = 500;
        /**
         * 发送注册事件
         */
        public static int SendLoginEvent = 600;
        /**
         * 隐藏悬浮窗
         */
        public static int HideFloatIcon = 700;
        /**
         * 显示悬浮窗
         */
        public static int ShowFloatIcon = 701;
 
 
    }
 
    #endregion
    public class DeviceInfo
    {
        public string imei;
        public string macAddress;
        public string androidID;
        public string uniqueID;
        public string userAgent;
        public int totalMemory;
    }
 
    #region 自由sdk相关
 
    public UnityAction onFreePlatformInitOk;
    public UnityAction onFreePlatformInitFail;
    public UnityAction<FP_LoginOk> onFreePlatformLoginOk;
    public UnityAction onFreePlatformLoginFail;
    public UnityAction onFreePlatformLogoutOk;
    public UnityAction onFreePlatformLogoutFail;
    public UnityAction onFreePlatformPayOk;
    public UnityAction onFreePlatformPayFail;
    public UnityAction onFreePlatformPayCancel;
    public UnityAction onFreePlatformBindOk;
    public UnityAction onFreePlatformBindFail;
    public UnityAction onShareFBResult;
    public class FP_LoginOk
    {
        public string account;//必选,账号
        public string token;//必选
        public string tokenExpire;
        public int phone;
        public int accountID;
        public string gameId;
        public string timeStamp;
        public string sessionID;
        public string yjAppId;
        public string yjSdkId;
        public string qkUserName; // 目前当做原始UID使用,因为游戏中会统一小写
    }
 
    public struct FP_CheckIDAuthentication
    {
        public string errorcode;
        public string errordesc;
        public string type;
        public string card_id;
    }
 
    public struct FP_DoIDAuthentication
    {
        public string errorcode;
        public string errordesc;
        public string card_id;
    }
 
    string authenticationCardId = "";
    public string channelId = "1000";
    public string platfromId = "1000";
 
    public void FreePlatformInit()
    {
#if !UNITY_EDITOR
        m_Json.Clear();
        m_Json["code"] = CodeU2A.FreePlatformInit;
        SendMessageToSDK(m_Json);
#endif
    }
 
    public void FreePlatformBindPhone()
    {
#if UNITY_ANDROID
        AndroidJavaClass _jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject _jo = _jc.GetStatic<AndroidJavaObject>("currentActivity");
        _jo.Call("BindPhone");
#endif
    }
 
    /// <summary>
    /// 自由SDK登陆
    /// </summary>
    public void FreePlatformLogin()
    {
        m_Json.Clear();
        m_Json["code"] = CodeU2A.FreePlatformLogin;
        SendMessageToSDK(m_Json);
    }
 
    public void TencentLogin(string param)
    {
#if !UNITY_EDITOR
        m_Json.Clear();
        m_Json["code"] = CodeU2A.TencentLogin;
        if (!string.IsNullOrEmpty(param))
        {
            m_Json["param"] = param;
        }
        SendMessageToSDK(m_Json);
#endif
    }
 
    /// <summary>
    /// 自由SDK登出
    /// </summary>
    public void FreePlatformLoginout()
    {
#if !UNITY_EDITOR
        m_Json.Clear();
        m_Json["code"] = CodeU2A.FreePlatformLogout;
        SendMessageToSDK(m_Json);
        if (ChannelPlatform == E_ChannelPlatform.Yl)
        {
            FreePlatformLogin();
        }
#endif
    }
    public void ShowAccountView()
    {
#if !UNITY_EDITOR
        m_Json.Clear();
        m_Json["code"] = CodeU2A.ShowAccountView;
        SendMessageToSDK(m_Json);
        if (ChannelPlatform == E_ChannelPlatform.Yl)
        {
            FreePlatformLogin();
        }
#endif
    }
    public void FreePlatformSwitchAccount()
    {
#if UNITY_ANDROID
        AndroidJavaClass _jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject _jo = _jc.GetStatic<AndroidJavaObject>("currentActivity");
        _jo.Call("SwitchAccount");
#endif
    }
 
    private Dictionary<string, string> m_PaymentTable = new Dictionary<string, string>();
    private string m_EncodeKey = "03sujm7gerywdvyd5vkkk772rs4by230";
 
    //private IEnumerator DelayQueryRecharge()
    //{
    //    yield return WaitingForSecondConst.WaitMS3000;
    //    var _package = new CA806_tagCMQueryRecharge();
    //    GameNetSystem.Instance.SendInfo(_package);
 
    //}
 
    /// <summary>
    /// 自由SDK支付 fixed sdk 支付逻辑修改
    /// </summary>
    /// 
    public void FreePlatformPay(string title, float money, string cpInfo)
    {
        // 提示是否使用代金券
        // var gameCash = UIHelper.GetAllVourcher();
 
        // bool isBuyGameCash = false; //代金券本身的充值不能用代金券购买 造成循环
        // int ctgID = ModelCenter.Instance.GetModel<VipModel>().orderInfoToCTGID[cpInfo];
        // if (ctgID != 0)
        // {
        //     isBuyGameCash = CTGConfig.Get(ctgID).PayType == 17;
        // }
 
 
        // if (!isBuyGameCash && gameCash >= money * 100 && !LoginAwardModel.rechargeLimit.Contains(ctgID))
        // {
 
        //     WindowCenter.Instance.Close<GotoChargeWin>();
        //     if (DayRemind.Instance.GetDayRemind(DayRemind.DJQTip))
        //     {
        //         var pack = new CA125_tagCMCoinBuyOrderInfo();
        //         pack.AppID = VersionConfig.Get().appId;
        //         pack.AppIDLen = (byte)pack.AppID.Length;
        //         pack.OrderInfo = cpInfo;
        //         pack.OrderInfoLen = (byte)pack.OrderInfo.Length;
        //         GameNetSystem.Instance.SendInfo(pack);
        //     }
        //     else
        //     {
        //         ConfirmCancel.ToggleConfirmCancel(Language.Get("Mail101"), Language.Get("GameCashRule1", money), Language.Get("TodayNoNotify"), (bool isOk, bool isToggle) =>
        //         {
        //             if (isOk)
        //             {
        //                 var pack = new CA125_tagCMCoinBuyOrderInfo();
        //                 pack.AppID = VersionConfig.Get().appId;
        //                 pack.AppIDLen = (byte)pack.AppID.Length;
        //                 pack.OrderInfo = cpInfo;
        //                 pack.OrderInfoLen = (byte)pack.OrderInfo.Length;
        //                 GameNetSystem.Instance.SendInfo(pack);
        //             }
        //             if (isToggle)
        //             {
        //                 DayRemind.Instance.SetDayRemind(DayRemind.DJQTip, true);
        //             }
        //         });
        //     }
        // }
        // else
        // { 
        //     FreePlatformPayEx(title, money, cpInfo);
        // }
    }
 
    public void FreePlatformPayEx(string title, float money, string cpInfo)
    {
//         OrderInfoConfig orderInfo = null;
//         VipModel vipModel = ModelCenter.Instance.GetModel<VipModel>();
//         if (vipModel.orderInfoToCTGID.ContainsKey(cpInfo) && vipModel.orderInfoToCTGID[cpInfo] != 0)
//         {
//             vipModel.TryGetOrderInfo(vipModel.orderInfoToCTGID[cpInfo], out orderInfo);
//         }
//         else
//         {
//             var keys = OrderInfoConfig.GetKeys();
//             for (int i = 0; i < keys.Count; i++)
//             {
//                 orderInfo = OrderInfoConfig.Get(keys[i]);
//                 if (orderInfo != null && orderInfo.OrderInfo == cpInfo)
//                 {
//                     break;
//                 }
//             }
//         }
// //#if !(UNITY_IOS || UNITY_IPHONE)
// //        string storeOrderInfo = orderInfo.StoreOrderInfo;
// //#else
// //        string storeOrderInfo = orderInfo.StoreOrderInfo2;
// //#endif
 
// #if UNITY_EDITOR
//         Debug.LogFormat("充值: {0}-{1}-{2}", title, money, cpInfo);
//         return;
// #endif
 
//         m_Json.Clear();
//         m_Json["code"] = CodeU2A.FreePlatformPay;
//         m_Json["orderId"] = DateTime.Now.ToString("yyyyMMddHHmmss") + UnityEngine.Random.Range(100000, 999999).ToString();
//         m_Json["mount"] = money.ToString();
//         m_Json["cpInfo"] = cpInfo;
//         //m_Json["storeOrderInfo"] = storeOrderInfo;
//         m_Json["title"] = title;
//         m_Json["roleID"] = PlayerDatas.Instance.baseData.PlayerID;
//         m_Json["roleName"] = PlayerDatas.Instance.baseData.PlayerName;
//         m_Json["level"] = PlayerDatas.Instance.baseData.LV.ToString();
//         m_Json["sid"] = ServerListCenter.Instance.currentServer.region_flag;
//         m_Json["serverName"] = ServerListCenter.Instance.currentServer.name;
//         m_Json["familyName"] = PlayerDatas.Instance.baseData.FamilyName;
//         m_Json["job"] = PlayerDatas.Instance.baseData.Job.ToString();
//         m_Json["money"] = PlayerDatas.Instance.baseData.diamond.ToString();
//         m_Json["gameName"] = VersionConfig.Get().productName;
//         m_Json["vipLevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString();
//         m_Json["createTime"] = TimeUtility.CreateSeconds.ToString();
//         m_Json["familyID"] = PlayerDatas.Instance.baseData.FamilyId.ToString();
//         m_Json["fightPower"] = PlayerDatas.Instance.baseData.FightPoint.ToString();
 
// #if UNITY_IOS
//         m_Json["identifier"] = VersionConfig.Get().bundleIdentifier;
// #endif
//         SendMessageToSDK(m_Json);
    }
 
 
    /// <summary>
    ///  分享到facebook
    /// /// </summary>
    public void ShareToFaceBook(int type)
    {
        // Debug.Log("越南分享");
        // m_Json.Clear();
        // m_Json["code"] = CodeU2A.ShareToFaceBook;
        // m_Json["type"] = type;
        // SendMessageToSDK(m_Json);
    }
 
    /// <summary>
    /// 去商店评论
    /// </summary>
    public void GoToPingfen()
    {
        // Debug.Log("越南评分");
        // m_Json.Clear();
        // m_Json["code"] = CodeU2A.GoToPingfen;
        // SendMessageToSDK(m_Json);
    }
 
    //前往商店
    public void GoToShop()
    {
        // m_Json.Clear();
        // m_Json["code"] = CodeU2A.GotoShop;
        // SendMessageToSDK(m_Json);
    }
 
 
    /**
     * @param context
     * @param event 事件名
     * @param value 事件值,如果没有可以传""
     * @param isRepeatReport 是否重复上报。根据运营需求是否排重上报,true可以重复上报,false仅上报一次
     */
    public void TraceEvent(string eventName, string value, bool isRepeatReport)
    {
        // Debug.Log("越南事件汇报 :" + eventName);
        // m_Json.Clear();
        // m_Json["code"] = CodeU2A.TrackEvent;
        // m_Json["eventName"] = eventName;
        // m_Json["value"] = value;
        // m_Json["isRepeatReport"] = isRepeatReport;
        // SendMessageToSDK(m_Json);
    }
 
    private void BuildFreePlatformInfo(JsonData json)
    {
        // if (FreePlatformInfo == null)
        // {
        //     FreePlatformInfo = new FP_LoginOk();
        // }
 
        // IDictionary _iDict = json as IDictionary;
 
        // if (_iDict.Contains("token"))
        // {
        //     FreePlatformInfo.token = json["token"].ToString();
        // }
        // if (_iDict.Contains("token_expire"))
        // {
        //     FreePlatformInfo.tokenExpire = json["token_expire"].ToString();
        // }
        // else
        // {
        //     FreePlatformInfo.tokenExpire = "";
        // }
        // if (_iDict.Contains("account"))
        // {
        //     FreePlatformInfo.account = json["account"].ToString();
        // }
 
        // if (_iDict.Contains("account_id"))
        // {
        //     int.TryParse(json["account_id"].ToString(), out FreePlatformInfo.accountID);
        // }
 
        // if (_iDict.Contains("session_id"))
        // {
        //     FreePlatformInfo.sessionID = (string)json["session_id"];
        // }
 
        // if (_iDict.Contains("game_id"))
        // {
        //     FreePlatformInfo.gameId = (string)json["game_id"];
        // }
 
        // if (_iDict.Contains("timeStamp"))
        // {
        //     FreePlatformInfo.timeStamp = (string)json["timeStamp"];
        // }
        // if (_iDict.Contains("userName"))
        // {
        //     FreePlatformInfo.qkUserName = json["userName"].ToString();
        // }
        // FreePlatformInfo.phone = 0;
    }
 
    private void HandleFreePlatformRegisteOk(JsonData json)
    {
        // BuildFreePlatformInfo(json);
    }
 
    private void HandleFreePlatformLoginOk(JsonData data)
    {
        // BuildFreePlatformInfo(data);
 
        // Debug.LogFormat("sdk登录成功:{0}", data.ToJson());
        // if (onFreePlatformLoginOk != null)
        // {
        //     onFreePlatformLoginOk(FreePlatformInfo);
        // }
    }
 
 
    // public void OnServerChargeOk(HA106_tagMCCoinToGoldReport pack)
    // {
    //     string orderID = pack.OrderID;
    //     uint coin = pack.Coin;
    //     OperationLogCollect.Instance.RecordEvent(9, coin);
 
    //     if (onFreePlatformPayOk != null)
    //     {
    //         onFreePlatformPayOk();
    //     }
 
    //     m_Json.Clear();
    //     m_Json["code"] = CodeU2A.PayFinished;
    //     m_Json["orderID"] = orderID;
    //     m_Json["payType"] = "_default_";
    //     m_Json["moneyType"] = "CNY";
    //     m_Json["money"] = (float)coin / 100;
    //     SendMessageToSDK(m_Json);
    // }
 
    public void SendRegistEvent(bool _ok, string _result)
    {
        if (_ok)
        {
            if (!_result.Equals("0"))
            {
                m_Json.Clear();
                m_Json["code"] = CodeU2A.SendRegistEvent;
                SendMessageToSDK(m_Json);
            }
        }
    }
 
    public void SendLoginEvent()
    {
        m_Json.Clear();
        m_Json["code"] = CodeU2A.SendLoginEvent;
        SendMessageToSDK(m_Json);
    }
 
    public void SendHideFloatWin()
    {
        m_Json.Clear();
        m_Json["code"] = CodeU2A.HideFloatIcon;
        SendMessageToSDK(m_Json);
    }
 
    public void SendShowFloatWin()
    {
        m_Json.Clear();
        m_Json["code"] = CodeU2A.ShowFloatIcon;
        SendMessageToSDK(m_Json);
    }
 
    public void CreateRoleOk(string roleID, string roleName, string time)
    {
        // m_Json.Clear();
        // m_Json["code"] = CodeU2A.CreateRole;
 
        // m_Json["roleID"] = roleID;
        // m_Json["roleName"] = roleName;
        // m_Json["sid"] = ServerListCenter.Instance.currentServer.region_flag;
        // m_Json["serverName"] = ServerListCenter.Instance.currentServer.name;
        // m_Json["familyName"] = PlayerDatas.Instance.baseData.FamilyName;
        // m_Json["level"] = "1";
        // m_Json["job"] = PlayerDatas.Instance.baseData.Job.ToString();
        // m_Json["money"] = PlayerDatas.Instance.baseData.diamond.ToString();
        // m_Json["gameName"] = VersionConfig.Get().productName;
        // m_Json["vipLevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString();
        // m_Json["createTime"] = time;
        // m_Json["familyID"] = PlayerDatas.Instance.baseData.FamilyId.ToString();
        // m_Json["fightPower"] = PlayerDatas.Instance.baseData.FightPoint.ToString();
        // SendMessageToSDK(m_Json);
    }
 
    public void DownloadStart()
    {
        m_Json.Clear();
        m_Json["code"] = CodeU2A.DownloadStart;
 
        SendMessageToSDK(m_Json);
    }
 
    public void DownloadEnd()
    {
        m_Json.Clear();
        m_Json["code"] = CodeU2A.DownloadEnd;
 
        SendMessageToSDK(m_Json);
    }
 
    public void RoleLogin()
    {
        // m_Json.Clear();
        // m_Json["code"] = CodeU2A.RoleLogin;
 
        // m_Json["roleID"] = PlayerDatas.Instance.baseData.PlayerID.ToString();
        // m_Json["roleName"] = PlayerDatas.Instance.baseData.PlayerName;
        // m_Json["sid"] = ServerListCenter.Instance.currentServer.region_flag;
        // m_Json["serverName"] = ServerListCenter.Instance.currentServer.name;
        // m_Json["familyName"] = PlayerDatas.Instance.baseData.FamilyName;
        // m_Json["level"] = PlayerDatas.Instance.baseData.LV;
        // m_Json["job"] = PlayerDatas.Instance.baseData.Job.ToString();
        // m_Json["money"] = PlayerDatas.Instance.baseData.diamond.ToString();
        // m_Json["gameName"] = VersionConfig.Get().productName;
        // m_Json["vipLevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString();
        // m_Json["createTime"] = TimeUtility.CreateSeconds.ToString();
        // m_Json["familyID"] = PlayerDatas.Instance.baseData.FamilyId.ToString();
        // m_Json["fightPower"] = PlayerDatas.Instance.baseData.FightPoint.ToString();
        // SendMessageToSDK(m_Json);
    }
 
    public void RoleLevelUp()
    {
        m_Json.Clear();
        m_Json["code"] = CodeU2A.RoleLevelUp;
 
        m_Json["roleID"] = PlayerDatas.Instance.PlayerId.ToString();
        m_Json["roleName"] = PlayerDatas.Instance.baseData.PlayerName;
        m_Json["sid"] = ServerListCenter.Instance.currentServer.region_flag;
        m_Json["serverName"] = ServerListCenter.Instance.currentServer.name;
        m_Json["familyName"] = PlayerDatas.Instance.baseData.FamilyName;
        m_Json["level"] = PlayerDatas.Instance.baseData.LV;
        m_Json["job"] = PlayerDatas.Instance.baseData.Job.ToString();
        m_Json["money"] = PlayerDatas.Instance.baseData.diamond.ToString();
        m_Json["gameName"] = VersionConfig.Get().productName;
        m_Json["vipLevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString();
        m_Json["levelUpTime"] = TimeUtility.AllSeconds.ToString();
        m_Json["createTime"] = TimeUtility.CreateSeconds.ToString();
        m_Json["familyID"] = PlayerDatas.Instance.baseData.FamilyId.ToString();
        m_Json["fightPower"] = PlayerDatas.Instance.baseData.FightPoint.ToString();
        SendMessageToSDK(m_Json);
    }
 
 
    public void RoleLoginOut()
    {
        if (PlayerDatas.Instance.PlayerId == 0)
            return;
        
        if (!DTC0403_tagPlayerLoginLoadOK.finishedLogin) 
            return;
 
        m_Json.Clear();
        m_Json["code"] = CodeU2A.RoleLoginOut;
 
        m_Json["roleID"] = PlayerDatas.Instance.PlayerId.ToString();
        m_Json["roleName"] = PlayerDatas.Instance.baseData.PlayerName;
        m_Json["sid"] = ServerListCenter.Instance.currentServer.region_flag;
        m_Json["serverName"] = ServerListCenter.Instance.currentServer.name;
        m_Json["familyName"] = PlayerDatas.Instance.baseData.FamilyName;
        m_Json["level"] = PlayerDatas.Instance.baseData.LV;
        m_Json["job"] = PlayerDatas.Instance.baseData.Job.ToString();
        m_Json["money"] = PlayerDatas.Instance.baseData.diamond.ToString();
        m_Json["gameName"] = VersionConfig.Get().productName;
        m_Json["vipLevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString();
        m_Json["levelUpTime"] = TimeUtility.AllSeconds.ToString();
        m_Json["createTime"] = TimeUtility.CreateSeconds.ToString();
        m_Json["familyID"] = PlayerDatas.Instance.baseData.FamilyId.ToString();
        m_Json["fightPower"] = PlayerDatas.Instance.baseData.FightPoint.ToString();
        SendMessageToSDK(m_Json);
    }
 
    public void GotoFansHouse()
    {
        Debug.Log("越南点赞");
        m_Json.Clear();
        m_Json["code"] = CodeU2A.FansHouse;
 
        SendMessageToSDK(m_Json);
    }
 
#endregion
 
    #region 插件相关
 
    #endregion
 
    #region 极光推送相关
    public void GeTui_SendLocalMessage(JsonData jsonData)
    {
        return;
        Debug.Log("GeTui_SendLocalMessage:" + jsonData["id"]);
        //      ------ 举例 ------
        //        JsonData _params = new JsonData ();
        //        _params ["code"] = 2005;
        //        _params ["id"] = 5;// id 重要, 标示每个通知的更新或者移除
        //        _params ["title"] = "the title";// 推送标题
        //        _params ["subtitle"] = "the subtitle";// 副标题
        //        _params ["content"] = "the content";// 具体内容
        //        _params ["badge"] = -1;// 角标
        //
        //        // 以下为决定应该多久后弹出此通知
        //        System.TimeSpan ts = System.DateTime.UtcNow - new System.DateTime (1970, 1, 1, 0, 0, 0, 0);
        //        long ret = System.Convert.ToInt64 (ts.TotalSeconds) + 3;// 表示3秒后
        //        _params ["fireTime"] = ret;
#if !UNITY_EDITOR
        jsonData["code"] = CodeU2A.JPushAddLocalMessage;
#if UNITY_ANDROID
        jsonData["fireTime"] = (long)jsonData["fireTime"] * 1000;
#endif
        SendMessageToSDK(jsonData);
#endif
    }
 
    public void GeTui_RemoveLocalMessage(string id)
    {
        return;
        Debug.Log("GeTui_RemoveLocalMessage:" + id);
#if !UNITY_EDITOR
        m_Json.Clear();
        m_Json["code"] = CodeU2A.JPushRemoveLocalMessage;
        m_Json["id"] = id;// id 重要, 标示每个通知的更新或者移除
 
        SendMessageToSDK(m_Json);
#endif
    }
 
    #endregion
}