zane 1 mês atrás
pai
commit
6f6a028382

+ 55 - 15
assets/resources/prefab/item/BadgeItem.prefab

@@ -25,20 +25,23 @@
         "__id__": 26
       },
       {
-        "__id__": 34
+        "__id__": 36
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 40
+        "__id__": 42
       },
       {
-        "__id__": 42
+        "__id__": 44
+      },
+      {
+        "__id__": 46
       }
     ],
     "_prefab": {
-      "__id__": 44
+      "__id__": 48
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -427,7 +430,7 @@
   },
   {
     "__type__": "cc.Node",
-    "_name": "grade1",
+    "_name": "icon_badge",
     "_objFlags": 0,
     "__editorExtras__": {},
     "_parent": {
@@ -693,6 +696,9 @@
       },
       {
         "__id__": 33
+      },
+      {
+        "__id__": 34
       }
     ],
     "removedComponents": []
@@ -759,9 +765,25 @@
       "z": 0
     }
   },
+  {
+    "__type__": "CCPropertyOverrideInfo",
+    "targetInfo": {
+      "__id__": 35
+    },
+    "propertyPath": [
+      "_name"
+    ],
+    "value": "lbl_badge_addition"
+  },
+  {
+    "__type__": "cc.TargetInfo",
+    "localID": [
+      "feJ9lYYadIAZCqovEwh8Et"
+    ]
+  },
   {
     "__type__": "cc.Node",
-    "_name": "lbl_balance-002",
+    "_name": "lbl_badge_name",
     "_objFlags": 0,
     "__editorExtras__": {},
     "_parent": {
@@ -771,14 +793,14 @@
     "_active": true,
     "_components": [
       {
-        "__id__": 35
+        "__id__": 37
       },
       {
-        "__id__": 37
+        "__id__": 39
       }
     ],
     "_prefab": {
-      "__id__": 39
+      "__id__": 41
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -815,11 +837,11 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 34
+      "__id__": 36
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 36
+      "__id__": 38
     },
     "_contentSize": {
       "__type__": "cc.Size",
@@ -843,11 +865,11 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 34
+      "__id__": 36
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 38
+      "__id__": 40
     },
     "_customMaterial": null,
     "_srcBlendFactor": 2,
@@ -928,7 +950,7 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 41
+      "__id__": 43
     },
     "_contentSize": {
       "__type__": "cc.Size",
@@ -956,7 +978,7 @@
     },
     "_enabled": false,
     "__prefab": {
-      "__id__": 43
+      "__id__": 45
     },
     "_customMaterial": null,
     "_srcBlendFactor": 2,
@@ -991,6 +1013,24 @@
     "__type__": "cc.CompPrefabInfo",
     "fileId": "180EokzlVNW7EkEwOnua0Y"
   },
+  {
+    "__type__": "ffcf5imcnFDEKf4t/giSXZw",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 1
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 47
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "faysafvW1EXZUhvwwtzKNk"
+  },
   {
     "__type__": "cc.PrefabInfo",
     "root": {

+ 24 - 3
assets/resources/prefab/item/BadgeItem.ts

@@ -1,10 +1,31 @@
 import { _decorator, Component, Node } from "cc";
 import { BadgeInfo } from "../../scripts/api/UserM";
+import ConfigM from "../../scripts/api/ConfigM";
+import BaseUI from "../../scripts/base/BaseUI";
+import AB from "../../scripts/base/AB";
+import { Sprite } from "cc";
 const { ccclass, property } = _decorator;
 
 @ccclass("BadgeItem")
-export class BadgeItem extends Component {
-  init(item: BadgeInfo) {
-    
+export class BadgeItem extends BaseUI {
+  async init(item: BadgeInfo) {
+    let badge = ConfigM.ins.getBadge(item.id);
+
+    this.setText("lbl_badge_name", badge.desc);
+    this.setText("lbl_badge_addition", badge.addition + "%");
+
+    let path = null;
+    if (badge.type == 1) {
+      path = "texture/common/grade" + badge.id;
+    }
+
+    let iconSprite = this.FindAs("icon_badge", Sprite);
+
+    try {
+      let spriteFrame = await AB.ins.loadSpriteFrame(path);
+      iconSprite.spriteFrame = spriteFrame;
+    } catch (error) {
+      iconSprite.node.active = false;
+    }
   }
 }

+ 10 - 5
assets/resources/prefab/layer/BadgeDetailLayer.ts

@@ -30,17 +30,22 @@ export class BadgeDetailLayer extends BaseUI {
     this._type = type;
     let tpl: Prefab = await AB.ins.loadPrefab("prefab/item/BadgeItem");
 
-    let list = await UserM.ins.getBadgeList();
-
-    if (!list || !list.badgeList || list.badgeList.length == 0) {
+    let all = await UserM.ins.getBadgeList();
+    let list = [];
+    for (let i = 0; i < all.badgeList.length; i++) {
+      if (all.badgeList[i].type == type) {
+        list.push(all.badgeList[i]);
+      }
+    }
+    if (list.length == 0) {
       this.FindNode("NoData").active = true;
       return;
     }
 
     this.FindNode("NoData").active = false;
 
-    for (let i = 0; i < list.badgeList.length; i++) {
-      let item = list.badgeList[i];
+    for (let i = 0; i < list.length; i++) {
+      let item = list[i];
       let itemNode = instantiate(tpl);
       itemNode.getComponent(BadgeItem).init(item);
       this.scrollView.content.addChild(itemNode);

+ 10 - 0
assets/resources/scripts/api/ConfigM.ts

@@ -44,10 +44,17 @@ export class ConfigRecharge {
   bonusList: GoodInfo[];
   firstRechargeList: GoodInfo[];
 }
+export class ConfigBadge {
+  addition: number;
+  desc: string;
+  id: number;
+  type: number;
+}
 export class Config {
   goodList: ConfigGood[];
   storeList: ConfigStore[];
   rechargeList: ConfigRecharge[];
+  badgeList: ConfigBadge[];
 }
 
 export class ClientConfig {
@@ -60,6 +67,9 @@ export class ConfigGrade {
   addition: number;
 }
 export default class ConfigM {
+  getBadge(id: number): ConfigBadge {
+    return this._config.badgeList.find((item) => item.id == id);
+  }
   getGradeAllocation(_grade: number) {
     let r = [5, 10, 10, 24, 26, 20, 5];
     return r[_grade - 1];

+ 2 - 1
assets/resources/scripts/api/UserM.ts

@@ -57,8 +57,9 @@ export default class UserM {
       this.data?.walletAddress != null && this.data?.walletAddress.length > 0
     );
   }
-  async getBadgeList() {
+  async getBadgeList( ) {
     let result = await WsM.ins.syncRequest(20002, {});
+    
     return result;
   }
   getGamePassCount() {