Kaynağa Gözat

完善登录流程-加载广告成功

mojunshou 8 ay önce
ebeveyn
işleme
cf9ec33fd5

+ 67 - 53
assets/bundle/gui/loading/loading.prefab

@@ -28,26 +28,26 @@
         "__id__": 46
       },
       {
-        "__id__": 88
+        "__id__": 89
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 102
+        "__id__": 103
       },
       {
-        "__id__": 104
+        "__id__": 105
       },
       {
-        "__id__": 106
+        "__id__": 107
       },
       {
-        "__id__": 108
+        "__id__": 109
       }
     ],
     "_prefab": {
-      "__id__": 110
+      "__id__": 111
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -1045,14 +1045,14 @@
     "_active": false,
     "_components": [
       {
-        "__id__": 83
+        "__id__": 84
       },
       {
-        "__id__": 85
+        "__id__": 86
       }
     ],
     "_prefab": {
-      "__id__": 87
+      "__id__": 88
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -1293,20 +1293,20 @@
         "__id__": 56
       },
       {
-        "__id__": 70
+        "__id__": 71
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 78
+        "__id__": 79
       },
       {
-        "__id__": 80
+        "__id__": 81
       }
     ],
     "_prefab": {
-      "__id__": 82
+      "__id__": 83
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -1363,7 +1363,7 @@
       }
     ],
     "_prefab": {
-      "__id__": 69
+      "__id__": 70
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -1655,7 +1655,11 @@
     "_target": {
       "__id__": 56
     },
-    "checkEvents": [],
+    "checkEvents": [
+      {
+        "__id__": 69
+      }
+    ],
     "_isChecked": true,
     "_checkMark": {
       "__id__": 60
@@ -1667,6 +1671,16 @@
     "fileId": "93ith0yfFNS7Mftwt6YcVZ"
   },
   {
+    "__type__": "cc.ClickEvent",
+    "target": {
+      "__id__": 1
+    },
+    "component": "",
+    "_componentId": "92429ykTnxFCrcGyW58JWjj",
+    "handler": "onToggleChick",
+    "customEventData": ""
+  },
+  {
     "__type__": "cc.PrefabInfo",
     "root": {
       "__id__": 1
@@ -1691,17 +1705,17 @@
     "_active": true,
     "_components": [
       {
-        "__id__": 71
+        "__id__": 72
       },
       {
-        "__id__": 73
+        "__id__": 74
       },
       {
-        "__id__": 75
+        "__id__": 76
       }
     ],
     "_prefab": {
-      "__id__": 77
+      "__id__": 78
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -1738,11 +1752,11 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 70
+      "__id__": 71
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 72
+      "__id__": 73
     },
     "_contentSize": {
       "__type__": "cc.Size",
@@ -1766,11 +1780,11 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 70
+      "__id__": 71
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 74
+      "__id__": 75
     },
     "_lineHeight": 24,
     "_string": "登录代表同意连赚方块<on click=\"onClicked\" param=\"User Agreement\"><color=#5C9CE9>《用户协议》</color></on>和<on click=\"onClicked\" param=\"Privacy Policy\"><color=#5C9CE9>《隐私政策》</color></on>",
@@ -1804,11 +1818,11 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 70
+      "__id__": 71
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 76
+      "__id__": 77
     },
     "_id": ""
   },
@@ -1839,7 +1853,7 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 79
+      "__id__": 80
     },
     "_contentSize": {
       "__type__": "cc.Size",
@@ -1867,7 +1881,7 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 81
+      "__id__": 82
     },
     "_resizeMode": 0,
     "_layoutType": 1,
@@ -1918,7 +1932,7 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 84
+      "__id__": 85
     },
     "_contentSize": {
       "__type__": "cc.Size",
@@ -1946,7 +1960,7 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 86
+      "__id__": 87
     },
     "watchPath": "*.btn_show",
     "foreachChildMode": false,
@@ -1997,23 +2011,23 @@
     },
     "_children": [
       {
-        "__id__": 89
+        "__id__": 90
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 95
+        "__id__": 96
       },
       {
-        "__id__": 97
+        "__id__": 98
       },
       {
-        "__id__": 99
+        "__id__": 100
       }
     ],
     "_prefab": {
-      "__id__": 101
+      "__id__": 102
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -2050,20 +2064,20 @@
     "_objFlags": 512,
     "__editorExtras__": {},
     "_parent": {
-      "__id__": 88
+      "__id__": 89
     },
     "_children": [],
     "_active": true,
     "_components": [
       {
-        "__id__": 90
+        "__id__": 91
       },
       {
-        "__id__": 92
+        "__id__": 93
       }
     ],
     "_prefab": {
-      "__id__": 94
+      "__id__": 95
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -2100,11 +2114,11 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 89
+      "__id__": 90
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 91
+      "__id__": 92
     },
     "_contentSize": {
       "__type__": "cc.Size",
@@ -2128,11 +2142,11 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 89
+      "__id__": 90
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 93
+      "__id__": 94
     },
     "_customMaterial": null,
     "_srcBlendFactor": 2,
@@ -2209,11 +2223,11 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 88
+      "__id__": 89
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 96
+      "__id__": 97
     },
     "_contentSize": {
       "__type__": "cc.Size",
@@ -2237,11 +2251,11 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 88
+      "__id__": 89
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 98
+      "__id__": 99
     },
     "_customMaterial": null,
     "_srcBlendFactor": 2,
