Browse Source

选择职业时,选择下一个艺人时需要刷新pageView内容。性别不一样问题

hwt 6 years ago
parent
commit
6607bd2d2a

+ 3 - 3
assets/resources/prefabs/change_job.prefab

@@ -4274,7 +4274,7 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 94,
+      "width": 90,
       "height": 40
     },
     "_rotationX": 0,
@@ -4381,7 +4381,7 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 4,
+      "width": 0,
       "height": 50
     },
     "_rotationX": 0,
@@ -5708,7 +5708,7 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 54,
+      "width": 52,
       "height": 30
     },
     "_rotationX": 0,

+ 5 - 5
assets/scripts/job/ChangeJob.js

@@ -79,13 +79,12 @@ cc.Class({
         this.user.active = false;
         this.pageView.node.active = true;
         this.levelUpNode.active = false;
-        this.pageView.getComponent('PVCtrl').bind(this.actorInfo.jobId, this.actorInfo.gender);
+        this.pageViewScript = this.pageView.getComponent('PVCtrl');
+        this.pageViewScript.bind(this.actorInfo.jobId, this.actorInfo.gender);
 
         this.titleText.string = '<b>职业转换</b>';
         this.confirmText.string = '<outline color=#690802 width=1><b>转职</b></outline>';
 
-        this.pageViewScript = this.pageView.getComponent('PVCtrl');
-
         JobApi.changeJobList(this.actorInfo.uid,
             (response) => {
                 this.userPack = response.userPack;
@@ -115,12 +114,12 @@ cc.Class({
         this.user.active = true;
         this.pageView.node.active = true;
         this.levelUpNode.active = false;
-        this.pageView.getComponent('PVCtrl').bind(0, this.actorInfo.gender);
+        this.pageViewScript = this.pageView.getComponent('PVCtrl');
+        this.pageViewScript.bind(0, this.actorInfo.gender);
 
         this.titleText.string = '<b>选择职业</b>';
         this.confirmText.string = '<outline color=#690802 width=1><b>确定</b></outline>';
 
-        this.pageViewScript = this.pageView.getComponent('PVCtrl');
         this.pageViewScript.bindSelectedJobText();
         this.bindChooseJob(this.actorInfo);
     },
@@ -242,6 +241,7 @@ cc.Class({
     },
 
     bindChooseJob() {
+        this.pageViewScript.bind(0, this.actorInfo.gender);
         this.user.getComponent('Actor').bind(this.actorInfo);
     },
 

+ 15 - 15
assets/scripts/job/PVCtrl.js

@@ -30,21 +30,6 @@ cc.Class({
             let item = cc.instantiate(this.jobItem);
             item.active = true;
             item.position = new cc.p(0, 0);
-            item.getComponent('JobItem').bind(this.jobList[i]);
-            this.pageview.addPage(item);
-        }
-        ///动态添加item的时候必须加这两行代码,刷新PageView的各种数值参数,让界面正常显示
-        this.pageview.sizeMode = cc.PageView.SizeMode.Free;
-        this.pageview._updatePageView();
-    },
-
-    bindJobList(jobList) {
-        this.pageview.removeAllPages();
-        this.jobList = jobList;
-        for (var i = 0; i < this.jobList.length; i++) {
-            let item = cc.instantiate(this.jobItem);
-            item.active = true;
-            item.position = new cc.p(0, 0);
             item.getComponent('JobItem').bind(this.jobList[i], this.gender);
             this.pageview.addPage(item);
         }
@@ -53,6 +38,21 @@ cc.Class({
         this.pageview._updatePageView();
     },
 
+    // bindJobList(jobList) {
+    //     this.pageview.removeAllPages();
+    //     this.jobList = jobList;
+    //     for (var i = 0; i < this.jobList.length; i++) {
+    //         let item = cc.instantiate(this.jobItem);
+    //         item.active = true;
+    //         item.position = new cc.p(0, 0);
+    //         item.getComponent('JobItem').bind(this.jobList[i], this.gender);
+    //         this.pageview.addPage(item);
+    //     }
+    //     ///动态添加item的时候必须加这两行代码,刷新PageView的各种数值参数,让界面正常显示
+    //     this.pageview.sizeMode = cc.PageView.SizeMode.Free;
+    //     this.pageview._updatePageView();
+    // },
+
     bindSelectedJobText() {
         let jobInfo = this.jobList[this.pageview.getCurrentPageIndex()];
         this.artistIconSprite.spriteFrame = this.jobIconFrames[jobInfo.id - 1];