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
a117c8b4
Commit
a117c8b4
authored
Dec 05, 2022
by
李嘉林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
商品列表展示收藏
parent
aa0ee60f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
32 deletions
+73
-32
src/api/goods.js
+5
-1
static/nativeComponents/GoodsList/GoodsItem/index.wxml
+3
-0
static/nativeComponents/GoodsList/GoodsItem/index.wxss
+5
-0
static/nativeComponents/GoodsList/index.js
+60
-31
No files found.
src/api/goods.js
View file @
a117c8b4
...
...
@@ -29,5 +29,9 @@ export default {
// 已加购
query_goods_cart_info
(
data
)
{
return
requestPOST
(
`
${
process
.
env
.
OLSHOP_URL
}
/cart/query_goods_cart_info`
,
data
)
}
},
// 已收藏
batch_query_collect_count
(
data
)
{
return
requestPOST
(
`
${
process
.
env
.
OLSHOP_URL
}
/product/batch_query_collect_count`
,
data
)
},
};
static/nativeComponents/GoodsList/GoodsItem/index.wxml
View file @
a117c8b4
...
...
@@ -185,6 +185,8 @@
{{datas.componentData.btnTest}}
</view>
</view>
<view class="start" wx:if="{{datas.componentData['collectFlag']}}">
<text style="color:{{datas.componentData.btnColor}}" class="buy-now-icon iconfont-common {{items.collectFlag?'common-iconaixin':'common-iconaixin1'}}"></text>
</view>
<!-- 底部展示标签列表 -->
<block wx:if="{{items!=null}}">
...
...
@@ -228,4 +230,5 @@
</view>
</view>
</view>
</view>
static/nativeComponents/GoodsList/GoodsItem/index.wxss
View file @
a117c8b4
...
...
@@ -304,6 +304,11 @@ align-items: flex-start;
bottom: 2px;
font-size: 36rpx;
}
.start{
position: absolute;
right: 50rpx;
bottom: 0;
}
.showCommission {
width: auto;
display: inline-block;
...
...
static/nativeComponents/GoodsList/index.js
View file @
a117c8b4
...
...
@@ -462,40 +462,42 @@ const componentOptions = {
}
});
let
that
=
this
// 是否加购
this
.
getPurchased
(
goodsList
,(
list
)
=>
{
let
that
=
this
let
pageGoodsList
=
this
.
getStorageSync
(
'pageGoodsList'
)
||
[]
if
(
flag
)
{
pageGoodsList
[
that
.
data
.
goodsListIndex
]
=
list
;
}
else
{
pageGoodsList
[
that
.
data
.
datasIndex
]
=
list
;
console
.
log
(
pageGoodsList
[
that
.
data
.
datasIndex
],
'--pageGoodsList[that.data.datasIndex]'
)
}
this
.
setStorageSync
(
'pageGoodsList'
,
pageGoodsList
);
// 获取是否要开启请求拦截
let
loadingFlag
=
this
.
getStorageSync
(
'loadingFlag'
)
loadingFlag
[
that
.
data
.
datasIndex
]
=
false
this
.
setStorageSync
(
'loadingFlag'
,
loadingFlag
);
that
.
setData
({
"datas.componentData.goodsList"
:
list
,
pageGoodsList
,
loadingFlag
,
scrollLoading
:
false
,
})
if
(
type
==
1
)
{
// 初始化
if
(
this
.
selectComponent
(
"#waterfallFlow"
))
{
this
.
selectComponent
(
"#waterfallFlow"
).
initList
(
list
);
this
.
getPurchased
(
goodsList
,(
list1
)
=>
{
this
.
collect
(
list1
,
(
list
)
=>
{
let
pageGoodsList
=
this
.
getStorageSync
(
'pageGoodsList'
)
||
[]
if
(
flag
)
{
pageGoodsList
[
that
.
data
.
goodsListIndex
]
=
list
;
}
else
{
pageGoodsList
[
that
.
data
.
datasIndex
]
=
list
;
console
.
log
(
pageGoodsList
[
that
.
data
.
datasIndex
],
'--pageGoodsList[that.data.datasIndex]'
)
}
}
else
{
// 滚动加载
if
(
this
.
selectComponent
(
"#waterfallFlow"
))
{
this
.
selectComponent
(
"#waterfallFlow"
).
reLoadPro
(
list
);
this
.
setStorageSync
(
'pageGoodsList'
,
pageGoodsList
);
// 获取是否要开启请求拦截
let
loadingFlag
=
this
.
getStorageSync
(
'loadingFlag'
)
loadingFlag
[
that
.
data
.
datasIndex
]
=
false
this
.
setStorageSync
(
'loadingFlag'
,
loadingFlag
);
that
.
setData
({
"datas.componentData.goodsList"
:
list
,
pageGoodsList
,
loadingFlag
,
scrollLoading
:
false
,
})
if
(
type
==
1
)
{
// 初始化
if
(
this
.
selectComponent
(
"#waterfallFlow"
))
{
this
.
selectComponent
(
"#waterfallFlow"
).
initList
(
list
);
}
}
else
{
// 滚动加载
if
(
this
.
selectComponent
(
"#waterfallFlow"
))
{
this
.
selectComponent
(
"#waterfallFlow"
).
reLoadPro
(
list
);
}
}
}
}
)
});
},
...
...
@@ -526,6 +528,33 @@ const componentOptions = {
callback
(
goodsList
);
}
},
// 收藏状态
collect
(
goodsList
,
callback
)
{
let
{
collectFlag
}
=
this
.
data
.
datas
.
componentData
;
let
list
=
goodsList
.
map
(
item
=>
item
.
productId
);
if
(
collectFlag
)
{
console
.
log
(
"getcollectFlag-list"
,
list
)
// if(!this.render) return;
goodsApi
.
batch_query_collect_count
(
list
).
then
(
res
=>
{
if
(
res
.
data
.
code
==
200
)
{
let
collectFlagList
=
res
.
data
.
data
||
[];
let
collectFlagListIds
=
[...
new
Set
(
collectFlagList
.
map
(
item
=>
item
.
productId
))];
console
.
log
(
collectFlagListIds
,
'---collectFlagListIds'
)
goodsList
.
forEach
(
item
=>
{
item
.
collectFlag
=
false
;
if
(
collectFlagListIds
.
includes
(
item
.
productId
))
{
item
.
collectFlag
=
true
;
console
.
log
(
"---------------1039"
)
}
})
callback
(
goodsList
);
console
.
log
(
goodsList
,
'getcollectFlag---goodsList'
)
}
})
}
else
{
callback
(
goodsList
);
}
},
// 触发图片加载
lazyloading
(){
var
that
=
this
...
...
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