瀏覽代碼

开始对接数据

mojunshou 8 月之前
父節點
當前提交
891f66bfe5

+ 42 - 3
assets/bundle/common/prefab/kind_tips.prefab

@@ -32,10 +32,13 @@
       },
       {
         "__id__": 74
+      },
+      {
+        "__id__": 76
       }
     ],
     "_prefab": {
-      "__id__": 76
+      "__id__": 78
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -238,7 +241,7 @@
     "value": {
       "__type__": "cc.Size",
       "width": 720,
-      "height": 1280
+      "height": 1600
     }
   },
   {
@@ -1519,7 +1522,7 @@
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 720,
-      "height": 1280
+      "height": 1600
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -1551,6 +1554,42 @@
     "fileId": "67K0zjOOtE7ooqs5P7bnBc"
   },
   {
+    "__type__": "cc.Widget",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 1
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 77
+    },
+    "_alignFlags": 45,
+    "_target": null,
+    "_left": 0,
+    "_right": 0,
+    "_top": 0,
+    "_bottom": 0,
+    "_horizontalCenter": 0,
+    "_verticalCenter": 0,
+    "_isAbsLeft": true,
+    "_isAbsRight": true,
+    "_isAbsTop": true,
+    "_isAbsBottom": true,
+    "_isAbsHorizontalCenter": true,
+    "_isAbsVerticalCenter": true,
+    "_originalWidth": 720,
+    "_originalHeight": 1280,
+    "_alignMode": 2,
+    "_lockFlags": 0,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "53TS3iuDpJ86pBO0OUuT62"
+  },
+  {
     "__type__": "cc.PrefabInfo",
     "root": {
       "__id__": 1

+ 7 - 28
assets/bundle/gui/eliminate/prefab/redPackeItem.prefab

@@ -26,13 +26,10 @@
     "_components": [
       {
         "__id__": 74
-      },
-      {
-        "__id__": 76
       }
     ],
     "_prefab": {
-      "__id__": 78
+      "__id__": 76
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -294,7 +291,7 @@
     },
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": -214.435,
+      "x": -215.899,
       "y": -17.625,
       "z": 0
     },
@@ -366,9 +363,9 @@
     "_dstBlendFactor": 4,
     "_color": {
       "__type__": "cc.Color",
-      "r": 255,
-      "g": 255,
-      "b": 255,
+      "r": 0,
+      "g": 0,
+      "b": 0,
       "a": 255
     },
     "_string": "100",
@@ -957,7 +954,7 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 72.294921875,
+      "width": 193.369140625,
       "height": 50.4
     },
     "_anchorPoint": {
@@ -993,7 +990,7 @@
       "b": 0,
       "a": 255
     },
-    "_string": "100/200",
+    "_string": "每日消除300次可领取",
     "_horizontalAlign": 1,
     "_verticalAlign": 1,
     "_actualFontSize": 20,
