Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mayi-mp-shop
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
程默
mayi-mp-shop
Commits
27016ee0
Commit
27016ee0
authored
Oct 27, 2022
by
李嘉林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
商品列表加载优化
parent
c0b464b9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
15 deletions
+21
-15
src/pages/home/index.vue
+1
-1
static/nativeComponents/GoodsList/index.js
+20
-14
No files found.
src/pages/home/index.vue
View file @
27016ee0
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
<!-- ***这个商品列表组件中需要对数据做缓存,可能有多个地方同时引用此组件
<!-- ***这个商品列表组件中需要对数据做缓存,可能有多个地方同时引用此组件
必须在缓存前加个唯一标识不然所有组件全部操作同一个缓存
必须在缓存前加个唯一标识不然所有组件全部操作同一个缓存
-->
-->
<goods-list
:storageKey=
"'home'+index"
:class=
"
'goodsListItem' + index"
:datas=
"item
"
></goods-list>
<goods-list
:storageKey=
"'home'+index"
:class=
"
['goodsListItem' + index,'goodsListItemIndex0']"
:datas=
"item"
:datasIndex=
"0"
:goodsListIndex=
"0
"
></goods-list>
</div>
</div>
<div
v-else-if=
"item.componentCode == 'area-navigation' && item.componentInfo.visible == 1"
>
<div
v-else-if=
"item.componentCode == 'area-navigation' && item.componentInfo.visible == 1"
>
<area-navigation
:datas=
"item"
:changeLocation=
"changeLocation"
></area-navigation>
<area-navigation
:datas=
"item"
:changeLocation=
"changeLocation"
></area-navigation>
...
...
static/nativeComponents/GoodsList/index.js
View file @
27016ee0
...
@@ -371,20 +371,26 @@ const componentOptions = {
...
@@ -371,20 +371,26 @@ const componentOptions = {
scrollLoading
:
true
scrollLoading
:
true
})
})
let
terminalProductIds
=
[]
let
terminalProductIds
=
[]
console
.
log
(
pageNum
,
'page-----'
);
let
pageNumList
=
this
.
getStorageSync
(
'pageNumList'
)
let
pageNumList
=
this
.
getStorageSync
(
'pageNumList'
)
let
pageNum
=
null
let
pageNum
=
null
if
(
flag
)
{
// 指定商品&网格布局和横向列表使用加载优化。
pageNum
=
pageNumList
[
this
.
data
.
goodsListIndex
]
let
{
style
}
=
this
.
data
.
datas
.
componentData
;
terminalProductIds
=
this
.
getStorageSync
(
'ids'
)[
this
.
data
.
goodsListIndex
].
slice
((
pageNum
-
1
)
*
this
.
data
.
pageSize
,
pageNum
*
this
.
data
.
pageSize
)
if
(
style
==
'list'
||
style
==
'rowList'
)
{
pageNum
+=
1
if
(
flag
)
{
pageNumList
[
this
.
data
.
goodsListIndex
]
=
pageNum
pageNum
=
pageNumList
[
this
.
data
.
goodsListIndex
]
}
else
{
terminalProductIds
=
this
.
getStorageSync
(
'ids'
)[
this
.
data
.
goodsListIndex
].
slice
((
pageNum
-
1
)
*
this
.
data
.
pageSize
,
pageNum
*
this
.
data
.
pageSize
)
pageNum
=
pageNumList
[
this
.
data
.
datasIndex
]
pageNum
+=
1
terminalProductIds
=
this
.
getStorageSync
(
'ids'
)[
this
.
data
.
datasIndex
].
slice
((
pageNum
-
1
)
*
this
.
data
.
pageSize
,
pageNum
*
this
.
data
.
pageSize
)
pageNumList
[
this
.
data
.
goodsListIndex
]
=
pageNum
pageNum
+=
1
}
else
{
pageNumList
[
this
.
data
.
datasIndex
]
=
pageNum
pageNum
=
pageNumList
[
this
.
data
.
datasIndex
]
terminalProductIds
=
this
.
getStorageSync
(
'ids'
)[
this
.
data
.
datasIndex
].
slice
((
pageNum
-
1
)
*
this
.
data
.
pageSize
,
pageNum
*
this
.
data
.
pageSize
)
pageNum
+=
1
pageNumList
[
this
.
data
.
datasIndex
]
=
pageNum
}
}
else
{
terminalProductIds
=
this
.
getStorageSync
(
'ids'
)[
this
.
data
.
goodsListIndex
];
}
}
console
.
log
(
pageNum
,
'page-----'
);
this
.
setStorageSync
(
'pageNumList'
,
pageNumList
)
this
.
setStorageSync
(
'pageNumList'
,
pageNumList
)
let
{
let
{
vipPrice
,
vipPrice
,
...
@@ -407,7 +413,8 @@ const componentOptions = {
...
@@ -407,7 +413,8 @@ const componentOptions = {
goodsApi
.
queryMoreProductInfo
(
moreQuery
).
then
(
res
=>
{
goodsApi
.
queryMoreProductInfo
(
moreQuery
).
then
(
res
=>
{
if
(
res
.
data
.
code
==
200
)
{
if
(
res
.
data
.
code
==
200
)
{
goodsList
=
res
.
data
.
data
;
goodsList
=
res
.
data
.
data
;
this
.
goodsListVal
(
goodsList
,
1
,
flag
);
let
pageGoodsList
=
this
.
data
.
pageGoodsList
[
this
.
data
.
datasIndex
]
||
[];
this
.
goodsListVal
([...
pageGoodsList
,...
goodsList
],
1
,
flag
);
}
}
});
});
},
},
...
@@ -529,7 +536,7 @@ const componentOptions = {
...
@@ -529,7 +536,7 @@ const componentOptions = {
let
{
style
}
=
storageDatasList
[
that
.
data
.
datasIndex
];
let
{
style
}
=
storageDatasList
[
that
.
data
.
datasIndex
];
let
type
=
''
let
type
=
''
if
(
style
==
'list'
){
if
(
style
==
'list'
||
style
==
'rowList'
){
type
=
'goods-item'
type
=
'goods-item'
}
else
{
}
else
{
console
.
log
(
"不是goods-item"
);
console
.
log
(
"不是goods-item"
);
...
@@ -562,7 +569,6 @@ const componentOptions = {
...
@@ -562,7 +569,6 @@ const componentOptions = {
pageGoodsList
[
that
.
data
.
datasIndex
][
index
].
loadState
=
true
pageGoodsList
[
that
.
data
.
datasIndex
][
index
].
loadState
=
true
}
}
}
}
that
.
setData
({
that
.
setData
({
pageGoodsList
,
pageGoodsList
,
})
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment