| 12345678910111213141516171819202122232425262728293031323334353637 |
- import { CocosHandler } from "./CocosHandler";
- //数据上报
- export class DCHandler {
- private static _inst: DCHandler;
- public static get inst(): DCHandler {
- if (!this._inst) {
- this._inst = new DCHandler();
- }
- return this._inst;
- }
- //数据上报
- async reportData(eventId: number, id?: number) {
- let param = {
- eventId: eventId,
- props: {}
- }
- if (id) {
- param.props = {
- id: id
- }
- }
- const data = {
- method: 'analytics.event',
- param: JSON.stringify(param)
- };
- const result = await CocosHandler.inst.sendMessageToAndroid(data, '获取数据上报状态');
- return JSON.parse(result);
- }
- }
- window["DCHandler"] = DCHandler;
|