@@ -1911,24 +1908,6 @@
     "fileId": "66c/6wuo1F0IzbuSBnY9FS"
   },
   {
-    "__type__": "f2eabVLcvlH5IXRlUEbXdFa",
-    "_name": "",
-    "_objFlags": 0,
-    "__editorExtras__": {},
-    "node": {
-      "__id__": 1
-    },
-    "_enabled": true,
-    "__prefab": {
-      "__id__": 77
-    },
-    "_id": ""
-  },
-  {
-    "__type__": "cc.CompPrefabInfo",
-    "fileId": "ddT3YrL/BB9YAHX1nhViTb"
-  },
-  {
     "__type__": "cc.PrefabInfo",
     "root": {
       "__id__": 1

File diff suppressed because it is too large
+ 2333 - 491
assets/bundle/gui/eliminate/prefab/redPacketWithdrawal.prefab


二進制
assets/bundle/gui/eliminate/texture/title/title_bg.png


+ 134 - 0
assets/bundle/gui/eliminate/texture/title/title_bg.png.meta

@@ -0,0 +1,134 @@
+{
+  "ver": "1.0.27",
+  "importer": "image",
+  "imported": true,
+  "uuid": "85316d7b-7c9b-498e-9dec-3b794aa94fba",
+  "files": [
+    ".json",
+    ".png"
+  ],
+  "subMetas": {
+    "6c48a": {
+      "importer": "texture",
+      "uuid": "85316d7b-7c9b-498e-9dec-3b794aa94fba@6c48a",
+      "displayName": "title_bg",
+      "id": "6c48a",
+      "name": "texture",
+      "userData": {
+        "wrapModeS": "clamp-to-edge",
+        "wrapModeT": "clamp-to-edge",
+        "imageUuidOrDatabaseUri": "85316d7b-7c9b-498e-9dec-3b794aa94fba",
+        "isUuid": true,
+        "visible": false,
+        "minfilter": "linear",
+        "magfilter": "linear",
+        "mipfilter": "none",
+        "anisotropy": 0
+      },
+      "ver": "1.0.22",
+      "imported": true,
+      "files": [
+        ".json"
+      ],
+      "subMetas": {}
+    },
+    "f9941": {
+      "importer": "sprite-frame",
+      "uuid": "85316d7b-7c9b-498e-9dec-3b794aa94fba@f9941",
+      "displayName": "title_bg",
+      "id": "f9941",
+      "name": "spriteFrame",
+      "userData": {
+        "trimThreshold": 1,
+        "rotated": false,
+        "offsetX": 0,
+        "offsetY": 0,
+        "trimX": 0,
+        "trimY": 0,
+        "width": 320,
+        "height": 80,
+        "rawWidth": 320,
+        "rawHeight": 80,
+        "borderTop": 0,
+        "borderBottom": 0,
+        "borderLeft": 0,
+        "borderRight": 0,
+        "packable": true,
+        "pixelsToUnit": 100,
+        "pivotX": 0.5,
+        "pivotY": 0.5,
+        "meshType": 0,
+        "vertices": {
+          "rawPosition": [
+            -160,
+            -40,
+            0,
+            160,
+            -40,
+            0,
+            -160,
+            40,
+            0,
+            160,
+            40,
+            0
+          ],
+          "indexes": [
+            0,
+            1,
+            2,
+            2,
+            1,
+            3
+          ],
+          "uv": [
+            0,
+            80,
+            320,
+            80,
+            0,
+            0,
+            320,
+            0
+          ],
+          "nuv": [
+            0,
+            0,
+            1,
+            0,
+            0,
+            1,
+            1,
+            1
+          ],
+          "minPos": [
+            -160,
+            -40,
+            0
+          ],
+          "maxPos": [
+            160,
+            40,
+            0
+          ]
+        },
+        "isUuid": true,
+        "imageUuidOrDatabaseUri": "85316d7b-7c9b-498e-9dec-3b794aa94fba@6c48a",
+        "atlasUuid": "",
+        "trimType": "auto"
+      },
+      "ver": "1.0.12",
+      "imported": true,
+      "files": [
+        ".json"
+      ],
+      "subMetas": {}
+    }
+  },
+  "userData": {
+    "type": "sprite-frame",
+    "hasAlpha": true,
+    "fixAlphaTransparencyArtifacts": false,
+    "redirect": "85316d7b-7c9b-498e-9dec-3b794aa94fba@6c48a"
+  }
+}

+ 2 - 2
assets/bundle/gui/loading/loading.prefab

@@ -272,7 +272,7 @@
         "__id__": 27
       }
     ],
