Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
apk_product
/
ForFun
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
72776ef7
...
72776ef70c466d4fd778778afc02252edcbde8cb
authored
2020-03-17 10:33:23 +0800
by
金学艇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.修改轮播图数据为服务器加载并且可以点击跳转
1 parent
40c814d2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
101 additions
and
80 deletions
assets/Script/listCell/pfbViewPagerLabelCell.js
assets/Script/main.js
assets/resources/data_template/main_viewpager.json
assets/Script/listCell/pfbViewPagerLabelCell.js
View file @
72776ef
...
...
@@ -28,15 +28,13 @@ cc.Class({
// cc.find('Select/Name/ActiveName/NameContainer', this.node).width = data.width - 10;
// cc.find('Select/Name/ActiveName/NameContainer/NameText', this.node).width = data.width - 10;
// this.normalName.node.width = data.width - 10;
let
aTitle
=
[
"魔法沙拉2"
,
"奔跑吧小兔子"
,
"勇敢的啫喱"
,
"记忆翻牌"
];
let
aName
=
[
"和爸妈一起做一盘沙拉"
,
"和小兔子一起出门吧"
,
"和Q弹的彩色啫喱锻炼身体"
,
"上完网课,锻炼下记忆力"
];
this
.
title
.
string
=
aTitle
[
i
];
this
.
selectTitle
.
string
=
aTitle
[
i
];
this
.
activeName1
.
string
=
data
.
title
||
aName
[
i
];
this
.
activeName2
.
string
=
data
.
title
||
aName
[
i
];
this
.
normalName
.
string
=
data
.
title
||
aName
[
i
];
this
.
afterTitle
.
string
=
aTitle
[
i
];
this
.
afterName
.
string
=
aName
[
i
];
this
.
title
.
string
=
data
.
name
;
this
.
selectTitle
.
string
=
data
.
name
;
this
.
activeName1
.
string
=
data
.
description
;
this
.
activeName2
.
string
=
data
.
description
;
this
.
normalName
.
string
=
data
.
description
;
this
.
afterTitle
.
string
=
data
.
name
;
this
.
afterName
.
string
=
data
.
description
;
// this.activeName1._updateRenderData(true);
// this.activeName2._updateRenderData(true);
// this.normalName._updateRenderData(true);
...
...
assets/Script/main.js
View file @
72776ef
...
...
@@ -106,57 +106,49 @@ cc.Class({
//搞轮播图
this
.
initViewPager
();
this
.
initViewPagerRightLabel
();
//搞通知框
this
.
initNotifyBox
();
//升级相关
// this.getUpdateDesc();
this
.
getMainLayoutJsonRequest
();
// this.getCategoryListRecommendRequest();
},
//轮播图相关
initViewPager
:
function
()
{
//搞初始化轮播图
let
aViewPagerPic
=
[
"魔法沙拉Ⅱ564-358"
,
"奇幻海底564-358"
,
"勇敢的啫喱564-358"
,
"飞檐走壁564-358"
];
for
(
let
i
=
0
;
i
<
4
;
i
++
)
{
let
nodeViewPager
=
cc
.
find
(
"scrollContent/ViewPagerArea/view/Content/page_"
+
i
,
this
.
node
);
cc
.
loader
.
loadRes
(
"Main/"
+
aViewPagerPic
[
i
],
cc
.
Texture2D
,
function
(
err
,
texture
)
{
nodeViewPager
.
getComponent
(
cc
.
Sprite
).
spriteFrame
=
new
cc
.
SpriteFrame
(
texture
);
});
}
this
.
_pageView
=
cc
.
find
(
'scrollContent/ViewPagerArea'
,
this
.
node
).
getComponent
(
cc
.
PageView
);
this
.
schedule
(()
=>
{
//TODO:PageView自动轮播
//一共多少页
let
count
=
this
.
_pageView
.
getPages
().
length
;
//取当前页下序号
let
index
=
this
.
_pageView
.
getCurrentPageIndex
();
//为最后一页,index为0,否则+1
// index = index+1 >= count ? 0 : index ++;
if
(
index
+
1
>=
count
)
{
index
=
0
;
}
else
{
index
++
;
}
//执行切换
// this._pageView.scrollToPage(index);
if
(
index
==
0
)
this
.
_pageView
.
update
(
10
);
//解决强制滑动到1后回弹效果
},
3
);
//3秒间隔
},
Network
.
ajax
(
"GET"
,
Common
.
TOPDRAW_API_SERVER
+
"main/main_viewpager.json"
,
null
,
null
,
function
(
strResponse
)
{
try
{
// cc.log("请求viewPager数据:" + strResponse);
var
oJSONResult
=
JSON
.
parse
(
strResponse
);
for
(
let
i
=
0
;
i
<
oJSONResult
.
resultSet
.
length
;
i
++
)
{
let
nodeViewPager
=
cc
.
find
(
"scrollContent/ViewPagerArea/view/Content/page_"
+
i
,
this
.
node
);
let
blockShadow
=
cc
.
find
(
"scrollContent/BlockShadow"
,
this
.
node
);
//搞图片
Network
.
loadImageInNativeRuntime
(
Common
.
TOPDRAW_IMAGE_SERVER
+
oJSONResult
.
resultSet
[
i
].
images
.
fileUrl
,
null
,
function
(
texture
,
iRequestId
)
{
nodeViewPager
.
getComponent
(
cc
.
Sprite
).
spriteFrame
=
new
cc
.
SpriteFrame
(
texture
);
},
function
()
{
},
this
);
initViewPagerRightLabel
:
function
()
{
let
blockShadow
=
cc
.
find
(
"scrollContent/BlockShadow"
,
this
.
node
);
for
(
let
i
=
0
;
i
<
4
;
i
++
)
{
let
nodeNav
=
cc
.
instantiate
(
this
.
PFB_VIEWPAGER_LABEL
);
nodeNav
.
getComponent
(
cc
.
Widget
).
top
=
i
*
(
nodeNav
.
height
+
2
);
blockShadow
.
addChild
(
nodeNav
,
10
,
"view_pager_label"
+
i
);
nodeNav
.
getComponent
(
'pfbViewPagerLabelCell'
).
init
(
""
,
function
()
{
//让细胞自己渲染
},
i
);
let
nodeNav
=
cc
.
instantiate
(
this
.
PFB_VIEWPAGER_LABEL
);
nodeNav
.
getComponent
(
cc
.
Widget
).
top
=
i
*
(
nodeNav
.
height
+
2
);
blockShadow
.
addChild
(
nodeNav
,
10
,
"view_pager_label"
+
i
);
nodeNav
.
getComponent
(
'pfbViewPagerLabelCell'
).
init
(
oJSONResult
.
resultSet
[
i
],
function
()
{
//让细胞自己渲染
},
i
);
let
fiNav
=
nodeNav
.
addComponent
(
FocusInfo
);
fiNav
.
init
(
null
,
false
,
null
,
null
,
1.1
);
//最后一个参数决定要不要放大显示
let
fiNav
=
nodeNav
.
addComponent
(
FocusInfo
);
fiNav
.
init
(
oJSONResult
.
resultSet
[
i
].
tvlink
,
false
,
null
,
null
,
1.1
);
//最后一个参数决定要不要放大显示
this
.
_aFocusTargets
[
0
][
"view_pager_label"
+
i
]
=
nodeNav
;
}
this
.
_aFocusTargets
[
0
][
"view_pager_label"
+
i
]
=
nodeNav
;
}
}
catch
(
error
)
{
cc
.
log
(
"Business Exception:Get getUpdateDesc..."
+
error
);
}
},
function
(
strResponse
)
{
cc
.
log
(
"Business Error:Get getUpdateDesc..."
+
strResponse
);
},
this
,
"uuid"
);
},
initNotifyBox
:
function
()
{
...
...
@@ -174,7 +166,7 @@ cc.Class({
//升级框内容
getUpdateDesc
:
function
()
{
Network
.
ajax
(
"GET"
,
"http://topdraw-game.oss-cn-shanghai.aliyuncs.com/forfun/
updateDesc.json"
,
null
,
null
,
Network
.
ajax
(
"GET"
,
Common
.
TOPDRAW_API_SERVER
+
"
updateDesc.json"
,
null
,
null
,
function
(
strResponse
)
{
try
{
cc
.
log
(
"获取升级内容。。。"
+
strResponse
);
...
...
@@ -584,38 +576,9 @@ cc.Class({
this
.
_aFocusTargets
[
0
][
oModule
.
code
]
=
node
;
}
if
(
0
==
oModule
.
name
.
indexOf
(
"blockShadow"
))
{
node
.
opacity
=
0
;
}
// if (oModule.title_visible == 1) { //
// cc.find('Name', node).active = true;
// cc.find('Name', node).width = oModule.width - 10;
// cc.find('Name/NameBg', node).width = oModule.width;
// cc.find('Name/NormalName', node).width = oModule.width - 10;
// cc.find('Name/ActiveName', node).width = oModule.width - 10;
// cc.find('Name/ActiveName/NameContainer', node).width = oModule.width - 10;
// cc.find('Name/ActiveName/NameContainer/NameText', node).width = oModule.width - 10;
// this.normalName.node.width = oModule.width - 10;
// this.activeName1.string = oModule.title;
// this.activeName2.string = oModule.title;
// this.normalName.string = oModule.title;
// this.activeName1._updateRenderData(true);
// this.activeName2._updateRenderData(true);
// this.normalName._updateRenderData(true);
// //调整文字位置
// let nodeCellName = this.node.getChildByName('Name');
// let nodeScreenTitleText = cc.find('ActiveName/NameContainer/NameText', nodeCellName);
// let nodeScreenTitleText1 = nodeScreenTitleText.getChildByName('NameText1');
// if (nodeScreenTitleText1.width > nodeScreenTitleText.width) {
// this.normalName.overflow = cc.Label.Overflow.CLAMP;
// this.normalName.enableWrapText = false;
// this.normalName.horizontalAlign = cc.Label.HorizontalAlign.LEFT;
// }
// }
}
}
}
...
...
@@ -650,7 +613,8 @@ cc.Class({
this
.
onScrollViewScrollStart
();
this
.
_scrollview
.
scrollToOffset
(
cc
.
v2
(
0
,
height
),
0.5
);
var
showFocusCallback
=
function
(
dt
)
{
this
.
_cFocus
.
show
();
if
(
0
!=
this
.
_fiCurrentFocus
.
node
.
name
.
indexOf
(
"view_pager_label"
))
this
.
_cFocus
.
show
();
this
.
onScrollViewScrollEnd
();
}
this
.
scheduleOnce
(
function
()
{
...
...
@@ -659,6 +623,11 @@ cc.Class({
this
.
_cFocus
.
flyFocus
(
this
.
_fiCurrentFocus
,
fiFocusTarget
,
Common
.
MOVE_DIRECTION_DOWN
,
null
,
null
);
this
.
scheduleOnce
(
showFocusCallback
,
0.5
);
},
0.5
);
let
blockShadow
=
cc
.
find
(
"scrollContent/BlockShadow"
,
this
.
node
);
for
(
let
i
=
0
;
i
<
blockShadow
.
childrenCount
;
i
++
)
{
blockShadow
.
children
[
i
].
active
=
true
;
}
// }
},
...
...
assets/resources/data_template/main_viewpager.json
0 → 100644
View file @
72776ef
{
"businessCode"
:
"success"
,
"count"
:
1
,
"resultSet"
:
[
{
"name"
:
"魔法沙拉2"
,
"description"
:
"和爸妈一起做一盘沙拉"
,
"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
\"
}}]}"
,
"images"
:
{
"extension"
:
".png"
,
"enable"
:
true
,
"fileUrl"
:
"upload/image/main/魔法沙拉Ⅱ564-358.png"
,
"width"
:
564
,
"height"
:
358
}
},
{
"name"
:
"奇幻海底"
,
"description"
:
"和小兔子一起出门吧"
,
"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
\"
}}]}"
,
"images"
:
{
"extension"
:
".png"
,
"enable"
:
true
,
"fileUrl"
:
"upload/image/main/奇幻海底564-358.png"
,
"width"
:
564
,
"height"
:
358
}
},
{
"name"
:
"勇敢的啫喱"
,
"description"
:
"和Q弹的彩色啫喱锻炼身体"
,
"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
\"
}}]}"
,
"images"
:
{
"extension"
:
".png"
,
"enable"
:
true
,
"fileUrl"
:
"upload/image/main/勇敢的啫喱564-358.png"
,
"width"
:
564
,
"height"
:
358
}
},
{
"name"
:
"飞檐走壁"
,
"description"
:
"上完网课,锻炼下记忆力"
,
"tvlink"
:
"{
\"
click
\"
:[{
\"
action
\"
:
\"
ChangeScene
\"
,
\"
parameters
\"
:{
\"
sceneName
\"
:
\"
sceneGameDetail
\"
,
\"
packageName
\"
:
\"
com.topdraw.xhx.feiyanzoubi
\"
}}]}"
,
"images"
:
{
"extension"
:
".png"
,
"enable"
:
true
,
"fileUrl"
:
"upload/image/main/飞檐走壁564-358.png"
,
"width"
:
564
,
"height"
:
358
}
}
]
}
\ No newline at end of file
Please
register
or
sign in
to post a comment