Przeglądaj źródła

解决商店界面点击后错误显示

eraser 3 lat temu
rodzic
commit
128f9614da
2 zmienionych plików z 18 dodań i 12 usunięć
  1. 3 3
      assets/Scene/MyCityScene - 004.fire
  2. 15 9
      assets/Script/UI/StoreView.js

+ 3 - 3
assets/Scene/MyCityScene - 004.fire

@@ -46026,7 +46026,7 @@
         "__id__": 1082
       }
     ],
-    "_active": true,
+    "_active": false,
     "_level": 2,
     "_components": [
       {
@@ -50364,7 +50364,7 @@
     "component": "",
     "_componentId": "fb162WetE9HbrPBo5d+xTNb",
     "handler": "onSwitchBuildingContent",
-    "customEventData": "1"
+    "customEventData": "0"
   },
   {
     "__type__": "cc.ClickEvent",
@@ -50575,7 +50575,7 @@
     "component": "",
     "_componentId": "fb162WetE9HbrPBo5d+xTNb",
     "handler": "onSwitchBuildingContent",
-    "customEventData": "2"
+    "customEventData": "1"
   },
   {
     "__type__": "cc.ClickEvent",

+ 15 - 9
assets/Script/UI/StoreView.js

@@ -41,6 +41,11 @@ cc.Class({
         seedSpriteFrame: {
             default: [],
             type: [cc.SpriteFrame]
+        },
+
+        seedNodeArry: {
+            default: [],
+            type: [cc.Node]
         }
     },
     HiddenAll() {
@@ -50,16 +55,13 @@ cc.Class({
             this.Exchange.active = false;
     },
     start() {
-        this.seedNodeArry = [];
         //默认设置第一个节点为 最上面
         this.SeedBtn.setSiblingIndex(10);
-
+        
         //获取种子和果实
         GlobalD.GameData.getMallSeed((res, vaule) => {
             this.mySeedList = vaule.data.seed;
-            //this.myFruitList = vaule.data.fruit;
-
-            //console.log(this.mySeedList, this.myFruitList);
+            
             for (let i = 0; i < this.mySeedList.length; i++) {
                 //没有种子数量不显示 todo 看看后续需不需要处理删除
                 if (this.mySeedList[i].amount < 1) continue;
@@ -123,22 +125,26 @@ cc.Class({
         //面板设置index
         
         //种子
-        if ('1' == index) {
+        if ('0' == index) {
             this.SeedBtn.y = -20;
             this.SeedBtn.getComponent(cc.Sprite).spriteFrame = this.Selecteded_Seed_Sprite;
             this.Seed.active = true;
-            this.SelectedFrame.parent = this.seedNodeArry[0];
 
+            if(this.seedNodeArry.length!=0)
+            {
+                this.SelectedFrame.parent = this.seedNodeArry[0];
+            }
+       
             //if (this.mySeedList.length > 0) {
             //    let Synopsis = "成熟期:" + this.mySeedList[0].maturity;
             //    this.ManageUI.getComponent('ManageUI').onSetButtonInfo(this.mySeedList[0].name, this.mySeedList[0].priceSnb, Synopsis);
             //}
-
+  
             this.SeedBtn.setSiblingIndex(10);
             this.SeedBtn.setContentSize(86, 88);
         }
         //兑换
-        else if ('2' == index) {
+        else if ('1' == index) {
             this.ExchangeBtn.y = -20;
             this.ExchangeBtn.getComponent(cc.Sprite).spriteFrame = this.Selecteded_Exchange_Sprite;
             this.Exchange.active = true;