-    "_active": true,
+    "_active": false,
     "_components": [
       {
         "__id__": 35
@@ -445,7 +445,7 @@
     "_isUnderline": false,
     "_underlineHeight": 2,
     "_cacheMode": 0,
-    "_enableOutline": true,
+    "_enableOutline": false,
     "_outlineColor": {
       "__type__": "cc.Color",
       "r": 0,

+ 44 - 8
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-07 15:35:51
+ * @LastEditTime: 2025-04-08 16:33:08
  * @Description: CocosHandler 处理类负责与安卓交互
  */
 import { native } from 'cc';
@@ -12,6 +12,7 @@ import { smc } from '../SingletonModuleComp';
 import { Account } from '../../account/Account';
 import { oops } from 'db://oops-framework/core/Oops';
 import { GameEvent } from '../config/GameEvent';
+import { ProtocolEvent } from './ProtocolEvent';
 const { ccclass, property } = _decorator;
 
 type CocosHandlerType = {
@@ -41,7 +42,7 @@ export class CocosHandler {
     //微信登录
     async wechat_login() {
         const param = {
-            "appId": "wx1234567890",
+            "appId": "wx1234567890",  //这个ID没申请下来
             "callback":
             {
                 "onSuccess": "CocosHandler.inst.wechat_login_success",
@@ -55,6 +56,7 @@ export class CocosHandler {
         }
 
         let result = await this.sendMessageToAndroid(data);
+        console.log("微信登录结果>>>>>>>>>>", result);
         // smc.account.AccountModel.
         return result;
     }
@@ -62,10 +64,11 @@ export class CocosHandler {
     //获取隐私授权状态
     async getPrivacyStatus() {
         const data: CocosHandlerType = {
-            method: "system.privacy.get",
+            method: "privacy.grant.get",
         }
         let result = await this.sendMessageToAndroid(data);
-        return result;
+        console.log("安卓返回隐私授权状态", result);
+        return JSON.parse(result);
     }
 
     //保存隐私授权状态
@@ -78,7 +81,8 @@ export class CocosHandler {
             param: JSON.stringify(param)
         }
         let result = await this.sendMessageToAndroid(data);
-        return result;
+        console.log("安卓返回隐私授权状态", result);
+        return JSON.parse(result);
     }
 
 
@@ -130,6 +134,9 @@ export class CocosHandler {
     }
 
 
+    //=================================以下是广告方法====================
+
+
     //广告请求--插屏广告
     async ad_interstitial() {
         const param = {
@@ -163,8 +170,8 @@ export class CocosHandler {
     }
 
     //广告加载失败回调
-    ad_interstitial_load_failed() {
-        console.log("广告加载失败回调");
+    ad_interstitial_load_failed(msg: string) {
+        console.log("广告加载失败回调", msg);
     }
 
     //广告显示失败回调
@@ -172,6 +179,8 @@ export class CocosHandler {
         console.log("广告显示失败回调");
     }
 
+    //
+
 
 
 
@@ -181,7 +190,11 @@ export class CocosHandler {
     wechat_login_success(str: string) {
         console.log("微信登录成功回调", str);
         //保存数据
-        oops.message.dispatchEvent(GameEvent.WechatLoginSuss);
+        // oops.message.dispatchEvent(GameEvent.WechatLoginSuss);
+
+
+        // 获取用户信息
+        //然后就是和服务器通信
     }
 
     //微信登录失败回调
@@ -190,12 +203,35 @@ export class CocosHandler {
         oops.gui.toast("微信登录失败");
     }
 
+
+
+
     //安卓直接调用广告回调,显示失败还是成功,成功提供什么奖励,失败又怎么做
     async ad_callback(ad_type: string, ad_status: string, ad_reward: string) {
 
 
     }
 
+
+
+
+    //==================跟服务器交互======================
+    //微信登录
+    async wx_login(code: string) {
+        const param = {
+            "code": code,
+            "url": ProtocolEvent.WechatLogin
+        }
+
+        const data: CocosHandlerType = {
+            method: "request.post",
+            param: JSON.stringify(param)
+        }
+
+        let result = await this.sendMessageToAndroid(data);
+        console.log("微信登录结果", result);
+        return result;
+    }
 }
 window['CocosHandler'] = CocosHandler;
 

+ 3 - 3
assets/script/game/common/manager/MessgageEvent.ts

@@ -2,14 +2,14 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-04-07 10:17:16
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-07 11:05:15
+ * @LastEditTime: 2025-04-08 16:17:49
  * @Description: 消息定义
  */
 
-const server_url = "https://www.baidu.com";
+const server_url = "http://192.168.10.103:8880";
 
 
-export enum MessgageEvent {
+export enum ProtocolEvent {
     /**微信登录*/
     WechatLogin = server_url + "/project/playlet/v1/user/login",
     /**账号信息*/

assets/script/game/common/manager/MessgageEvent.ts.meta → assets/script/game/common/manager/ProtocolEvent.ts.meta


+ 13 - 9
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-03-20 11:27:04
+ * @LastEditTime: 2025-04-08 15:45:49
  * @Description: 温馨提示弹窗
  */
 import { _decorator, Component, Node } from 'cc';
@@ -12,6 +12,7 @@ import { UIID } from '../config/GameUIConfig';
 import { sys } from 'cc';
 import { DeviceUtil } from 'db://oops-framework/core/utils/DeviceUtil';
 import { AndroidEvent } from '../config/AndroidEvent';
+import { CocosHandler } from '../manager/CocosHandler';
 const { ccclass, property } = _decorator;
 
 @ccclass('KindTipsView')
@@ -20,17 +21,20 @@ export class KindTipsView extends GameComponent {
         this.setButton();
     }
 
-    private btn_agree() {
+    private async btn_agree() {
         console.log("同意");
-        // 同意后,将同意状态存储到本地
-        sys.localStorage.setItem("agree", "true");
-        // 是客户端就发送信息给安卓
+
         if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
-            // 发送信息给安卓
-            // sys.sendNativeEvent("agree");
+            let result = await CocosHandler.inst.savePrivacyStatus(true);
+            console.log("返回状态>>>>>>>>>>>>>>>>>", result)
+            if (result.code == 0) {
+                sys.localStorage.setItem("agree", "true");
+                oops.message.dispatchEvent(AndroidEvent.AgreePrivacy);
+                oops.gui.remove(UIID.KindTips);
+            } else {
+                oops.gui.toast("保存失败")
+            }
         }
-        // 关闭当前UI
-        oops.message.dispatchEvent(AndroidEvent.AgreePrivacy);
     }
 
     private btn_disagree() {

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

@@ -2,12 +2,17 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-19 18:02:51
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-03-19 18:38:24
+ * @LastEditTime: 2025-04-08 15:46:03
  * @Description: 隐私挽留弹窗
  */
 import { game } from 'cc';
 import { _decorator, Component, Node } from 'cc';
+import { oops } from 'db://oops-framework/core/Oops';
+import { DeviceUtil } from 'db://oops-framework/core/utils/DeviceUtil';
 import { GameComponent } from 'db://oops-framework/module/common/GameComponent';
+import { AndroidEvent } from '../config/AndroidEvent';
+import { UIID } from '../config/GameUIConfig';
+import { CocosHandler } from '../manager/CocosHandler';
 const { ccclass, property } = _decorator;
 
 @ccclass('RetentionView')
@@ -16,9 +21,20 @@ export class RetentionView extends GameComponent {
         this.setButton();
     }
 
-    private btn_agree() {
+    private async btn_agree() {
         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);
+                oops.gui.remove(UIID.Retention);
+            } else {
+                oops.gui.toast("保存失败")
+            }
+        }
     }
 
     private btn_disagree() {

+ 98 - 5
assets/script/game/eliminate/view/RedPackeItemView.ts

@@ -2,23 +2,116 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-20 18:39:37
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-03-25 15:59:59
+ * @LastEditTime: 2025-04-08 14:07:54
  * @Description: 红包列表item
  */
-import { _decorator } from 'cc';
+import { _decorator, Node } from 'cc';
 import { oops } from 'db://oops-framework/core/Oops';
-import { GameComponent } from "db://oops-framework/module/common/GameComponent";
-import { UIID } from '../../common/config/GameUIConfig';
+import { Label } from 'cc';
+import { ProgressBar } from 'cc';
+import { Sprite } from 'cc';
+import VMParent from 'db://oops-framework/libs/model-view/VMParent';
 
 const { ccclass, property } = _decorator;
 
 /** 显示对象控制 */
 @ccclass('RedPackeItemView')
-export class RedPackeItemView extends GameComponent {
+export class RedPackeItemView extends VMParent {
+    @property(Node)
+    private receiveNode: Node = null!;
+
+    @property(Node)
+    private unReceiveNode: Node = null!;
+
+    private lab_title: Label = null!;
+    private lab_progress: Label = null!;
+    private pro_progress: ProgressBar = null!;
+    private sp_icon: Sprite = null!;
+    private lab_num: Label = null!;
+
+    data: any = {
+        title: "完成任务即可领取红包~",
+        current: 10,
+        total: 100,
+        state: 1,
+        goods: [
+            {
+                type: 1001,
+                num: 100
+            }
+        ]
+    }
+
     protected start() {
         this.setButton();
+        this.initComponent();
+    }
+
+
+
+    private initComponent() {
+        this.lab_title = this.node.getChildByPath("Bg/lab_title")?.uiLabel!;
+        this.lab_progress = this.node.getChildByPath("Bg/lab_progress")?.uiLabel!;
+        this.pro_progress = this.node.getChildByPath("Bg/pro_progress")?.uiProgressBar!;
+        this.sp_icon = this.node.getChildByPath("Bg/sp_icon")?.uiSprite!;
+        this.lab_num = this.node.getChildByPath("Bg/lab_num")?.uiLabel!;
+
+    }
+
+
+
+
+    setItem(data: any, idx: number) {
+        console.log("setData>>>>>>>>>>>>>", data);
+        this.data = data;
+        this.updateData();
+    }
+
+
+    public getdata() {
+        return this.data;
     }
 
+    //更新数据
+    private updateData() {
+        console.log("updateData", this.data);
+
+        if (this.data.state == 0) {
+            this.receiveNode.active = false;
+            this.unReceiveNode.active = true;
+        } else if (this.data.state == 1) {
+            this.receiveNode.active = true;
+            this.unReceiveNode.active = false;
+        }
+        this.lab_title.string = this.data.title;
+        this.lab_progress.string = `${this.data.current}/${this.data.total}`;
+        this.pro_progress.progress = this.data.current / this.data.total;
+        // this.sp_icon.spriteFrame = oops.res.getSpriteFrame(this.data.goods[0].type);
+        this.lab_num.string = this.data.goods[0].num;
+
+
+
+    }
+
+
+    //进行中按钮
+    private btn_none() {
+        oops.gui.toast("完成任务即可领取红包~");
+    }
+
+
+    //可领取按钮
+    private btn_receive() {
+        oops.gui.toast("领取红包~");
+        //发送领取红包请求
+    }
+
+
+
+
+
+
+
 
 
 

+ 41 - 11
assets/script/game/eliminate/view/RedPackeWithdrawalViewComp.ts

@@ -2,30 +2,59 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-20 17:53:50
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-03-28 15:16:02
+ * @LastEditTime: 2025-04-08 14:59:27
  * @Description: 红包提现
  */
-import { _decorator } from "cc";
+import { _decorator, Node } from "cc";
 import { oops } from "db://oops-framework/core/Oops";
 import { ecs } from "db://oops-framework/libs/ecs/ECS";
 import { CCComp } from "db://oops-framework/module/common/CCComp";
 import { UIID } from "../../common/config/GameUIConfig";
+import List from "../ui/List";
+import { RedPackeItemView } from "./RedPackeItemView";
+import { GameComponent } from "db://oops-framework/module/common/GameComponent";
 
 const { ccclass, property } = _decorator;
 
 /** 视图层对象 */
-@ccclass('RedEnvelopeWithdrawalViewComp')
-@ecs.register('RedEnvelopeWithdrawalView', false)
-export class RedEnvelopeWithdrawalViewComp extends CCComp {
-    /** 视图层逻辑代码分离演示 */
-    start() {
-        // const entity = this.ent as ecs.Entity;         // ecs.Entity 可转为当前模块的具体实体对象
+@ccclass('RedPackeWithdrawalViewComp')
+export class RedPackeWithdrawalViewComp extends GameComponent {
+
+    @property(List)
+    recordList: List = null!;
+
+    data: any[] = [];
+    onLoad() {
         this.setButton();
+        const data = {
+            title: `每日消除100次即可领取`,
+            current: 1,
+            total: 100,
+            state: 0,
+            goods: [
+                {
+                    type: 1001,
+                    num: 100
+                }
+            ]
+        }
+
+        for (let i = 0; i < 10; i++) {
+            this.data.push(data);
+        }
+        oops.log.logView(this.data, "this.data");
+        this.recordList.numItems = this.data.length;
+        oops.log.logView(this.recordList.numItems, "this.recordList.numItems");
     }
 
-    /** 视图对象通过 ecs.Entity.remove(RedEnvelopeWithdrawalViewComp) 删除组件是触发组件处理自定义释放逻辑 */
-    reset() {
-        this.node.destroy();
+
+    private onListRender(item: Node, idx: number) {
+        console.log("onListRender", idx);
+        const itemView: RedPackeItemView | null = item.getComponent(RedPackeItemView);
+        if (itemView) {
+            console.log(">>>>>>>>>>>>>>>>>", itemView)
+            itemView.setItem(this.data[idx], idx);
+        }
     }
 
     private btn_back() {
@@ -36,4 +65,5 @@ export class RedEnvelopeWithdrawalViewComp extends CCComp {
     private btn_record() {
         oops.gui.open(UIID.WithdrawRecord);
     }
+
 }

+ 5 - 3
assets/script/game/eliminate/view/WithdrawalRecordViewComp.ts

@@ -2,7 +2,7 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-21 10:17:49
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-03 14:05:27
+ * @LastEditTime: 2025-04-08 11:18:17
  * @Description: 提现记录
  */
 import { _decorator, Node } from "cc";
@@ -58,12 +58,14 @@ export class WithdrawalRecordViewComp extends CCComp {
 
         const moneyLabel = item.getChildByName("lab_money")?.getComponent(Label);
         if (moneyLabel) moneyLabel.string = data.money + "元";
+        //TS原生随机数0 或者1 
+        const randomNum = Math.random() > 0.5 ? 0 : 1;
 
         const statusNode1 = item.getChildByName("record_state1");
-        if (statusNode1) statusNode1.active = data.status == 1;
+        if (statusNode1) statusNode1.active = randomNum == 0;
 
         const statusNode2 = item.getChildByName("record_state2");
-        if (statusNode2) statusNode2.active = data.status == 2;
+        if (statusNode2) statusNode2.active = randomNum == 1;
 
     }
 

+ 75 - 18
assets/script/game/initialize/view/LoadingViewComp.ts

@@ -2,21 +2,21 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-19 16:23:51
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-07 16:05:58
+ * @LastEditTime: 2025-04-08 15:04:41
  * @Description: loading界面
  */
-import { _decorator, sys } from "cc";
+import { _decorator, Toggle } from "cc";
 import { DeviceUtil } from "db://oops-framework/core/utils/DeviceUtil";
 import { ModuleUtil } from "db://oops-framework/module/common/ModuleUtil";
 import { oops } from "../../../../../extensions/oops-plugin-framework/assets/core/Oops";
 import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
 import { CCVMParentComp } from "../../../../../extensions/oops-plugin-framework/assets/module/common/CCVMParentComp";
 import { AndroidEvent } from "../../common/config/AndroidEvent";
+import { GameEvent } from "../../common/config/GameEvent";
 import { UIID } from "../../common/config/GameUIConfig";
+import { CocosHandler } from "../../common/manager/CocosHandler";
 import { smc } from "../../common/SingletonModuleComp";
 import { EliminateViewComp } from "../../eliminate/view/EliminateViewComp";
-import { CocosHandler } from "../../common/manager/CocosHandler";
-import { GameEvent } from "../../common/config/GameEvent";
 const { ccclass, property } = _decorator;
 
 /** 游戏资源加载 */
@@ -42,6 +42,7 @@ export class LoadingViewComp extends CCVMParentComp {
     start() {
         this.enter();
         this.setButton();
+        this.updateToggleState();
     }
 
     async enter() {
@@ -49,14 +50,27 @@ export class LoadingViewComp extends CCVMParentComp {
         if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
             const state = await CocosHandler.inst.getPrivacyStatus();
             console.log("隐私状态>>>>>>>>>>>>>>>>", state);
-            if (state) {
-                //同意过,是否是登录状态,同意过就请求数据保存数,然后直接加载资源
+            if (state.granted) {
+                const isWxLogin = oops.storage.getBoolean("isWxLogin");
+                if (isWxLogin) {
+                    //直接登录
+                    let result = await CocosHandler.inst.wechat_login();
+                    if (result.code) {
+                        this.setWxLoginBtnState(false);
+                        this.loadRes();
+                    } else {
+                        oops.gui.toast("登录失败,请重试")
+                    }
+                } else {
+                    console.log("缓存没有,需要显示登录按钮")
+                    this.setWxLoginBtnState(true);
+                }
             } else {
-                //没有同意过
                 oops.gui.open(UIID.KindTips);
             }
         } else {
             //非原生,网页的
+            this.setWxLoginBtnState(false);
             this.loadRes();
         }
     }
@@ -70,6 +84,8 @@ export class LoadingViewComp extends CCVMParentComp {
 
     private loginSuss() {
         //关闭按钮
+        this.setWxLoginBtnState(false);
+        this.loadRes();
         //加载资源
     }
 
@@ -79,7 +95,7 @@ export class LoadingViewComp extends CCVMParentComp {
         oops.gui.remove(UIID.KindTips);
         //如果是客户端就显示微信登录按钮
         if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
-            this.showWxLogin();
+            this.setWxLoginBtnState(true);
         } else {
             this.loadRes();
         }
@@ -131,17 +147,20 @@ export class LoadingViewComp extends CCVMParentComp {
      * @return {*}
      */
     private async btn_wxlogin() {
-        //跟安卓交互
+        //是否同意了我们的隐私政策
+        const agree = oops.storage.getBoolean("agree");
+        if (!agree) {
+            // oops.gui.open(UIID.KindTips);
+            oops.gui.toast("请同意隐私政策")
+            return;
+        }
+
+
+
         //登录完要隐藏微信按钮然后加载进度
         let result = await CocosHandler.inst.wechat_login();
         if (result.code) {
-
-            //登录成功
-            //存数据
-            const wxNode = this.node.getChildByName("login_node");
-            if (wxNode) {
-                wxNode.active = false;
-            }
+            this.setWxLoginBtnState(false);
             this.loadRes();
         } else {
 
@@ -158,13 +177,51 @@ export class LoadingViewComp extends CCVMParentComp {
      * @description: 显示微信登录
      * @return {*}
      */
-    showWxLogin() {
+    setWxLoginBtnState(state: boolean) {
         const wxNode = this.node.getChildByName("login_node");
         if (wxNode) {
-            wxNode.active = true;
+            wxNode.active = state;
+        }
+
+        //load条相反
+        const loadNode = this.node.getChildByName("pro_progress");
+        if (loadNode) {
+            loadNode.active = !state;
+        }
+    }
+
+
+    /**
+     * @description:隐私政策toggle
+     * @return {*}
+     */
+    onToggleChick(toggle: Toggle) {
+        if (toggle.isChecked) {
+            oops.storage.set("agree", true);
+        } else {
+            oops.storage.set("agree", false);
+        }
+    }
+
+
+    //更新toggle状态
+    updateToggleState() {
+        const agree = oops.storage.getBoolean("agree");
+        const toggle = this.node.getChildByPath("login_node/login_bg/tog_agree")!.uiToggle;
+        if (agree) {
+            toggle.isChecked = true;
+        } else {
+            toggle.isChecked = false;
         }
     }
 
+
+
+
+
+
+
+
     reset(): void { }