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
74e4a3d7
...
74e4a3d7a144cda8c34faf3ee95b38ffca9d9c81
authored
2020-03-11 17:24:41 +0800
by
金学艇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.解决列表页Android端加载数据异步问题
1 parent
2b6708fb
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
166 additions
and
91 deletions
assets/Script/gameCategory.js
assets/Script/gameDetail.js
assets/Script/gameLoading.js
assets/resources/Prefab/pfbMainViewPagerLabelCell.prefab
assets/Script/gameCategory.js
View file @
74e4a3d
...
...
@@ -39,32 +39,6 @@ cc.Class({
// fiScrollBtn.init(null, true);
this
.
getNavList
();
//获取导航栏信息
this
.
getCategoryListJsonRequest
();
},
getCategoryListJsonRequest
:
function
()
{
var
self
=
this
;
var
aJsonList
=
[
"catetory_jtdr_list.json"
,
"catetory_all_list.json"
,
"catetory_nlbz_list.json"
,
"catetory_3dyx_list.json"
,
"catetory_xyx_list.json"
,
"catetory_tyjj_list.json"
];
this
.
aCategoryListJson
=
[];
if
(
this
.
aCategoryListJson
&&
this
.
aCategoryListJson
.
length
>
0
)
{
return
;
}
for
(
let
i
=
0
;
i
<
aJsonList
.
length
;
i
++
)
{
//这里可能会导致对应导航错乱,改为同步请求
CCNetwork
.
ajax
(
"GET"
,
Common
.
TOPDRAW_API_SERVER
+
"main/"
+
aJsonList
[
i
],
null
,
null
,
function
(
strResponse
)
{
try
{
// cc.log("远程数据:"+strResponse);
var
oJSONResult
=
JSON
.
parse
(
strResponse
);
this
.
aCategoryListJson
.
push
(
strResponse
);
// cc.log("请求数据返回:" + oJSONResult.count);
}
catch
(
error
)
{
cc
.
log
(
"Business Exception:Get getCategoryListJsonRequest..."
+
error
);
}
},
function
(
strResponse
)
{
cc
.
log
(
"Business Error:Get getCategoryListJsonRequest..."
+
strResponse
);
},
this
,
"uuid"
);
}
},
getNavList
:
function
()
{
...
...
@@ -138,7 +112,8 @@ cc.Class({
}
this
.
_oSceneContext
.
focusPath
=
"TypeListArea/TypeListWrapper/TypeList/topNavi"
+
this
.
_oSceneContext
.
_iCurrentLeftIndex
;
this
.
checkDataReadyAndInitFocus
();
this
.
requestMediaList
(
1
);
// this.requestMediaList(1);
this
.
getSimulateRequest
();
}
else
{
cc
.
log
(
"Business Error:getNavList..."
+
oJSONResult
.
description
);
}
...
...
@@ -151,6 +126,29 @@ cc.Class({
},
this
,
"uuid"
);
},
getSimulateRequest
:
function
()
{
var
self
=
this
;
var
aJsonList
=
[
"catetory_jtdr_list.json"
,
"catetory_all_list.json"
,
"catetory_nlbz_list.json"
,
"catetory_3dyx_list.json"
,
"catetory_xyx_list.json"
,
"catetory_tyjj_list.json"
];
if
(
this
.
_oInit
[
this
.
_oSceneContext
.
_iCurrentLeftIndex
])
{
//已经加载过数据直接取
self
.
requestMediaList
(
1
);
}
else
{
Network
.
ajax
(
"GET"
,
Common
.
TOPDRAW_API_SERVER
+
"main/"
+
aJsonList
[
this
.
_oSceneContext
.
_iCurrentLeftIndex
],
null
,
null
,
function
(
strResponse
)
{
try
{
this
.
_oInit
[
this
.
_oSceneContext
.
_iCurrentLeftIndex
]
=
strResponse
;
this
.
scheduleOnce
(
function
()
{
self
.
requestMediaList
(
1
);
//重新渲染CategoryList
},
0
);
}
catch
(
error
)
{
cc
.
log
(
"Business Exception:Get getSimulateRequest..."
+
error
);
}
},
function
(
strResponse
)
{
cc
.
log
(
"Business Error:Get getSimulateRequest..."
+
strResponse
);
},
this
,
"uuid"
);
}
},
requestMediaList
:
function
(
cId
)
{
var
self
=
this
;
if
(
cId
)
{
...
...
@@ -262,8 +260,9 @@ cc.Class({
);
// lvCategoryList.loadData(
// function (strResponse) {
// cc.log("/////" + JSON.stringify(this.test_list_json1.json));
let
strResponse
=
this
.
aCategoryListJson
[
this
.
_oSceneContext
.
_iCurrentLeftIndex
];
// cc.log("/////" + this._oInit[this._oSceneContext._iCurrentLeftIndex]);
// let strResponse = this.aCategoryListJson[this._oSceneContext._iCurrentLeftIndex];
let
strResponse
=
this
.
_oInit
[
this
.
_oSceneContext
.
_iCurrentLeftIndex
];
lvCategoryList
.
renderInitData
(
strResponse
,
function
()
{
// cc.log("InitCategoryList-------------------->");
var
oJSONResult
=
JSON
.
parse
(
strResponse
);
...
...
@@ -378,7 +377,7 @@ cc.Class({
var
index
=
parseInt
(
this
.
_fiCurrentFocus
.
node
.
getName
().
replace
(
'CategoryListCell'
,
''
));
// cc.log("当前时多少条目:" + index);
let
lvCategoryList
=
this
.
node
.
getChildByName
(
'CategoryList'
).
getComponent
(
ListView
);
if
(
lvCategoryList
.
scrollARowUp
(
index
,
this
.
aCategoryListJson
[
this
.
_oSceneContext
.
_iCurrentLeftIndex
]))
{
if
(
lvCategoryList
.
scrollARowUp
(
index
,
this
.
_oInit
[
this
.
_oSceneContext
.
_iCurrentLeftIndex
]))
{
return
;
}
}
...
...
@@ -396,7 +395,7 @@ cc.Class({
if
(
0
==
this
.
_fiCurrentFocus
.
node
.
getName
().
indexOf
(
'CategoryListCell'
))
{
var
index
=
parseInt
(
this
.
_fiCurrentFocus
.
node
.
getName
().
replace
(
'CategoryListCell'
,
''
));
let
lvCategoryList
=
this
.
node
.
getChildByName
(
'CategoryList'
).
getComponent
(
ListView
);
if
(
lvCategoryList
.
scrollARowDown
(
null
,
index
,
this
.
aCategoryListJson
[
this
.
_oSceneContext
.
_iCurrentLeftIndex
]))
{
if
(
lvCategoryList
.
scrollARowDown
(
null
,
index
,
this
.
_oInit
[
this
.
_oSceneContext
.
_iCurrentLeftIndex
]))
{
return
;
}
}
...
...
@@ -536,7 +535,8 @@ cc.Class({
this
.
_oSceneContext
.
_iCurrentLeftIndex
=
iIndex
;
this
.
scheduleOnce
(
function
()
{
this
.
requestMediaList
(
1
);
//重新渲染CategoryList
// this.requestMediaList(1); //重新渲染CategoryList
this
.
getSimulateRequest
();
},
0
);
}
...
...
assets/Script/gameDetail.js
View file @
74e4a3d
...
...
@@ -457,9 +457,9 @@ cc.Class({
jsb
.
reflection
.
callStaticMethod
(
"com/topdraw/melody/TopdrawSDKWrapper"
,
"startOBiGame"
,
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"
,
Common
.
TOPDRAW_API_SERVER
+
this
.
_oSceneContext
.
_downloadUrl
,
this
.
_oSceneContext
.
_packageName
,
this
.
_oSceneContext
.
_className
,
""
);
}
else
{
//这里应该转圈圈等待加载游戏
cc
.
find
(
"LoadingLabel"
,
this
.
node
).
opacity
=
255
;
cc
.
find
(
"Loading/LoadingIcon"
,
this
.
node
).
opacity
=
255
;
cc
.
find
(
"Loading/LoadingIcon"
,
this
.
node
).
getComponent
(
cc
.
Animation
).
play
();
//
cc.find("LoadingLabel", this.node).opacity = 255;
//
cc.find("Loading/LoadingIcon", this.node).opacity = 255;
//
cc.find("Loading/LoadingIcon", this.node).getComponent(cc.Animation).play();
jsb
.
reflection
.
callStaticMethod
(
"com/topdraw/melody/TopdrawSDKWrapper"
,
"startGame"
,
"(Ljava/lang/String;Ljava/lang/String;)V"
,
this
.
_oSceneContext
.
_packageName
,
""
);
}
}
else
{
...
...
assets/Script/gameLoading.js
View file @
74e4a3d
...
...
@@ -58,6 +58,51 @@ cc.Class({
}
},
keyDownDirection
:
function
(
Direct
)
{
var
fiFocusTarget
=
null
;
var
fiCurrentFocus
=
this
.
_fiCurrentFocus
;
var
oScrollParameter
=
null
;
let
aCheckResult
;
fiFocusTarget
=
this
.
_cFocus
.
findTarget
(
fiCurrentFocus
,
this
.
_aFocusTargets
,
this
.
_iSceneStatus
,
Direct
);
if
(
!
fiFocusTarget
)
{
return
;
}
// aCheckResult = this.checkFocusTarget(fiFocusTarget, oScrollParameter);
// fiFocusTarget = aCheckResult[0];
// oScrollParameter = aCheckResult[1];
this
.
_cFocus
.
flyFocus
(
this
.
_fiCurrentFocus
,
fiFocusTarget
,
Direct
,
null
,
oScrollParameter
);
},
onKeyDown
:
function
(
event
)
{
this
.
_super
(
event
);
switch
(
event
.
keyCode
)
{
case
cc
.
macro
.
KEY
.
up
:
case
Common
.
ANDROID_KEY
.
up
:
this
.
keyDownDirection
(
Common
.
MOVE_DIRECTION_UP
);
break
;
case
cc
.
macro
.
KEY
.
right
:
case
Common
.
ANDROID_KEY
.
right
:
this
.
keyDownDirection
(
Common
.
MOVE_DIRECTION_RIGHT
);
break
;
case
cc
.
macro
.
KEY
.
down
:
case
Common
.
ANDROID_KEY
.
down
:
this
.
keyDownDirection
(
Common
.
MOVE_DIRECTION_DOWN
);
break
;
case
cc
.
macro
.
KEY
.
left
:
case
Common
.
ANDROID_KEY
.
left
:
this
.
keyDownDirection
(
Common
.
MOVE_DIRECTION_LEFT
);
break
;
case
cc
.
macro
.
KEY
.
enter
:
case
cc
.
macro
.
KEY
.
space
:
case
Common
.
ANDROID_KEY
.
enter
:
// this.doCurrentFocusTVLinkAction(Common.TV_LINK_ACTION_CLICK);
break
;
case
cc
.
macro
.
KEY
.
backspace
:
case
Common
.
ANDROID_KEY
.
back
:
this
.
_bIsFocusInit
=
true
;
this
.
backAScene
();
break
;
}
},
// hideLoadingIcon: function () {
// cc.log("隐藏LoadingIcon...");
// cc.find("Loading/LoadingIcon", this.node).getComponent(cc.Animation).pause();
...
...
assets/resources/Prefab/pfbMainViewPagerLabelCell.prefab
View file @
74e4a3d
...
...
@@ -24,23 +24,23 @@
"__id__": 6
},
{
"__id__": 4
0
"__id__": 4
1
}
],
"_active": true,
"_components": [
{
"__id__": 50
},
{
"__id__": 51
},
{
"__id__": 52
},
{
"__id__": 53
}
],
"_prefab": {
"__id__": 5
3
"__id__": 5
4
},
"_opacity": 255,
"_color": {
...
...
@@ -120,7 +120,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 53.83,
"height":
50.4
"height":
37.8
},
"_anchorPoint": {
"__type__": "cc.Vec2",
...
...
@@ -173,7 +173,7 @@
"_string": "Label",
"_N$string": "Label",
"_fontSize": 22,
"_lineHeight":
4
0,
"_lineHeight":
3
0,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
...
...
@@ -199,7 +199,7 @@
"_alignFlags": 8,
"_left": 24,
"_right": 0,
"_top":
0
,
"_top":
24.1
,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
...
...
@@ -242,11 +242,11 @@
"_active": false,
"_components": [
{
"__id__": 3
8
"__id__": 3
9
}
],
"_prefab": {
"__id__":
39
"__id__":
40
},
"_opacity": 255,
"_color": {
...
...
@@ -326,7 +326,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 200,
"height": 3
4
"height": 3
0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
...
...
@@ -378,8 +378,8 @@
"_useOriginalSize": false,
"_string": "脑力训练",
"_N$string": "脑力训练",
"_fontSize": 2
4
,
"_lineHeight": 3
4
,
"_fontSize": 2
2
,
"_lineHeight": 3
0
,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
...
...
@@ -405,9 +405,9 @@
"__id__": 1
},
"_alignFlags": 9,
"_left": 2
6
,
"_left": 2
4
,
"_right": 0,
"_top": 1
7
,
"_top": 1
5
,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
...
...
@@ -450,14 +450,14 @@
"_active": true,
"_components": [
{
"__id__": 3
5
"__id__": 3
6
},
{
"__id__": 3
6
"__id__": 3
7
}
],
"_prefab": {
"__id__": 3
7
"__id__": 3
8
},
"_opacity": 255,
"_color": {
...
...
@@ -740,7 +740,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 69,
"height":
31.5
"height":
22
},
"_anchorPoint": {
"__type__": "cc.Vec2",
...
...
@@ -792,8 +792,8 @@
"_useOriginalSize": false,
"_string": "载入中...",
"_N$string": "载入中...",
"_fontSize": 1
8
,
"_lineHeight": 2
5
,
"_fontSize": 1
6
,
"_lineHeight": 2
2
,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
...
...
@@ -875,7 +875,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 69,
"height":
31.5
"height":
22
},
"_anchorPoint": {
"__type__": "cc.Vec2",
...
...
@@ -927,8 +927,8 @@
"_useOriginalSize": false,
"_string": "载入中...",
"_N$string": "载入中...",
"_fontSize": 1
8
,
"_lineHeight": 2
5
,
"_fontSize": 1
6
,
"_lineHeight": 2
2
,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
...
...
@@ -989,11 +989,11 @@
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags":
9
,
"_left": 2
6
,
"_alignFlags":
12
,
"_left": 2
4
,
"_right": 0,
"_top": 5
6
,
"_bottom":
0
,
"_top": 5
1
,
"_bottom":
15
,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
...
...
@@ -1074,14 +1074,14 @@
"_active": true,
"_components": [
{
"__id__": 3
2
"__id__": 3
3
},
{
"__id__": 3
3
"__id__": 3
4
}
],
"_prefab": {
"__id__": 3
4
"__id__": 3
5
},
"_opacity": 255,
"_color": {
...
...
@@ -1142,10 +1142,13 @@
"_components": [
{
"__id__": 30
},
{
"__id__": 31
}
],
"_prefab": {
"__id__": 3
1
"__id__": 3
2
},
"_opacity": 255,
"_color": {
...
...
@@ -1158,7 +1161,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 72,
"height":
31.5
"height":
22
},
"_anchorPoint": {
"__type__": "cc.Vec2",
...
...
@@ -1210,8 +1213,8 @@
"_useOriginalSize": false,
"_string": "游戏名称",
"_N$string": "游戏名称",
"_fontSize": 1
8
,
"_lineHeight": 2
5
,
"_fontSize": 1
6
,
"_lineHeight": 2
2
,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
...
...
@@ -1225,6 +1228,33 @@
"_id": ""
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 29
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 9,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
...
...
@@ -1265,11 +1295,11 @@
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags":
9
,
"_left": 2
6
,
"_alignFlags":
12
,
"_left": 2
4
,
"_right": 0,
"_top": 5
6
,
"_bottom":
0
,
"_top": 5
1
,
"_bottom":
15
,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
...
...
@@ -1409,16 +1439,16 @@
},
"_children": [
{
"__id__": 4
1
"__id__": 4
2
},
{
"__id__": 4
5
"__id__": 4
6
}
],
"_active": false,
"_components": [],
"_prefab": {
"__id__":
49
"__id__":
50
},
"_opacity": 255,
"_color": {
...
...
@@ -1472,20 +1502,20 @@
"_name": "Title",
"_objFlags": 0,
"_parent": {
"__id__": 4
0
"__id__": 4
1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 4
2
"__id__": 4
3
},
{
"__id__": 4
3
"__id__": 4
4
}
],
"_prefab": {
"__id__": 4
4
"__id__": 4
5
},
"_opacity": 255,
"_color": {
...
...
@@ -1539,7 +1569,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 4
1
"__id__": 4
2
},
"_enabled": true,
"_materials": [
...
...
@@ -1569,7 +1599,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 4
1
"__id__": 4
2
},
"_enabled": true,
"alignMode": 1,
...
...
@@ -1607,20 +1637,20 @@
"_name": "Name",
"_objFlags": 0,
"_parent": {
"__id__": 4
0
"__id__": 4
1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 4
6
"__id__": 4
7
},
{
"__id__": 4
7
"__id__": 4
8
}
],
"_prefab": {
"__id__": 4
8
"__id__": 4
9
},
"_opacity": 255,
"_color": {
...
...
@@ -1674,7 +1704,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 4
5
"__id__": 4
6
},
"_enabled": true,
"_materials": [
...
...
@@ -1704,7 +1734,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 4
5
"__id__": 4
6
},
"_enabled": true,
"alignMode": 1,
...
...
@@ -1832,10 +1862,10 @@
"__id__": 30
},
"afterTitle": {
"__id__": 4
2
"__id__": 4
3
},
"afterName": {
"__id__": 4
6
"__id__": 4
7
},
"_id": ""
},
...
...
Please
register
or
sign in
to post a comment