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 @@
<!-- ***这个商品列表组件中需要对数据做缓存,可能有多个地方同时引用此组件
必须在缓存前加个唯一标识不然所有组件全部操作同一个缓存
-->
<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
v-else-if=
"item.componentCode == 'area-navigation' && item.componentInfo.visible == 1"
>
<area-navigation
:datas=
"item"
:changeLocation=
"changeLocation"
></area-navigation>
...
...
static/nativeComponents/GoodsList/index.js
View file @
27016ee0
...
...
@@ -371,20 +371,26 @@ const componentOptions = {
scrollLoading
:
true
})
let
terminalProductIds
=
[]
console
.
log
(
pageNum
,
'page-----'
);
let
pageNumList
=
this
.
getStorageSync
(
'pageNumList'
)
let
pageNum
=
null
if
(
flag
)
{
pageNum
=
pageNumList
[
this
.
data
.
goodsListIndex
]
terminalProductIds
=
this
.
getStorageSync
(
'ids'
)[
this
.
data
.
goodsListIndex
].
slice
((
pageNum
-
1
)
*
this
.
data
.
pageSize
,
pageNum
*
this
.
data
.
pageSize
)
pageNum
+=
1
pageNumList
[
this
.
data
.
goodsListIndex
]
=
pageNum
}
else
{
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
// 指定商品&网格布局和横向列表使用加载优化。
let
{
style
}
=
this
.
data
.
datas
.
componentData
;
if
(
style
==
'list'
||
style
==
'rowList'
)
{
if
(
flag
)
{
pageNum
=
pageNumList
[
this
.
data
.
goodsListIndex
]
terminalProductIds
=
this
.
getStorageSync
(
'ids'
)[
this
.
data
.
goodsListIndex
].
slice
((
pageNum
-
1
)
*
this
.
data
.
pageSize
,
pageNum
*
this
.
data
.
pageSize
)
pageNum
+=
1
pageNumList
[
this
.
data
.
goodsListIndex
]
=
pageNum
}
else
{
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
)
let
{
vipPrice
,
...
...
@@ -407,7 +413,8 @@ const componentOptions = {
goodsApi
.
queryMoreProductInfo
(
moreQuery
).
then
(
res
=>
{
if
(
res
.
data
.
code
==
200
)
{
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 = {
let
{
style
}
=
storageDatasList
[
that
.
data
.
datasIndex
];
let
type
=
''
if
(
style
==
'list'
){
if
(
style
==
'list'
||
style
==
'rowList'
){
type
=
'goods-item'
}
else
{
console
.
log
(
"不是goods-item"
);
...
...
@@ -562,7 +569,6 @@ const componentOptions = {
pageGoodsList
[
that
.
data
.
datasIndex
][
index
].
loadState
=
true
}
}
that
.
setData
({
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