YZ_Tool_Bili.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import PlatUtils from "./PlatUtils";
  2. import { utils } from "./Utils";
  3. import YZ_Constant, { LevelStatus } from "./YZ_Constant";
  4. const { ccclass, property } = cc._decorator;
  5. /**
  6. * 哔哩工具类
  7. */
  8. @ccclass
  9. export default class YZ_Tool_Bili {
  10. _sysInfo: any = {};
  11. public get SysInfo() {
  12. return this._sysInfo;
  13. }
  14. /**
  15. * 服务器配置信息
  16. */
  17. _serverConfig: any = null;
  18. public get ServerConfig() {
  19. return this._serverConfig;
  20. }
  21. /**
  22. *
  23. * @param data 配置数据
  24. */
  25. public init(data: string) {
  26. if (PlatUtils.IsBili) {
  27. // if (data) {
  28. // let configObj: any = JSON.parse(data);
  29. // if (configObj && configObj.uc) {
  30. // ST_DefaultServerConfig = JSON.stringify(configObj.uc);
  31. // }
  32. // }
  33. utils.showLog("哔哩 平台初始化完成 >>");
  34. this.initSystemInfo();
  35. utils.emitServerInitEvent();
  36. }
  37. }
  38. /**
  39. * 分享
  40. * @param callback 回调
  41. */
  42. public share(callback: Function = null) {
  43. //@ts-ignore
  44. bl.shareAppMessage({
  45. title: utils.config.otherconfig.shareTitle,
  46. imageUrl: utils.config.otherconfig.shareImgUrl,
  47. success: () => {
  48. utils.showLog("bili 分享成功!");
  49. callback && callback(true)
  50. },
  51. fail: () => {
  52. utils.showLog("bili 分享失败!");
  53. callback && callback(false, "分享失败!");
  54. }
  55. })
  56. }
  57. /**
  58. * 初始化获取系统信息参数
  59. */
  60. public initSystemInfo() {
  61. if (PlatUtils.IsBili) {
  62. //@ts-ignore
  63. this._sysInfo = bl.getSystemInfoSync();
  64. }
  65. }
  66. }