|
|
@@ -2,7 +2,7 @@
|
|
|
* @Author: mojunshou 1637302775@qq.com
|
|
|
* @Date: 2025-03-31 10:45:44
|
|
|
* @LastEditors: mojunshou 1637302775@qq.com
|
|
|
- * @LastEditTime: 2025-04-08 16:33:08
|
|
|
+ * @LastEditTime: 2025-04-08 17:33:14
|
|
|
* @Description: CocosHandler 处理类负责与安卓交互
|
|
|
*/
|
|
|
import { native } from 'cc';
|
|
|
@@ -13,6 +13,8 @@ import { Account } from '../../account/Account';
|
|
|
import { oops } from 'db://oops-framework/core/Oops';
|
|
|
import { GameEvent } from '../config/GameEvent';
|
|
|
import { ProtocolEvent } from './ProtocolEvent';
|
|
|
+import { AndroidEvent } from '../config/AndroidEvent';
|
|
|
+import { UIID } from '../config/GameUIConfig';
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
type CocosHandlerType = {
|
|
|
@@ -135,6 +137,37 @@ export class CocosHandler {
|
|
|
|
|
|
|
|
|
//=================================以下是广告方法====================
|
|
|
+ //每次启动都加载一次启屏广告
|
|
|
+ async ad_interstitial_start() {
|
|
|
+ const param = {
|
|
|
+ "funcId": "101",
|
|
|
+ "callback":
|
|
|
+ {
|
|
|
+ "onClose": "CocosHandler.inst.ad_splash_close"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const data: CocosHandlerType = {
|
|
|
+ method: "ad.splash",
|
|
|
+ param: JSON.stringify(param)
|
|
|
+ }
|
|
|
+ let result = await this.sendMessageToAndroid(data);
|
|
|
+ console.log("启屏广告返回数据", result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //启屏广告关闭时回调
|
|
|
+ ad_splash_close() {
|
|
|
+ if (oops.gui.has(UIID.KindTips)) {
|
|
|
+ oops.gui.remove(UIID.KindTips);
|
|
|
+ }
|
|
|
+ if (oops.gui.has(UIID.Retention)) {
|
|
|
+ oops.gui.remove(UIID.Retention);
|
|
|
+ }
|
|
|
+ oops.message.dispatchEvent(AndroidEvent.AgreePrivacy);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
//广告请求--插屏广告
|
|
|
@@ -232,6 +265,40 @@ export class CocosHandler {
|
|
|
console.log("微信登录结果", result);
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ //获取账号信息
|
|
|
+ getAccountInfo() {
|
|
|
+ const param = {
|
|
|
+ "url": ProtocolEvent.AccountInfo,
|
|
|
+ "param": {
|
|
|
+ "authToken": "123456"
|
|
|
+ },
|
|
|
+ "callback": {
|
|
|
+ "onSuccess": "CocosHandler.inst.getAccountInfo_success",
|
|
|
+ "onFail": "CocosHandler.inst.getAccountInfo_fail"
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ const data: CocosHandlerType = {
|
|
|
+ method: "request.post",
|
|
|
+ param: JSON.stringify(param)
|
|
|
+ }
|
|
|
+ this.sendMessageToAndroid(data);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //获取账号信息成功回调
|
|
|
+ getAccountInfo_success(str: string) {
|
|
|
+ console.log("获取账号信息成功回调", str);
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取账号信息失败回调
|
|
|
+ getAccountInfo_fail(str: string) {
|
|
|
+ console.log("获取账号信息失败回调", str);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
window['CocosHandler'] = CocosHandler;
|
|
|
|