1.修改轮播图数据为服务器加载并且可以点击跳转
Showing
3 changed files
with
92 additions
and
71 deletions
... | @@ -28,15 +28,13 @@ cc.Class({ | ... | @@ -28,15 +28,13 @@ cc.Class({ |
28 | // cc.find('Select/Name/ActiveName/NameContainer', this.node).width = data.width - 10; | 28 | // cc.find('Select/Name/ActiveName/NameContainer', this.node).width = data.width - 10; |
29 | // cc.find('Select/Name/ActiveName/NameContainer/NameText', this.node).width = data.width - 10; | 29 | // cc.find('Select/Name/ActiveName/NameContainer/NameText', this.node).width = data.width - 10; |
30 | // this.normalName.node.width = data.width - 10; | 30 | // this.normalName.node.width = data.width - 10; |
31 | let aTitle = ["魔法沙拉2", "奔跑吧小兔子", "勇敢的啫喱", "记忆翻牌"]; | 31 | this.title.string = data.name; |
32 | let aName = ["和爸妈一起做一盘沙拉", "和小兔子一起出门吧", "和Q弹的彩色啫喱锻炼身体", "上完网课,锻炼下记忆力"]; | 32 | this.selectTitle.string = data.name; |
33 | this.title.string = aTitle[i]; | 33 | this.activeName1.string = data.description; |
34 | this.selectTitle.string=aTitle[i]; | 34 | this.activeName2.string = data.description; |
35 | this.activeName1.string = data.title || aName[i]; | 35 | this.normalName.string = data.description; |
36 | this.activeName2.string = data.title || aName[i]; | 36 | this.afterTitle.string = data.name; |
37 | this.normalName.string = data.title || aName[i]; | 37 | this.afterName.string = data.description; |
38 | this.afterTitle.string = aTitle[i]; | ||
39 | this.afterName.string = aName[i]; | ||
40 | // this.activeName1._updateRenderData(true); | 38 | // this.activeName1._updateRenderData(true); |
41 | // this.activeName2._updateRenderData(true); | 39 | // this.activeName2._updateRenderData(true); |
42 | // this.normalName._updateRenderData(true); | 40 | // this.normalName._updateRenderData(true); | ... | ... |
... | @@ -106,57 +106,49 @@ cc.Class({ | ... | @@ -106,57 +106,49 @@ cc.Class({ |
106 | 106 | ||
107 | //搞轮播图 | 107 | //搞轮播图 |
108 | this.initViewPager(); | 108 | this.initViewPager(); |
109 | this.initViewPagerRightLabel(); | ||
110 | //搞通知框 | 109 | //搞通知框 |
111 | this.initNotifyBox(); | 110 | this.initNotifyBox(); |
111 | //升级相关 | ||
112 | // this.getUpdateDesc(); | 112 | // this.getUpdateDesc(); |
113 | this.getMainLayoutJsonRequest(); | 113 | this.getMainLayoutJsonRequest(); |
114 | // this.getCategoryListRecommendRequest(); | ||
115 | }, | 114 | }, |
116 | 115 | ||
116 | //轮播图相关 | ||
117 | initViewPager: function () { | 117 | initViewPager: function () { |
118 | //搞初始化轮播图 | 118 | this._pageView = cc.find('scrollContent/ViewPagerArea', this.node).getComponent(cc.PageView); |
119 | let aViewPagerPic = ["魔法沙拉Ⅱ564-358", "奇幻海底564-358", "勇敢的啫喱564-358", "飞檐走壁564-358"]; | 119 | Network.ajax("GET", Common.TOPDRAW_API_SERVER + "main/main_viewpager.json", null, null, |
120 | for (let i = 0; i < 4; i++) { | 120 | function (strResponse) { |
121 | try { | ||
122 | // cc.log("请求viewPager数据:" + strResponse); | ||
123 | var oJSONResult = JSON.parse(strResponse); | ||
124 | for (let i = 0; i < oJSONResult.resultSet.length; i++) { | ||
121 | let nodeViewPager = cc.find("scrollContent/ViewPagerArea/view/Content/page_" + i, this.node); | 125 | let nodeViewPager = cc.find("scrollContent/ViewPagerArea/view/Content/page_" + i, this.node); |
122 | cc.loader.loadRes("Main/" + aViewPagerPic[i], cc.Texture2D, function (err, texture) { | 126 | let blockShadow = cc.find("scrollContent/BlockShadow", this.node); |
127 | //搞图片 | ||
128 | Network.loadImageInNativeRuntime(Common.TOPDRAW_IMAGE_SERVER + oJSONResult.resultSet[i].images.fileUrl, null, | ||
129 | function (texture, iRequestId) { | ||
123 | nodeViewPager.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture); | 130 | nodeViewPager.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture); |
124 | }); | 131 | }, function () { }, this |
125 | } | 132 | ); |
126 | |||
127 | this._pageView = cc.find('scrollContent/ViewPagerArea', this.node).getComponent(cc.PageView); | ||
128 | this.schedule(() => { //TODO:PageView自动轮播 | ||
129 | //一共多少页 | ||
130 | let count = this._pageView.getPages().length; | ||
131 | //取当前页下序号 | ||
132 | let index = this._pageView.getCurrentPageIndex(); | ||
133 | //为最后一页,index为0,否则+1 | ||
134 | // index = index+1 >= count ? 0 : index ++; | ||
135 | if (index + 1 >= count) { | ||
136 | index = 0; | ||
137 | } else { | ||
138 | index++; | ||
139 | } | ||
140 | //执行切换 | ||
141 | // this._pageView.scrollToPage(index); | ||
142 | if (index == 0) this._pageView.update(10); //解决强制滑动到1后回弹效果 | ||
143 | }, 3); //3秒间隔 | ||
144 | }, | ||
145 | 133 | ||
146 | initViewPagerRightLabel: function () { | ||
147 | let blockShadow = cc.find("scrollContent/BlockShadow", this.node); | ||
148 | for (let i = 0; i < 4; i++) { | ||
149 | let nodeNav = cc.instantiate(this.PFB_VIEWPAGER_LABEL); | 134 | let nodeNav = cc.instantiate(this.PFB_VIEWPAGER_LABEL); |
150 | nodeNav.getComponent(cc.Widget).top = i * (nodeNav.height + 2); | 135 | nodeNav.getComponent(cc.Widget).top = i * (nodeNav.height + 2); |
151 | blockShadow.addChild(nodeNav, 10, "view_pager_label" + i); | 136 | blockShadow.addChild(nodeNav, 10, "view_pager_label" + i); |
152 | nodeNav.getComponent('pfbViewPagerLabelCell').init("", function () { //让细胞自己渲染 | 137 | nodeNav.getComponent('pfbViewPagerLabelCell').init(oJSONResult.resultSet[i], function () { //让细胞自己渲染 |
153 | }, i); | 138 | }, i); |
154 | 139 | ||
155 | let fiNav = nodeNav.addComponent(FocusInfo); | 140 | let fiNav = nodeNav.addComponent(FocusInfo); |
156 | fiNav.init(null, false, null, null, 1.1); //最后一个参数决定要不要放大显示 | 141 | fiNav.init(oJSONResult.resultSet[i].tvlink, false, null, null, 1.1); //最后一个参数决定要不要放大显示 |
157 | 142 | ||
158 | this._aFocusTargets[0]["view_pager_label" + i] = nodeNav; | 143 | this._aFocusTargets[0]["view_pager_label" + i] = nodeNav; |
159 | } | 144 | } |
145 | } catch (error) { | ||
146 | cc.log("Business Exception:Get getUpdateDesc..." + error); | ||
147 | } | ||
148 | }, | ||
149 | function (strResponse) { | ||
150 | cc.log("Business Error:Get getUpdateDesc..." + strResponse); | ||
151 | }, this, "uuid"); | ||
160 | }, | 152 | }, |
161 | 153 | ||
162 | initNotifyBox: function () { | 154 | initNotifyBox: function () { |
... | @@ -174,7 +166,7 @@ cc.Class({ | ... | @@ -174,7 +166,7 @@ cc.Class({ |
174 | 166 | ||
175 | //升级框内容 | 167 | //升级框内容 |
176 | getUpdateDesc: function () { | 168 | getUpdateDesc: function () { |
177 | Network.ajax("GET", "http://topdraw-game.oss-cn-shanghai.aliyuncs.com/forfun/updateDesc.json", null, null, | 169 | Network.ajax("GET", Common.TOPDRAW_API_SERVER + "updateDesc.json", null, null, |
178 | function (strResponse) { | 170 | function (strResponse) { |
179 | try { | 171 | try { |
180 | cc.log("获取升级内容。。。" + strResponse); | 172 | cc.log("获取升级内容。。。" + strResponse); |
... | @@ -584,38 +576,9 @@ cc.Class({ | ... | @@ -584,38 +576,9 @@ cc.Class({ |
584 | this._aFocusTargets[0][oModule.code] = node; | 576 | this._aFocusTargets[0][oModule.code] = node; |
585 | } | 577 | } |
586 | 578 | ||
587 | |||
588 | |||
589 | if (0 == oModule.name.indexOf("blockShadow")) { | 579 | if (0 == oModule.name.indexOf("blockShadow")) { |
590 | node.opacity = 0; | 580 | node.opacity = 0; |
591 | } | 581 | } |
592 | |||
593 | // if (oModule.title_visible == 1) { // | ||
594 | // cc.find('Name', node).active = true; | ||
595 | // cc.find('Name', node).width = oModule.width - 10; | ||
596 | // cc.find('Name/NameBg', node).width = oModule.width; | ||
597 | // cc.find('Name/NormalName', node).width = oModule.width - 10; | ||
598 | // cc.find('Name/ActiveName', node).width = oModule.width - 10; | ||
599 | // cc.find('Name/ActiveName/NameContainer', node).width = oModule.width - 10; | ||
600 | // cc.find('Name/ActiveName/NameContainer/NameText', node).width = oModule.width - 10; | ||
601 | // this.normalName.node.width = oModule.width - 10; | ||
602 | // this.activeName1.string = oModule.title; | ||
603 | // this.activeName2.string = oModule.title; | ||
604 | // this.normalName.string = oModule.title; | ||
605 | // this.activeName1._updateRenderData(true); | ||
606 | // this.activeName2._updateRenderData(true); | ||
607 | // this.normalName._updateRenderData(true); | ||
608 | |||
609 | // //调整文字位置 | ||
610 | // let nodeCellName = this.node.getChildByName('Name'); | ||
611 | // let nodeScreenTitleText = cc.find('ActiveName/NameContainer/NameText', nodeCellName); | ||
612 | // let nodeScreenTitleText1 = nodeScreenTitleText.getChildByName('NameText1'); | ||
613 | // if (nodeScreenTitleText1.width > nodeScreenTitleText.width) { | ||
614 | // this.normalName.overflow = cc.Label.Overflow.CLAMP; | ||
615 | // this.normalName.enableWrapText = false; | ||
616 | // this.normalName.horizontalAlign = cc.Label.HorizontalAlign.LEFT; | ||
617 | // } | ||
618 | // } | ||
619 | } | 582 | } |
620 | } | 583 | } |
621 | } | 584 | } |
... | @@ -650,6 +613,7 @@ cc.Class({ | ... | @@ -650,6 +613,7 @@ cc.Class({ |
650 | this.onScrollViewScrollStart(); | 613 | this.onScrollViewScrollStart(); |
651 | this._scrollview.scrollToOffset(cc.v2(0, height), 0.5); | 614 | this._scrollview.scrollToOffset(cc.v2(0, height), 0.5); |
652 | var showFocusCallback = function (dt) { | 615 | var showFocusCallback = function (dt) { |
616 | if (0 != this._fiCurrentFocus.node.name.indexOf("view_pager_label")) | ||
653 | this._cFocus.show(); | 617 | this._cFocus.show(); |
654 | this.onScrollViewScrollEnd(); | 618 | this.onScrollViewScrollEnd(); |
655 | } | 619 | } |
... | @@ -659,6 +623,11 @@ cc.Class({ | ... | @@ -659,6 +623,11 @@ cc.Class({ |
659 | this._cFocus.flyFocus(this._fiCurrentFocus, fiFocusTarget, Common.MOVE_DIRECTION_DOWN, null, null); | 623 | this._cFocus.flyFocus(this._fiCurrentFocus, fiFocusTarget, Common.MOVE_DIRECTION_DOWN, null, null); |
660 | this.scheduleOnce(showFocusCallback, 0.5); | 624 | this.scheduleOnce(showFocusCallback, 0.5); |
661 | }, 0.5); | 625 | }, 0.5); |
626 | |||
627 | let blockShadow = cc.find("scrollContent/BlockShadow", this.node); | ||
628 | for (let i = 0; i < blockShadow.childrenCount; i++) { | ||
629 | blockShadow.children[i].active = true; | ||
630 | } | ||
662 | // } | 631 | // } |
663 | 632 | ||
664 | }, | 633 | }, | ... | ... |
1 | { | ||
2 | "businessCode": "success", | ||
3 | "count": 1, | ||
4 | "resultSet": [ | ||
5 | { | ||
6 | "name": "魔法沙拉2", | ||
7 | "description": "和爸妈一起做一盘沙拉", | ||
8 | "tvlink": "{\"click\":[{\"action\":\"ChangeScene\",\"parameters\":{\"sceneName\":\"sceneGameDetail\",\"packageName\":\"com.Orbbec.MagicSalad2\",\"activityName\":\"com.orbbec.u3d.OrbbecActivity\",\"downloadUrl\":\"apk/com.Orbbec.MagicSalad2_v1.2.0_20190110_Release.apk\"}}]}", | ||
9 | "images": { | ||
10 | "extension": ".png", | ||
11 | "enable": true, | ||
12 | "fileUrl": "upload/image/main/魔法沙拉Ⅱ564-358.png", | ||
13 | "width": 564, | ||
14 | "height": 358 | ||
15 | } | ||
16 | }, | ||
17 | { | ||
18 | "name": "奇幻海底", | ||
19 | "description": "和小兔子一起出门吧", | ||
20 | "tvlink": "{\"click\":[{\"action\":\"ChangeScene\",\"parameters\":{\"sceneName\":\"sceneGameDetail\",\"packageName\":\"com.orbbec.OceanAR\",\"activityName\":\"com.orbbec.u3d.OrbbecActivity\",\"downloadUrl\":\"apk/com.orbbec.OceanAR_v2.1.14_bc89_20190704_Release.apk\"}}]}", | ||
21 | "images": { | ||
22 | "extension": ".png", | ||
23 | "enable": true, | ||
24 | "fileUrl": "upload/image/main/奇幻海底564-358.png", | ||
25 | "width": 564, | ||
26 | "height": 358 | ||
27 | } | ||
28 | }, | ||
29 | { | ||
30 | "name": "勇敢的啫喱", | ||
31 | "description": "和Q弹的彩色啫喱锻炼身体", | ||
32 | "tvlink": "{\"click\":[{\"action\":\"ChangeScene\",\"parameters\":{\"sceneName\":\"sceneGameDetail\",\"packageName\":\"com.Orbbec.BraveJelly\",\"activityName\":\"com.orbbec.u3d.OrbbecActivity\",\"downloadUrl\":\"apk/com.Orbbec.BraveJelly_v2.0.27_bc31_20190702_Release.apk\"}}]}", | ||
33 | "images": { | ||
34 | "extension": ".png", | ||
35 | "enable": true, | ||
36 | "fileUrl": "upload/image/main/勇敢的啫喱564-358.png", | ||
37 | "width": 564, | ||
38 | "height": 358 | ||
39 | } | ||
40 | }, | ||
41 | { | ||
42 | "name": "飞檐走壁", | ||
43 | "description": "上完网课,锻炼下记忆力", | ||
44 | "tvlink": "{\"click\":[{\"action\":\"ChangeScene\",\"parameters\":{\"sceneName\":\"sceneGameDetail\",\"packageName\":\"com.topdraw.xhx.feiyanzoubi\"}}]}", | ||
45 | "images": { | ||
46 | "extension": ".png", | ||
47 | "enable": true, | ||
48 | "fileUrl": "upload/image/main/飞檐走壁564-358.png", | ||
49 | "width": 564, | ||
50 | "height": 358 | ||
51 | } | ||
52 | } | ||
53 | ] | ||
54 | } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or sign in to post a comment