Commit a117c8b4 by 李嘉林

商品列表展示收藏

parent aa0ee60f
...@@ -29,5 +29,9 @@ export default { ...@@ -29,5 +29,9 @@ export default {
// 已加购 // 已加购
query_goods_cart_info(data) { query_goods_cart_info(data) {
return requestPOST(`${process.env.OLSHOP_URL}/cart/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)
},
}; };
...@@ -185,6 +185,8 @@ ...@@ -185,6 +185,8 @@
{{datas.componentData.btnTest}} {{datas.componentData.btnTest}}
</view> </view>
</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> </view>
<!-- 底部展示标签列表 --> <!-- 底部展示标签列表 -->
<block wx:if="{{items!=null}}"> <block wx:if="{{items!=null}}">
...@@ -228,4 +230,5 @@ ...@@ -228,4 +230,5 @@
</view> </view>
</view> </view>
</view> </view>
</view>
...@@ -304,6 +304,11 @@ align-items: flex-start; ...@@ -304,6 +304,11 @@ align-items: flex-start;
bottom: 2px; bottom: 2px;
font-size: 36rpx; font-size: 36rpx;
} }
.start{
position: absolute;
right: 50rpx;
bottom: 0;
}
.showCommission { .showCommission {
width: auto; width: auto;
display: inline-block; display: inline-block;
......
...@@ -462,40 +462,42 @@ const componentOptions = { ...@@ -462,40 +462,42 @@ const componentOptions = {
} }
}); });
let that = this
// 是否加购 // 是否加购
this.getPurchased(goodsList,(list) => { this.getPurchased(goodsList,(list1) => {
let that = this this.collect(list1, (list) => {
let pageGoodsList = this.getStorageSync('pageGoodsList') || [] let pageGoodsList = this.getStorageSync('pageGoodsList') || []
if (flag) { if (flag) {
pageGoodsList[that.data.goodsListIndex] = list; pageGoodsList[that.data.goodsListIndex] = list;
}else{ }else{
pageGoodsList[that.data.datasIndex] = list; pageGoodsList[that.data.datasIndex] = list;
console.log(pageGoodsList[that.data.datasIndex],'--pageGoodsList[that.data.datasIndex]') 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);
} }
} else { this.setStorageSync('pageGoodsList', pageGoodsList);
// 滚动加载
if (this.selectComponent("#waterfallFlow")) {
this.selectComponent("#waterfallFlow").reLoadPro(list); // 获取是否要开启请求拦截
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 = { ...@@ -526,6 +528,33 @@ const componentOptions = {
callback(goodsList); 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(){ lazyloading(){
var that = this var that = this
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment