JsbSystem.ts 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. import { DataEventId } from "../../game/data/GameData";
  2. import ATSDKMgr from "../sdk/ad/toppon/AnyThinkAdsMgr/ATSDKMgr";
  3. /**
  4. * Jsb管理类(与安卓Java类或者IOS交互)
  5. * @description
  6. * @author 冯聪
  7. */
  8. export default class JsbSystem {
  9. /**代码桥在AS中的路径 */
  10. private static _JSB_ANDROID_PATH: string = "org/cocos2dx/javascript/thirdSdk/ThirdSdkMgr";
  11. /**代码桥在IOS中的路径 */
  12. private static _JSB_IOS_PATH: string = "ThirdSdkMgr";
  13. /**代码桥在AS中的路径 */
  14. private static _JSB_ANDROID_PATH_JSDK: string = "org/cocos2dx/javascript/thirdSdk/ysdk/YSDKMgr";
  15. //callBack
  16. public static callBack: Function = null;
  17. /**
  18. * 是否文件存在
  19. * @param filePath 文件路径
  20. * @returns 是否文件存在 boolean
  21. */
  22. public static isFileExist(fileName: string): boolean {
  23. if (cc.sys.os == cc.sys.OS_WINDOWS) {
  24. return true;
  25. }
  26. let filePath = this.getWritablePath() + fileName + ".apk";
  27. return jsb.fileUtils.isFileExist(filePath);
  28. }
  29. /**
  30. * 获取写入的路径
  31. * @description
  32. * @returns path 写入路径(string)
  33. */
  34. public static getWritablePath(): string {
  35. return jsb.fileUtils.getWritablePath();
  36. }
  37. /**
  38. * 调用项目工程静态方法
  39. * @description 调用Android与IOS对应的静态方法
  40. * @param path 调用路径:"org/cocos2dx/javascript/AppActivity":java中的包名(.换成/)+class文件名,就当是路径好了
  41. * @param methodName 调用的方法名:必须public static
  42. * @param methodSignature 方法签名:“(Ljava/lang/String;)Ljava/lang/String;”:()内的是调用的java方法的参数类型,()外面的是返回值类
  43. * @param parameters 参数:是java方法需要传入的参数(可以多个,与methodSignature中()内的数量和类型一一对应)
  44. */
  45. public static callStaticMethod(path: string, methodName: string, methodSignature: string, ...parameters: any): any {
  46. let value = jsb.reflection.callStaticMethod(path, methodName, methodSignature, ...parameters);
  47. return value;
  48. }
  49. /**
  50. * Java调用返回测试
  51. * @description 自定义功能 JavaToCocos
  52. */
  53. public static backTest() {
  54. }
  55. /**
  56. * 更新设备信息
  57. * @description 自定义功能 JavaToCocos
  58. * @param info info(Java返回)
  59. */
  60. public static updateDeviceInfo(info) {
  61. mk.console.log("===[JsbSystem] updateDeviceInfo", info)
  62. if (cc.sys.os == cc.sys.OS_ANDROID) {
  63. gData.appData.updateDeviceInfo(info);
  64. }
  65. else if (cc.sys.os == cc.sys.OS_IOS) {
  66. }
  67. }
  68. /** 获取手机授权 */
  69. public static checkPermission() {
  70. if (CC_DEBUG) {
  71. gData.appData.mac = '07:16:ec:c3:d3:55,79:46:dc:dd:b7:13';
  72. gData.appData.machineInfo.mac = gData.appData.mac;
  73. gData.appData.getDeviceInfoCompelete = true;
  74. }
  75. if (cc.sys.os == cc.sys.OS_ANDROID) {
  76. this.callStaticMethod(this._JSB_ANDROID_PATH, "checkPermission", "()V");
  77. }
  78. else if (cc.sys.os == cc.sys.OS_IOS) {
  79. jsb.reflection.callStaticMethod("GameConfig", "checkPermission:", "");
  80. }
  81. }
  82. /**
  83. * 获取设备信息
  84. * @description 自定义功能 CocosToJava
  85. */
  86. public static getDeviceInfo() {
  87. let deviceInfo = "";
  88. if (cc.sys.os == cc.sys.OS_ANDROID) {
  89. deviceInfo = this.callStaticMethod(this._JSB_ANDROID_PATH, "getDeviceInfo", "()Ljava/lang/String;");
  90. console.log("===[JsbSystem] getDeviceInfo ", deviceInfo);
  91. gData.appData.updateDeviceInfo(deviceInfo);
  92. }
  93. else if (cc.sys.os == cc.sys.OS_IOS) {
  94. this.callStaticMethod(this._JSB_IOS_PATH, "getDeviceInfo", "");
  95. }
  96. else {
  97. gData.appData.getDeviceInfoCompelete = true;
  98. }
  99. }
  100. /**
  101. * 获取包名
  102. * @description 自定义功能 CocosToJava
  103. * @returns packName 包名
  104. */
  105. public static getPackageName() {
  106. let packName = '';
  107. if (cc.sys.os == cc.sys.OS_ANDROID) {
  108. packName = this.callStaticMethod(this._JSB_ANDROID_PATH, "getPackageName", "()Ljava/lang/String;");
  109. }
  110. else if (cc.sys.os == cc.sys.OS_IOS) {
  111. packName = this.callStaticMethod("CsjAdReward", "getPackageName", "");
  112. }
  113. return packName;
  114. }
  115. /**
  116. * 获取appid 和 配置version
  117. * @description 自定义功能 CocosToJava
  118. * @returns appid
  119. */
  120. public static getWxAppId() {
  121. let unicodeStr = "";
  122. if (cc.sys.os == cc.sys.OS_ANDROID) {
  123. unicodeStr = this.callStaticMethod(this._JSB_ANDROID_PATH, "getWxAppId", "()Ljava/lang/String;");
  124. }
  125. else if (cc.sys.os == cc.sys.OS_IOS) {
  126. unicodeStr = this.callStaticMethod("CsjAdReward", "getWxAppId", "",);
  127. }
  128. let unicodeArr = unicodeStr.split(';');
  129. if (unicodeArr) {
  130. gData.appData.appId = unicodeArr[0];
  131. gData.appData.version = unicodeArr[1];
  132. }
  133. if (CC_DEBUG) {
  134. //gData.appData.appId = "wx3c0cc2f730c5ad5a";
  135. //gData.appData.version = "1.0.0";
  136. gData.appData.appId = "wxd413dcac1e6a74c9";
  137. gData.appData.version = "13.1.8";
  138. }
  139. // console.log('gData.appData ', unicodeStr)
  140. // console.log('gData.appData.appId ', gData.appData.appId)
  141. // console.log('gData.appData.version ', gData.appData.version)
  142. }
  143. /**
  144. * 获取广告渠道和相关id
  145. * @description 自定义功能 CocosToJava
  146. * @returns str
  147. */
  148. public static getAdvertisingChannel(): string {
  149. let str = "";
  150. if (cc.sys.os == cc.sys.OS_ANDROID) {
  151. str = this.callStaticMethod(this._JSB_ANDROID_PATH, "getAdvertisingChannel", "()Ljava/lang/String;");
  152. }
  153. else if (cc.sys.os == cc.sys.OS_IOS) {
  154. str = this.callStaticMethod("CsjAdReward", "AdvertisingChannel", "");
  155. }
  156. return str;
  157. }
  158. /** 显示开屏 */
  159. static showSplash() {
  160. // mk.data.sendDataEvent('slashAd', '开屏')
  161. if (cc.sys.os == cc.sys.OS_ANDROID) {
  162. this.callStaticMethod(this._JSB_ANDROID_PATH, "showSplash", "(Ljava/lang/String;)V", ATSDKMgr.topon_splash_placementId);
  163. }
  164. else if (cc.sys.os == cc.sys.OS_IOS) {
  165. jsb.reflection.callStaticMethod("GameConfig", "showSplash:", "");
  166. }
  167. }
  168. /**
  169. * 复制到剪切板
  170. * @description Andorid功能 CocosToJava
  171. * @param str 剪切板字符串内容
  172. */
  173. public static setClipboard(str: string) {
  174. if (cc.sys.os == cc.sys.OS_ANDROID) {
  175. this.callStaticMethod(this._JSB_ANDROID_PATH, "setClipboard", "(Ljava/lang/String;)V", str);
  176. }
  177. else if (cc.sys.os == cc.sys.OS_IOS) {
  178. }
  179. else if (cc.sys.isBrowser) {
  180. var input = str;
  181. const el: any = document.createElement('textarea');
  182. el.value = input;
  183. el.setAttribute('readonly', '');
  184. el.style.contain = 'strict';
  185. el.style.position = 'absolute';
  186. el.style.left = '-9999px';
  187. el.style.fontSize = '12pt';
  188. const selection = getSelection();
  189. var originalRange: any = false;
  190. if (selection.rangeCount > 0) {
  191. originalRange = selection.getRangeAt(0);
  192. }
  193. document.body.appendChild(el);
  194. el.select();
  195. el.selectionStart = 0;
  196. el.selectionEnd = input.length;
  197. var success = false;
  198. try {
  199. success = document.execCommand('copy');
  200. } catch (err) { }
  201. document.body.removeChild(el);
  202. if (originalRange) {
  203. selection.removeAllRanges();
  204. selection.addRange(originalRange);
  205. }
  206. return success;
  207. }
  208. }
  209. /**
  210. * 请求用户授权
  211. * @description Andorid功能 CocosToJava
  212. */
  213. public static requestPermission() {
  214. if (cc.sys.os == cc.sys.OS_ANDROID) {
  215. this.callStaticMethod(this._JSB_ANDROID_PATH, "requestPermission", "()V");
  216. }
  217. else if (cc.sys.os == cc.sys.OS_IOS) {
  218. this.callStaticMethod("AppController", "requestPermission", "");
  219. }
  220. }
  221. /**
  222. * 获取安卓的版本号
  223. * @description Andorid功能 CocosToJava
  224. */
  225. public static getAppVersion() {
  226. if (cc.sys.os == cc.sys.OS_ANDROID) {
  227. this.callStaticMethod(this._JSB_ANDROID_PATH, "getAppVersion", "()V");
  228. }
  229. else if (cc.sys.os == cc.sys.OS_IOS) {
  230. this.callStaticMethod("AppController", "getAppVersion", "");
  231. }
  232. }
  233. /**
  234. * 设置安卓得版本号
  235. * @description Andorid功能 JavaToCocos
  236. * @param appVersion app版本号
  237. */
  238. public static setAppVersion(appVersion: string) {
  239. if (cc.sys.os == cc.sys.OS_ANDROID) {
  240. // GameConst.appVersion = appVersion;
  241. }
  242. else if (cc.sys.os == cc.sys.OS_IOS) {
  243. }
  244. }
  245. /**
  246. * 安装apk
  247. * @description Andorid功能 CocosToJava
  248. * @param apkName apkName
  249. */
  250. public static installApk(apkName: string) {
  251. let fullPath = this.getWritablePath() + apkName + ".apk";
  252. if (cc.sys.os == cc.sys.OS_ANDROID) {
  253. this.callStaticMethod(this._JSB_ANDROID_PATH, "installApk", "(Ljava/lang/String;)V", fullPath);
  254. }
  255. else if (cc.sys.os == cc.sys.OS_IOS) {
  256. this.callStaticMethod("GameConfig", "installApk:", "");
  257. }
  258. }
  259. /**
  260. * 是否可以启动游戏
  261. * @param packageName 包名
  262. * @param start 如存在是否启动
  263. * @returns ifCan
  264. */
  265. public static ifCanStartGame(packageName: string, start: boolean): boolean {
  266. let isCan = false;
  267. if (cc.sys.os == cc.sys.OS_ANDROID) {
  268. isCan = this.callStaticMethod(this._JSB_ANDROID_PATH, "isStartGame", "(Ljava/lang/String;Z)Z", packageName, start);
  269. return isCan;
  270. }
  271. else if (cc.sys.os == cc.sys.OS_IOS) {
  272. isCan = this.callStaticMethod("GameConfig", "installApk:", "");
  273. }
  274. return isCan;
  275. }
  276. /**
  277. * 数数事件注册
  278. * @description 数数SDK功能
  279. * @returns
  280. */
  281. static setTAEventRegister() {
  282. if (cc.sys.os == cc.sys.OS_ANDROID) {
  283. this.callStaticMethod(this._JSB_ANDROID_PATH, "setTAEventRegister", "()V");
  284. }
  285. else if (cc.sys.os == cc.sys.OS_IOS) {
  286. }
  287. }
  288. /**
  289. * 发送自定义事件 自定义功能 CocosToJava
  290. * @description 发送统计事件
  291. * @param key 事件的key值
  292. * @param value 事件的value值
  293. */
  294. public static sendEvent(key: string, value: string) {
  295. if (cc.sys.os == cc.sys.OS_ANDROID) {
  296. this.callStaticMethod(this._JSB_ANDROID_PATH, "sendEvent", "(Ljava/lang/String;Ljava/lang/String;)V", key, value);
  297. }
  298. else if (cc.sys.os == cc.sys.OS_IOS) {
  299. }
  300. }
  301. /**
  302. * 发送自定义事件 自定义功能 CocosToJava
  303. * @description 发送统计事件
  304. * @param key 事件的key值
  305. * @param value 事件的value值
  306. */
  307. public static sendEventValue(key: string, value: string, value1: number) {
  308. if (cc.sys.os == cc.sys.OS_ANDROID) {
  309. this.callStaticMethod(this._JSB_ANDROID_PATH, "sendEventValue", "(Ljava/lang/String;Ljava/lang/String;F)V", key, value, value1);
  310. }
  311. else if (cc.sys.os == cc.sys.OS_IOS) {
  312. }
  313. }
  314. /**
  315. * 设置人物属性
  316. * @param type 0 set 1 add
  317. * @param property 属性名
  318. * @param value 数值
  319. */
  320. public static setTAEventUser(type: number, property: string, value: number) {
  321. if (cc.sys.os == cc.sys.OS_ANDROID) {
  322. this.callStaticMethod(this._JSB_ANDROID_PATH, "setTAEventUser", "(ILjava/lang/String;F)V", type, property, value);
  323. }
  324. else if (cc.sys.os == cc.sys.OS_IOS) {
  325. }
  326. }
  327. /**
  328. * 设置人物属性
  329. * @param type 0 set 1 add
  330. * @param property 属性名
  331. * @param value 数值
  332. */
  333. public static setTAEventUserStr(type: number, property: string, value: string) {
  334. if (cc.sys.os == cc.sys.OS_ANDROID) {
  335. this.callStaticMethod(this._JSB_ANDROID_PATH, "setTAEventUserStr", "(ILjava/lang/String;Ljava/lang/String;)V", type, property, value);
  336. }
  337. else if (cc.sys.os == cc.sys.OS_IOS) {
  338. }
  339. }
  340. /** 设置人物uin到数数
  341. * id uin
  342. */
  343. public static setTAUserID(id: string) {
  344. if (cc.sys.os == cc.sys.OS_ANDROID) {
  345. this.callStaticMethod(this._JSB_ANDROID_PATH, "setTAUserID", "(Ljava/lang/String;)V", id);
  346. }
  347. else if (cc.sys.os == cc.sys.OS_IOS) {
  348. }
  349. }
  350. /**
  351. * 微信授权
  352. * @description 微信SDK功能 CocosToJava
  353. */
  354. public static WxAuth() {
  355. if (cc.sys.os == cc.sys.OS_ANDROID) {
  356. this.callStaticMethod(this._JSB_ANDROID_PATH, "WxAuth", "()V");
  357. }
  358. else if (cc.sys.os == cc.sys.OS_IOS) {
  359. this.callStaticMethod("AppController", "WxAuth", "");
  360. }
  361. }
  362. /**
  363. * 获取授权code
  364. * @description 微信SDK功能 JavaToCocos
  365. * @param code 微信code(Java返回)
  366. */
  367. public static onGetWxAccessCode(code) {
  368. // 暂时注释,需要网络通信
  369. gData.wechatData.code = code;
  370. console.log("=== gData.wechatData.code", gData.wechatData.code);
  371. mk.tip.pop("微信登陆成功,快提现吧!");
  372. gData.loginData.wxLogin();
  373. let value = mk.storage.getStorage('loadingAuth');
  374. if (!value) {
  375. mk.storage.setStorage('loadingAuth', 1);
  376. mk.data.sendDataEvent(DataEventId.loading, '微信授权登录成功');
  377. }
  378. mk.ui.closePanel('authUI');
  379. }
  380. /**
  381. * 微信打开小游戏
  382. * @description 微信SDK功能 CocosToJava
  383. */
  384. public static OpenMiniGame() {
  385. if (cc.sys.os == cc.sys.OS_ANDROID) {
  386. this.callStaticMethod(this._JSB_ANDROID_PATH, "OpenMiniGame", "()V");
  387. }
  388. else if (cc.sys.os == cc.sys.OS_IOS) {
  389. this.callStaticMethod("AppController", "WxAuth", "");
  390. }
  391. }
  392. /**
  393. * 分享成微信小游戏
  394. * @description 微信SDK功能 CocosToJava
  395. */
  396. public static ShareToMiniGame() {
  397. if (cc.sys.os == cc.sys.OS_ANDROID) {
  398. this.callStaticMethod(this._JSB_ANDROID_PATH, "ShareToMiniGame", "()V");
  399. }
  400. else if (cc.sys.os == cc.sys.OS_IOS) {
  401. this.callStaticMethod("AppController", "WxAuth", "");
  402. }
  403. }
  404. /**
  405. * 分享图片
  406. * @description 微信SDK功能 CocosToJava
  407. */
  408. public static sharePic() {
  409. if (cc.sys.platform == cc.sys.WECHAT_GAME) {
  410. return
  411. }
  412. if (cc.sys.os == cc.sys.OS_ANDROID) {
  413. jsb.reflection.callStaticMethod(this._JSB_ANDROID_PATH, "sharePic", "()V");
  414. }
  415. else if (cc.sys.os == cc.sys.OS_IOS) {
  416. jsb.reflection.callStaticMethod("GameConfig", "sharePic:", "");
  417. }
  418. }
  419. /** 打开微信 */
  420. public static openWx() {
  421. if (cc.sys.os == cc.sys.OS_ANDROID) {
  422. this.callStaticMethod(this._JSB_ANDROID_PATH, "openWx", "()V");
  423. }
  424. else if (cc.sys.os == cc.sys.OS_IOS) {
  425. this.callStaticMethod("AppController", "openWx", "");
  426. }
  427. }
  428. /** 下载文件
  429. * @param url 下载地址
  430. * @param fileName 存储文件名称
  431. * @param successCb 成功回调
  432. * @param failCb 失败回调
  433. * @param progressCb 下载进度回调
  434. */
  435. public static downFile2Local(url, fileName, successCb, failCb, progressCb): any {
  436. var fullPath = jsb.fileUtils.getWritablePath() + fileName
  437. if (jsb) {
  438. var downloader = new jsb.Downloader();
  439. downloader.setOnFileTaskSuccess(function () {
  440. console.log("DownLoadM setOnFileTaskSuccess", "")
  441. if (successCb) {
  442. console.log("DownLoadM result... ", jsb.fileUtils.isFileExist(fullPath))
  443. console.log("DownLoadM setOnFileTaskSuccess fullPath...", fullPath)
  444. successCb(fullPath);
  445. }
  446. });
  447. downloader.setOnTaskError(function (task: any, errorCode: number, errorCodeInternal: number, errorStr: string) {
  448. console.log("DownLoadM setOnTaskError", errorCode + " ; " + errorCodeInternal + " ; " + errorStr)
  449. if (failCb) {
  450. failCb(fullPath);
  451. }
  452. });
  453. downloader.setOnTaskProgress(function (task: any, bytesReceived: number, totalBytesReceived: number, totalBytesExpected: number) {
  454. console.log("DownLoadM", bytesReceived + " ; " + totalBytesReceived + " ; " + totalBytesExpected)
  455. if (progressCb) {
  456. progressCb(bytesReceived, totalBytesReceived, totalBytesExpected)
  457. }
  458. });
  459. downloader.createDownloadFileTask(url, fullPath);//创建下载任务
  460. return downloader
  461. }
  462. }
  463. private static singleClick = true;
  464. private static splashADid = '';
  465. /** 上传开屏广告星云埋点 */
  466. public static updateSplashAdLog(info) {
  467. let arr = info.split('#')
  468. // console.log('updateSplashAdLog placementId ', arr[0])
  469. // console.log('updateSplashAdLog callbackInfo ', arr[1])
  470. let data = JSON.parse(arr[1])
  471. gData.adData.updateADLog(6, arr[0], data);
  472. this.splashADid = arr[0];
  473. let times = mk.storage.getStorage('ad_openEcpm');
  474. if (!times) {
  475. times = 1;
  476. }
  477. else {
  478. times++;
  479. }
  480. mk.storage.setStorage('ad_openEcpm', times);
  481. if (times <= 300) {
  482. if (times <= 50) {
  483. mk.data.sendDataEventValue(DataEventId.ad_openEcpm, `ad_video_ecpm${times}`, data.adsource_price);
  484. }
  485. else if (times % 10 == 0) {
  486. mk.data.sendDataEventValue(DataEventId.ad_openEcpm, `ad_video_ecpm${times}`, data.adsource_price);
  487. }
  488. }
  489. }
  490. public static clickSplash() {
  491. mk.data.sendDataEvent(DataEventId.Ad_click, 'splash_click');
  492. gData.adData.updateADLog(54, this.splashADid);
  493. if (this.singleClick) {
  494. this.singleClick = false;
  495. gData.adData.updateADLog(74, this.splashADid);
  496. }
  497. }
  498. /** 获取阿里风控设备token */
  499. public static getAliRiskDeviceToken() {
  500. let token = '';
  501. if (cc.sys.os == cc.sys.OS_ANDROID) {
  502. token = this.callStaticMethod(this._JSB_ANDROID_PATH, "getAliDeviceToken", "()Ljava/lang/String;");
  503. }
  504. else if (cc.sys.os == cc.sys.OS_IOS) {
  505. token = this.callStaticMethod("AppController", "openWx", "");
  506. }
  507. return token;
  508. }
  509. public static backKeyCallBack() {
  510. if (this.callBack) {
  511. this.callBack();
  512. }
  513. }
  514. public static systemExit() {
  515. if (cc.sys.os == cc.sys.OS_ANDROID) {
  516. this.callStaticMethod(this._JSB_ANDROID_PATH, "systemExit", "()V");
  517. }
  518. }
  519. public static changeNetState(state: string) {
  520. if (state == '1') {
  521. mk.ui.closePanel('NetDisConnect');
  522. }
  523. else if (state == '0') {
  524. mk.ui.openPanel('module/netDisconnect/NetDisConnect');
  525. }
  526. }
  527. //分享链接
  528. public static shareInviteUrl(url: string, title: string, describe: string, imgUrl: string) {
  529. if (cc.sys.platform == cc.sys.WECHAT_GAME) {
  530. return
  531. }
  532. if (cc.sys.os == cc.sys.OS_ANDROID) {
  533. jsb.reflection.callStaticMethod(this._JSB_ANDROID_PATH, "shareInviteUrl",
  534. "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", url, title, describe, imgUrl);
  535. }
  536. else if (cc.sys.os == cc.sys.OS_IOS) {
  537. //to do
  538. // jsb.reflection.callStaticMethod("GameConfig", "sharePic:", "");
  539. }
  540. }
  541. /** 初始化ysdk */
  542. public static ysdkInit() {
  543. if (cc.sys.os == cc.sys.OS_ANDROID) {
  544. this.callStaticMethod(this._JSB_ANDROID_PATH_JSDK, "init", "()V");
  545. }
  546. else if (cc.sys.os == cc.sys.OS_IOS) {
  547. this.callStaticMethod("AppController", "init", "");
  548. }
  549. }
  550. /** ysdk登录 */
  551. public static autologin() {
  552. if (cc.sys.os == cc.sys.OS_ANDROID) {
  553. this.callStaticMethod(this._JSB_ANDROID_PATH_JSDK, "autologin", "()V");
  554. }
  555. else if (cc.sys.os == cc.sys.OS_IOS) {
  556. this.callStaticMethod("AppController", "autologin", "");
  557. }
  558. }
  559. public static ysdkAuthSuccess() {
  560. gData.loginData.passAnti = true;
  561. mk.data.setTAEventUserStr(0, 'realName', "认证通过人数");
  562. //mk.data.sendDataEvent(DataEventId.realName, '认证通过人数');
  563. }
  564. /** 统计时长 */
  565. public static updateActivateLog(sessionDuration) {
  566. console.log('test>>> updateActivateLog ', sessionDuration)
  567. let data = {
  568. 'appId': gData.appData.appId,
  569. 'uin': gData.loginData.uin,
  570. 'sessionDuration': sessionDuration
  571. }
  572. mk.http.sendData('activateLog', data);
  573. }
  574. /** 屏蔽对应广告位的广告源 */
  575. public static setFilterAdSourceIdList(adID: string, adSourceStr: string) {
  576. if (cc.sys.os == cc.sys.OS_ANDROID) {
  577. jsb.reflection.callStaticMethod(this._JSB_ANDROID_PATH, "setFilterAdSourceIdList", "(Ljava/lang/String;Ljava/lang/String;)V", adID, adSourceStr);
  578. }
  579. else if (cc.sys.os == cc.sys.OS_IOS) {
  580. jsb.reflection.callStaticMethod("GameConfig", "setFilterAdSourceIdList:", "");
  581. }
  582. }
  583. /** 数盟获取设备id */
  584. public static getQueryID() {
  585. if (cc.sys.os == cc.sys.OS_ANDROID) {
  586. jsb.reflection.callStaticMethod(this._JSB_ANDROID_PATH, "getQueryID", "()V");
  587. }
  588. else if (cc.sys.os == cc.sys.OS_IOS) {
  589. jsb.reflection.callStaticMethod("GameConfig", "getQueryID:", "");
  590. }
  591. }
  592. /** 设置数盟设备id */
  593. public static setShuzilmEquipID(szlm_did: string) {
  594. mk.shuzilmM.setShuzilmEquipID(szlm_did);
  595. }
  596. /** 设置同盾设备id */
  597. public static setTDEquipID(equipID) {
  598. mk.tongdunM.setTDEquipID(equipID);
  599. }
  600. /** 同盾初始化 */
  601. public static tongdunInit() {
  602. if (cc.sys.os == cc.sys.OS_ANDROID) {
  603. jsb.reflection.callStaticMethod(this._JSB_ANDROID_PATH, "tongdunInit", "()V");
  604. }
  605. else if (cc.sys.os == cc.sys.OS_IOS) {
  606. jsb.reflection.callStaticMethod("GameConfig", "tongdunInit:", "");
  607. }
  608. }
  609. }
  610. window['JsbMgr'] = JsbSystem