@@ -2282,11 +2296,11 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 88
+      "__id__": 89
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 100
+      "__id__": 101
     },
     "clickEvents": [],
     "_interactable": true,
@@ -2338,7 +2352,7 @@
     "_duration": 0.1,
     "_zoomScale": 1.2,
     "_target": {
-      "__id__": 88
+      "__id__": 89
     },
     "_id": ""
   },
@@ -2369,7 +2383,7 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 103
+      "__id__": 104
     },
     "_contentSize": {
       "__type__": "cc.Size",
@@ -2397,7 +2411,7 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 105
+      "__id__": 106
     },
     "_alignFlags": 45,
     "_target": null,
@@ -2433,7 +2447,7 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 107
+      "__id__": 108
     },
     "_id": ""
   },
@@ -2451,7 +2465,7 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 109
+      "__id__": 110
     },
     "_id": ""
   },

+ 68 - 1
assets/script/game/common/manager/CocosHandler.ts

@@ -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;
 

+ 2 - 3
assets/script/game/common/tips/KindTipsView.ts

@@ -2,7 +2,7 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-19 18:02:51
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-08 15:45:49
+ * @LastEditTime: 2025-04-08 17:12:37
  * @Description: 温馨提示弹窗
  */
 import { _decorator, Component, Node } from 'cc';
@@ -28,8 +28,7 @@ export class KindTipsView extends GameComponent {
             let result = await CocosHandler.inst.savePrivacyStatus(true);
             console.log("返回状态>>>>>>>>>>>>>>>>>", result)
             if (result.code == 0) {
-                sys.localStorage.setItem("agree", "true");
-                oops.message.dispatchEvent(AndroidEvent.AgreePrivacy);
+                CocosHandler.inst.ad_interstitial_start();
                 oops.gui.remove(UIID.KindTips);
             } else {
                 oops.gui.toast("保存失败")

+ 2 - 4
assets/script/game/common/tips/RetentionView.ts

@@ -2,7 +2,7 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-19 18:02:51
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-08 15:46:03
+ * @LastEditTime: 2025-04-08 17:09:27
  * @Description: 隐私挽留弹窗
  */
 import { game } from 'cc';
@@ -25,11 +25,9 @@ export class RetentionView extends GameComponent {
         console.log("同意");
         //调用安卓给权限
         if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
-            // 发送信息给安卓
-            // sys.sendNativeEvent("agree");
             let result = await CocosHandler.inst.savePrivacyStatus(true);
             if (result.code == 0) {
-                oops.message.dispatchEvent(AndroidEvent.AgreePrivacy);
+                CocosHandler.inst.ad_interstitial_start();
                 oops.gui.remove(UIID.Retention);
             } else {
                 oops.gui.toast("保存失败")

+ 14 - 16
assets/script/game/initialize/view/LoadingViewComp.ts

@@ -2,7 +2,7 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-19 16:23:51
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-08 15:04:41
+ * @LastEditTime: 2025-04-08 17:21:30
  * @Description: loading界面
  */
 import { _decorator, Toggle } from "cc";
@@ -50,7 +50,8 @@ export class LoadingViewComp extends CCVMParentComp {
         if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
             const state = await CocosHandler.inst.getPrivacyStatus();
             console.log("隐私状态>>>>>>>>>>>>>>>>", state);
-            if (state.granted) {
+            if (state.data.result) {
+                //同意之后都加载一次启屏广告
                 const isWxLogin = oops.storage.getBoolean("isWxLogin");
                 if (isWxLogin) {
                     //直接登录
@@ -158,14 +159,18 @@ export class LoadingViewComp extends CCVMParentComp {
 
 
         //登录完要隐藏微信按钮然后加载进度
-        let result = await CocosHandler.inst.wechat_login();
-        if (result.code) {
-            this.setWxLoginBtnState(false);
-            this.loadRes();
-        } else {
+        // let result = await CocosHandler.inst.wechat_login();
+        // if (result.code) {
+        //     this.setWxLoginBtnState(false);
+        //     this.loadRes();
+        // } else {
 
-            oops.gui.toast("登录失败,请重试")
-        }
+        //     oops.gui.toast("登录失败,请重试")
+        // }
+
+
+        //先跳过,直接进行第二步
+        CocosHandler.inst.getAccountInfo();
     }
 
 
@@ -215,13 +220,6 @@ export class LoadingViewComp extends CCVMParentComp {
         }
     }
 
-
-
-
-
-
-
-
     reset(): void { }